@@ -465,6 +465,8 @@ impl EventCacheStore for SqliteEventCacheStore {
465
465
key : & str ,
466
466
holder : & str ,
467
467
) -> Result < bool > {
468
+ let _timer = timer ! ( "method" ) ;
469
+
468
470
let key = key. to_owned ( ) ;
469
471
let holder = holder. to_owned ( ) ;
470
472
@@ -498,6 +500,8 @@ impl EventCacheStore for SqliteEventCacheStore {
498
500
linked_chunk_id : LinkedChunkId < ' _ > ,
499
501
updates : Vec < Update < Event , Gap > > ,
500
502
) -> Result < ( ) , Self :: Error > {
503
+ let _timer = timer ! ( "method" ) ;
504
+
501
505
// Use a single transaction throughout this function, so that either all updates
502
506
// work, or none is taken into account.
503
507
let hashed_linked_chunk_id =
@@ -826,6 +830,8 @@ impl EventCacheStore for SqliteEventCacheStore {
826
830
& self ,
827
831
linked_chunk_id : LinkedChunkId < ' _ > ,
828
832
) -> Result < Vec < RawChunk < Event , Gap > > , Self :: Error > {
833
+ let _timer = timer ! ( "method" ) ;
834
+
829
835
let hashed_linked_chunk_id =
830
836
self . encode_key ( keys:: LINKED_CHUNKS , linked_chunk_id. storage_key ( ) ) ;
831
837
@@ -868,6 +874,8 @@ impl EventCacheStore for SqliteEventCacheStore {
868
874
& self ,
869
875
linked_chunk_id : LinkedChunkId < ' _ > ,
870
876
) -> Result < Vec < ChunkMetadata > , Self :: Error > {
877
+ let _timer = timer ! ( "method" ) ;
878
+
871
879
let hashed_linked_chunk_id =
872
880
self . encode_key ( keys:: LINKED_CHUNKS , linked_chunk_id. storage_key ( ) ) ;
873
881
@@ -929,6 +937,8 @@ impl EventCacheStore for SqliteEventCacheStore {
929
937
& self ,
930
938
linked_chunk_id : LinkedChunkId < ' _ > ,
931
939
) -> Result < ( Option < RawChunk < Event , Gap > > , ChunkIdentifierGenerator ) , Self :: Error > {
940
+ let _timer = timer ! ( "method" ) ;
941
+
932
942
let hashed_linked_chunk_id =
933
943
self . encode_key ( keys:: LINKED_CHUNKS , linked_chunk_id. storage_key ( ) ) ;
934
944
@@ -1023,6 +1033,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1023
1033
linked_chunk_id : LinkedChunkId < ' _ > ,
1024
1034
before_chunk_identifier : ChunkIdentifier ,
1025
1035
) -> Result < Option < RawChunk < Event , Gap > > , Self :: Error > {
1036
+ let _timer = timer ! ( "method" ) ;
1037
+
1026
1038
let hashed_linked_chunk_id =
1027
1039
self . encode_key ( keys:: LINKED_CHUNKS , linked_chunk_id. storage_key ( ) ) ;
1028
1040
@@ -1071,6 +1083,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1071
1083
1072
1084
#[ instrument( skip( self ) ) ]
1073
1085
async fn clear_all_linked_chunks ( & self ) -> Result < ( ) , Self :: Error > {
1086
+ let _timer = timer ! ( "method" ) ;
1087
+
1074
1088
self . write ( )
1075
1089
. await ?
1076
1090
. with_transaction ( move |txn| {
@@ -1080,6 +1094,7 @@ impl EventCacheStore for SqliteEventCacheStore {
1080
1094
txn. execute ( "DELETE FROM events" , ( ) )
1081
1095
} )
1082
1096
. await ?;
1097
+
1083
1098
Ok ( ( ) )
1084
1099
}
1085
1100
@@ -1089,6 +1104,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1089
1104
linked_chunk_id : LinkedChunkId < ' _ > ,
1090
1105
events : Vec < OwnedEventId > ,
1091
1106
) -> Result < Vec < ( OwnedEventId , Position ) > , Self :: Error > {
1107
+ let _timer = timer ! ( "method" ) ;
1108
+
1092
1109
// If there's no events for which we want to check duplicates, we can return
1093
1110
// early. It's not only an optimization to do so: it's required, otherwise the
1094
1111
// `repeat_vars` call below will panic.
@@ -1169,6 +1186,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1169
1186
room_id : & RoomId ,
1170
1187
event_id : & EventId ,
1171
1188
) -> Result < Option < Event > , Self :: Error > {
1189
+ let _timer = timer ! ( "method" ) ;
1190
+
1172
1191
let event_id = event_id. to_owned ( ) ;
1173
1192
let this = self . clone ( ) ;
1174
1193
@@ -1200,6 +1219,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1200
1219
event_id : & EventId ,
1201
1220
filters : Option < & [ RelationType ] > ,
1202
1221
) -> Result < Vec < ( Event , Option < Position > ) > , Self :: Error > {
1222
+ let _timer = timer ! ( "method" ) ;
1223
+
1203
1224
let hashed_room_id = self . encode_key ( keys:: LINKED_CHUNKS , room_id) ;
1204
1225
1205
1226
let hashed_linked_chunk_id =
@@ -1226,6 +1247,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1226
1247
1227
1248
#[ instrument( skip( self , event) ) ]
1228
1249
async fn save_event ( & self , room_id : & RoomId , event : Event ) -> Result < ( ) , Self :: Error > {
1250
+ let _timer = timer ! ( "method" ) ;
1251
+
1229
1252
let Some ( event_id) = event. event_id ( ) else {
1230
1253
error ! ( %room_id, "Trying to save an event with no ID" ) ;
1231
1254
return Ok ( ( ) ) ;
@@ -1254,6 +1277,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1254
1277
content : Vec < u8 > ,
1255
1278
ignore_policy : IgnoreMediaRetentionPolicy ,
1256
1279
) -> Result < ( ) > {
1280
+ let _timer = timer ! ( "method" ) ;
1281
+
1257
1282
self . media_service . add_media_content ( self , request, content, ignore_policy) . await
1258
1283
}
1259
1284
@@ -1263,6 +1288,8 @@ impl EventCacheStore for SqliteEventCacheStore {
1263
1288
from : & MediaRequestParameters ,
1264
1289
to : & MediaRequestParameters ,
1265
1290
) -> Result < ( ) , Self :: Error > {
1291
+ let _timer = timer ! ( "method" ) ;
1292
+
1266
1293
let prev_uri = self . encode_key ( keys:: MEDIA , from. source . unique_key ( ) ) ;
1267
1294
let prev_format = self . encode_key ( keys:: MEDIA , from. format . unique_key ( ) ) ;
1268
1295
@@ -1281,11 +1308,15 @@ impl EventCacheStore for SqliteEventCacheStore {
1281
1308
1282
1309
#[ instrument( skip_all) ]
1283
1310
async fn get_media_content ( & self , request : & MediaRequestParameters ) -> Result < Option < Vec < u8 > > > {
1311
+ let _timer = timer ! ( "method" ) ;
1312
+
1284
1313
self . media_service . get_media_content ( self , request) . await
1285
1314
}
1286
1315
1287
1316
#[ instrument( skip_all) ]
1288
1317
async fn remove_media_content ( & self , request : & MediaRequestParameters ) -> Result < ( ) > {
1318
+ let _timer = timer ! ( "method" ) ;
1319
+
1289
1320
let uri = self . encode_key ( keys:: MEDIA , request. source . unique_key ( ) ) ;
1290
1321
let format = self . encode_key ( keys:: MEDIA , request. format . unique_key ( ) ) ;
1291
1322
@@ -1300,11 +1331,15 @@ impl EventCacheStore for SqliteEventCacheStore {
1300
1331
& self ,
1301
1332
uri : & MxcUri ,
1302
1333
) -> Result < Option < Vec < u8 > > , Self :: Error > {
1334
+ let _timer = timer ! ( "method" ) ;
1335
+
1303
1336
self . media_service . get_media_content_for_uri ( self , uri) . await
1304
1337
}
1305
1338
1306
1339
#[ instrument( skip( self ) ) ]
1307
1340
async fn remove_media_content_for_uri ( & self , uri : & MxcUri ) -> Result < ( ) > {
1341
+ let _timer = timer ! ( "method" ) ;
1342
+
1308
1343
let uri = self . encode_key ( keys:: MEDIA , uri) ;
1309
1344
1310
1345
let conn = self . write ( ) . await ?;
@@ -1318,11 +1353,15 @@ impl EventCacheStore for SqliteEventCacheStore {
1318
1353
& self ,
1319
1354
policy : MediaRetentionPolicy ,
1320
1355
) -> Result < ( ) , Self :: Error > {
1356
+ let _timer = timer ! ( "method" ) ;
1357
+
1321
1358
self . media_service . set_media_retention_policy ( self , policy) . await
1322
1359
}
1323
1360
1324
1361
#[ instrument( skip_all) ]
1325
1362
fn media_retention_policy ( & self ) -> MediaRetentionPolicy {
1363
+ let _timer = timer ! ( "method" ) ;
1364
+
1326
1365
self . media_service . media_retention_policy ( )
1327
1366
}
1328
1367
@@ -1332,11 +1371,15 @@ impl EventCacheStore for SqliteEventCacheStore {
1332
1371
request : & MediaRequestParameters ,
1333
1372
ignore_policy : IgnoreMediaRetentionPolicy ,
1334
1373
) -> Result < ( ) , Self :: Error > {
1374
+ let _timer = timer ! ( "method" ) ;
1375
+
1335
1376
self . media_service . set_ignore_media_retention_policy ( self , request, ignore_policy) . await
1336
1377
}
1337
1378
1338
1379
#[ instrument( skip_all) ]
1339
1380
async fn clean_up_media_cache ( & self ) -> Result < ( ) , Self :: Error > {
1381
+ let _timer = timer ! ( "method" ) ;
1382
+
1340
1383
self . media_service . clean_up_media_cache ( self ) . await
1341
1384
}
1342
1385
}
0 commit comments