1- use std:: { ops:: Deref , sync :: Arc } ;
1+ use std:: ops:: Deref ;
22
33use criterion:: * ;
4- use matrix_sdk_common:: uuid:: Uuid ;
54use matrix_sdk_crypto:: { EncryptionSettings , OlmMachine } ;
65use matrix_sdk_test:: response_from_file;
76use ruma:: {
@@ -12,7 +11,7 @@ use ruma::{
1211 } ,
1312 IncomingResponse ,
1413 } ,
15- device_id, room_id, user_id, DeviceId , UserId ,
14+ device_id, room_id, user_id, DeviceId , TransactionId , UserId ,
1615} ;
1716use serde_json:: Value ;
1817use tokio:: runtime:: Builder ;
@@ -51,7 +50,7 @@ pub fn keys_query(c: &mut Criterion) {
5150 let runtime = Builder :: new_multi_thread ( ) . build ( ) . expect ( "Can't create runtime" ) ;
5251 let machine = OlmMachine :: new ( alice_id ( ) , alice_device_id ( ) ) ;
5352 let response = keys_query_response ( ) ;
54- let uuid = Uuid :: new_v4 ( ) ;
53+ let txn_id = TransactionId :: new ( ) ;
5554
5655 let count = response. device_keys . values ( ) . fold ( 0 , |acc, d| acc + d. len ( ) )
5756 + response. master_keys . len ( )
@@ -65,7 +64,7 @@ pub fn keys_query(c: &mut Criterion) {
6564
6665 group. bench_with_input ( BenchmarkId :: new ( "memory store" , & name) , & response, |b, response| {
6766 b. to_async ( & runtime)
68- . iter ( || async { machine. mark_request_as_sent ( & uuid , response) . await . unwrap ( ) } )
67+ . iter ( || async { machine. mark_request_as_sent ( & txn_id , response) . await . unwrap ( ) } )
6968 } ) ;
7069
7170 let dir = tempfile:: tempdir ( ) . unwrap ( ) ;
@@ -80,17 +79,17 @@ pub fn keys_query(c: &mut Criterion) {
8079
8180 group. bench_with_input ( BenchmarkId :: new ( "sled store" , & name) , & response, |b, response| {
8281 b. to_async ( & runtime)
83- . iter ( || async { machine. mark_request_as_sent ( & uuid , response) . await . unwrap ( ) } )
82+ . iter ( || async { machine. mark_request_as_sent ( & txn_id , response) . await . unwrap ( ) } )
8483 } ) ;
8584
8685 group. finish ( )
8786}
8887
8988pub fn keys_claiming ( c : & mut Criterion ) {
90- let runtime = Arc :: new ( Builder :: new_multi_thread ( ) . build ( ) . expect ( "Can't create runtime" ) ) ;
89+ let runtime = Builder :: new_multi_thread ( ) . build ( ) . expect ( "Can't create runtime" ) ;
9190
9291 let keys_query_response = keys_query_response ( ) ;
93- let uuid = Uuid :: new_v4 ( ) ;
92+ let txn_id = TransactionId :: new ( ) ;
9493
9594 let response = keys_claim_response ( ) ;
9695
@@ -106,12 +105,12 @@ pub fn keys_claiming(c: &mut Criterion) {
106105 || {
107106 let machine = OlmMachine :: new ( alice_id ( ) , alice_device_id ( ) ) ;
108107 runtime
109- . block_on ( machine. mark_request_as_sent ( & uuid , & keys_query_response) )
108+ . block_on ( machine. mark_request_as_sent ( & txn_id , & keys_query_response) )
110109 . unwrap ( ) ;
111- ( machine, runtime. clone ( ) )
110+ ( machine, & runtime, & txn_id )
112111 } ,
113- move |( machine, runtime) | {
114- runtime. block_on ( machine. mark_request_as_sent ( & uuid , response) ) . unwrap ( )
112+ move |( machine, runtime, txn_id ) | {
113+ runtime. block_on ( machine. mark_request_as_sent ( txn_id , response) ) . unwrap ( )
115114 } ,
116115 BatchSize :: SmallInput ,
117116 )
@@ -130,12 +129,12 @@ pub fn keys_claiming(c: &mut Criterion) {
130129 ) )
131130 . unwrap ( ) ;
132131 runtime
133- . block_on ( machine. mark_request_as_sent ( & uuid , & keys_query_response) )
132+ . block_on ( machine. mark_request_as_sent ( & txn_id , & keys_query_response) )
134133 . unwrap ( ) ;
135- ( machine, runtime. clone ( ) )
134+ ( machine, & runtime, & txn_id )
136135 } ,
137- move |( machine, runtime) | {
138- runtime. block_on ( machine. mark_request_as_sent ( & uuid , response) ) . unwrap ( )
136+ move |( machine, runtime, txn_id ) | {
137+ runtime. block_on ( machine. mark_request_as_sent ( txn_id , response) ) . unwrap ( )
139138 } ,
140139 BatchSize :: SmallInput ,
141140 )
@@ -148,7 +147,7 @@ pub fn room_key_sharing(c: &mut Criterion) {
148147 let runtime = Builder :: new_multi_thread ( ) . build ( ) . expect ( "Can't create runtime" ) ;
149148
150149 let keys_query_response = keys_query_response ( ) ;
151- let uuid = Uuid :: new_v4 ( ) ;
150+ let txn_id = TransactionId :: new ( ) ;
152151 let response = keys_claim_response ( ) ;
153152 let room_id = room_id ! ( "!test:localhost" ) ;
154153
@@ -158,8 +157,8 @@ pub fn room_key_sharing(c: &mut Criterion) {
158157 let count = response. one_time_keys . values ( ) . fold ( 0 , |acc, d| acc + d. len ( ) ) ;
159158
160159 let machine = OlmMachine :: new ( alice_id ( ) , alice_device_id ( ) ) ;
161- runtime. block_on ( machine. mark_request_as_sent ( & uuid , & keys_query_response) ) . unwrap ( ) ;
162- runtime. block_on ( machine. mark_request_as_sent ( & uuid , & response) ) . unwrap ( ) ;
160+ runtime. block_on ( machine. mark_request_as_sent ( & txn_id , & keys_query_response) ) . unwrap ( ) ;
161+ runtime. block_on ( machine. mark_request_as_sent ( & txn_id , & response) ) . unwrap ( ) ;
163162
164163 let mut group = c. benchmark_group ( "Room key sharing" ) ;
165164 group. throughput ( Throughput :: Elements ( count as u64 ) ) ;
@@ -195,8 +194,8 @@ pub fn room_key_sharing(c: &mut Criterion) {
195194 None ,
196195 ) )
197196 . unwrap ( ) ;
198- runtime. block_on ( machine. mark_request_as_sent ( & uuid , & keys_query_response) ) . unwrap ( ) ;
199- runtime. block_on ( machine. mark_request_as_sent ( & uuid , & response) ) . unwrap ( ) ;
197+ runtime. block_on ( machine. mark_request_as_sent ( & txn_id , & keys_query_response) ) . unwrap ( ) ;
198+ runtime. block_on ( machine. mark_request_as_sent ( & txn_id , & response) ) . unwrap ( ) ;
200199
201200 group. bench_function ( BenchmarkId :: new ( "sled store" , & name) , |b| {
202201 b. to_async ( & runtime) . iter ( || async {
@@ -227,7 +226,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
227226
228227 let machine = OlmMachine :: new ( alice_id ( ) , alice_device_id ( ) ) ;
229228 let response = huge_keys_query_response ( ) ;
230- let uuid = Uuid :: new_v4 ( ) ;
229+ let txn_id = TransactionId :: new ( ) ;
231230 let users: Vec < Box < UserId > > = response. device_keys . keys ( ) . cloned ( ) . collect ( ) ;
232231
233232 let count = response. device_keys . values ( ) . fold ( 0 , |acc, d| acc + d. len ( ) ) ;
@@ -237,7 +236,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
237236
238237 let name = format ! ( "{} devices" , count) ;
239238
240- runtime. block_on ( machine. mark_request_as_sent ( & uuid , & response) ) . unwrap ( ) ;
239+ runtime. block_on ( machine. mark_request_as_sent ( & txn_id , & response) ) . unwrap ( ) ;
241240
242241 group. bench_function ( BenchmarkId :: new ( "memory store" , & name) , |b| {
243242 b. to_async ( & runtime) . iter_with_large_drop ( || async {
@@ -255,7 +254,7 @@ pub fn devices_missing_sessions_collecting(c: &mut Criterion) {
255254 ) )
256255 . unwrap ( ) ;
257256
258- runtime. block_on ( machine. mark_request_as_sent ( & uuid , & response) ) . unwrap ( ) ;
257+ runtime. block_on ( machine. mark_request_as_sent ( & txn_id , & response) ) . unwrap ( ) ;
259258
260259 group. bench_function ( BenchmarkId :: new ( "sled store" , & name) , |b| {
261260 b. to_async ( & runtime) . iter ( || async {
0 commit comments