@@ -43,12 +43,18 @@ fn generate_queue_path(queue_path: &str, queue_id: usize) -> String {
4343}
4444
4545async fn do_insert (
46+ cachestore_name : & str ,
4647 cachestore : & Arc < RocksCacheStore > ,
4748 total : usize ,
4849 size_kb : usize ,
4950 queue_path : & str ,
5051 insert_id_padding : usize ,
5152) {
53+ println ! (
54+ "[Preparing] {}: Inserting {} items into queue: {}" ,
55+ cachestore_name, total, queue_path
56+ ) ;
57+
5258 for i in 0 ..total {
5359 let fut = cachestore. queue_add ( QueueAddPayload {
5460 path : generate_queue_path ( queue_path, i + insert_id_padding) ,
@@ -60,12 +66,13 @@ async fn do_insert(
6066 let res = fut. await ;
6167 assert ! ( res. is_ok( ) ) ;
6268 }
69+
70+ println ! ( "[Preparing] {}: Done" , cachestore_name) ;
6371}
6472
6573fn do_insert_bench ( c : & mut Criterion , runtime : & Runtime , total : usize , size_kb : usize ) {
66- let cachestore = runtime. block_on ( async {
67- prepare_cachestore ( & format ! ( "cachestore_queue_add_{}" , size_kb) ) . unwrap ( )
68- } ) ;
74+ let cachestore_name = format ! ( "cachestore_queue_add_{}" , size_kb) ;
75+ let cachestore = runtime. block_on ( async { prepare_cachestore ( & cachestore_name) . unwrap ( ) } ) ;
6976
7077 c. bench_with_input (
7178 BenchmarkId :: new ( format ! ( "queue_add queues:1, size:{} kb" , size_kb) , total) ,
@@ -78,6 +85,7 @@ fn do_insert_bench(c: &mut Criterion, runtime: &Runtime, total: usize, size_kb:
7885 insert_id_padding += total;
7986
8087 do_insert (
88+ & cachestore_name,
8189 & cachestore,
8290 * total,
8391 * size_kb,
@@ -116,18 +124,24 @@ fn do_list_bench(
116124 total : usize ,
117125) {
118126 let cachestore = runtime. block_on ( async {
119- let cachestore = prepare_cachestore ( & format ! (
127+ let cachestore_name = format ! (
120128 "cachestore_queue_list_{}_{}" ,
121129 format!( "{:?}" , status_filter) . to_ascii_lowercase( ) ,
122130 size_kb
123- ) )
124- . unwrap ( ) ;
125-
126- do_insert ( & cachestore, per_queue, size_kb, "STANDALONE#queue" , 0 ) . await ;
127- do_insert ( & cachestore, per_queue, size_kb, "STANDALONE#queue" , 0 ) . await ;
128- do_insert ( & cachestore, per_queue, size_kb, "STANDALONE#queue" , 0 ) . await ;
129- do_insert ( & cachestore, per_queue, size_kb, "STANDALONE#queue" , 0 ) . await ;
130- do_insert ( & cachestore, per_queue, size_kb, "STANDALONE#queue" , 0 ) . await ;
131+ ) ;
132+ let cachestore = prepare_cachestore ( & cachestore_name) . unwrap ( ) ;
133+
134+ for idx in 0 ..5 {
135+ do_insert (
136+ & cachestore_name,
137+ & cachestore,
138+ per_queue,
139+ size_kb,
140+ & format ! ( "STANDALONE#queue{}" , idx + 1 ) ,
141+ 0 ,
142+ )
143+ . await ;
144+ }
131145
132146 cachestore
133147 } ) ;
@@ -148,11 +162,11 @@ fn do_list_bench(
148162 ) ;
149163}
150164
151- async fn do_get ( cachestore : & Arc < RocksCacheStore > , total : usize ) {
165+ async fn do_get ( cachestore : & Arc < RocksCacheStore > , total : usize , total_queues : usize ) {
152166 for i in 0 ..total {
153167 let fut = cachestore. queue_get ( QueueKey :: ByPath ( generate_queue_path (
154- "STANDALONE#queue" ,
155- i + ( ( i - 1 ) * 5 ) ,
168+ & format ! ( "STANDALONE#queue{}" , ( i % total_queues ) + 1 ) ,
169+ i,
156170 ) ) ) ;
157171
158172 let res = fut. await ;
@@ -166,15 +180,23 @@ fn do_get_bench(
166180 per_queue : usize ,
167181 size_kb : usize ,
168182 total : usize ,
183+ queues : usize ,
169184) {
170185 let cachestore = runtime. block_on ( async {
171- let cachestore = prepare_cachestore ( & format ! ( "cachestore_queue_get_{}" , size_kb) ) . unwrap ( ) ;
172-
173- do_insert ( & cachestore, per_queue, size_kb, "STANDALONE#queue" , 0 ) . await ;
174- do_insert ( & cachestore, per_queue, size_kb, "STANDALONE#queue" , 0 ) . await ;
175- do_insert ( & cachestore, per_queue, size_kb, "STANDALONE#queue" , 0 ) . await ;
176- do_insert ( & cachestore, per_queue, size_kb, "STANDALONE#queue" , 0 ) . await ;
177- do_insert ( & cachestore, per_queue, size_kb, "STANDALONE#queue" , 0 ) . await ;
186+ let cachestore_name = format ! ( "cachestore_queue_get_{}" , size_kb) ;
187+ let cachestore = prepare_cachestore ( & cachestore_name) . unwrap ( ) ;
188+
189+ for idx in 0 ..queues {
190+ do_insert (
191+ & cachestore_name,
192+ & cachestore,
193+ per_queue,
194+ size_kb,
195+ & format ! ( "STANDALONE#queue{}" , idx + 1 ) ,
196+ 0 ,
197+ )
198+ . await ;
199+ }
178200
179201 cachestore
180202 } ) ;
@@ -189,7 +211,7 @@ fn do_get_bench(
189211 ) ,
190212 & total,
191213 |b, total| {
192- b. to_async ( runtime) . iter ( || do_get ( & cachestore, * total) ) ;
214+ b. to_async ( runtime) . iter ( || do_get ( & cachestore, * total, 3 ) ) ;
193215 } ,
194216 ) ;
195217}
@@ -205,7 +227,7 @@ fn do_benches(c: &mut Criterion) {
205227 do_list_bench ( c, & runtime, Some ( QueueItemStatus :: Pending ) , 1_000 , 128 , 128 ) ;
206228 do_list_bench ( c, & runtime, Some ( QueueItemStatus :: Active ) , 1_000 , 128 , 128 ) ;
207229
208- do_get_bench ( c, & runtime, 10_000 , 128 , 128 ) ;
230+ do_get_bench ( c, & runtime, 2_500 , 128 , 128 , 4 na ) ;
209231}
210232
211233criterion_group ! ( benches, do_benches) ;
0 commit comments