@@ -11,7 +11,7 @@ use taskbroker::{
1111} ;
1212use tokio:: task:: JoinSet ;
1313
14- async fn get_pending_activations ( num_activations : u32 , num_workers : u32 ) {
14+ async fn get_pending_activations ( num_activations : u32 , num_workers : u32 , shards : u8 ) {
1515 let url = if cfg ! ( feature = "bench-with-mnt-disk" ) {
1616 let mut rng = rand:: thread_rng ( ) ;
1717 format ! (
@@ -26,7 +26,7 @@ async fn get_pending_activations(num_activations: u32, num_workers: u32) {
2626 InflightActivationStore :: new (
2727 & url,
2828 InflightActivationStoreConfig {
29- sharding_factor : 8 ,
29+ sharding_factor : shards ,
3030 vacuum_interval_ms : 60000 ,
3131 max_processing_attempts : 1 ,
3232 } ,
@@ -67,7 +67,7 @@ async fn get_pending_activations(num_activations: u32, num_workers: u32) {
6767 ) ;
6868}
6969
70- async fn set_status ( num_activations : u32 , num_workers : u32 ) {
70+ async fn set_status ( num_activations : u32 , num_workers : u32 , shards : u8 ) {
7171 assert ! ( num_activations % num_workers == 0 ) ;
7272
7373 let url = if cfg ! ( feature = "bench-with-mnt-disk" ) {
@@ -84,7 +84,7 @@ async fn set_status(num_activations: u32, num_workers: u32) {
8484 InflightActivationStore :: new (
8585 & url,
8686 InflightActivationStoreConfig {
87- sharding_factor : 8 ,
87+ sharding_factor : shards ,
8888 max_processing_attempts : 1 ,
8989 vacuum_interval_ms : 60000 ,
9090 } ,
@@ -135,7 +135,7 @@ fn store_bench(c: &mut Criterion) {
135135 let num_activations: u32 = 8192 ;
136136 let num_workers = 64 ;
137137
138- c. benchmark_group ( "bench_InflightActivationShard " )
138+ c. benchmark_group ( "bench_InflightActivationStore_2_shards " )
139139 . sample_size ( 256 )
140140 . throughput ( criterion:: Throughput :: Elements ( num_activations. into ( ) ) )
141141 . bench_function ( "get_pending_activation" , |b| {
@@ -144,15 +144,75 @@ fn store_bench(c: &mut Criterion) {
144144 . build ( )
145145 . unwrap ( ) ;
146146 b. to_async ( runtime)
147- . iter ( || get_pending_activations ( num_activations, num_workers) ) ;
147+ . iter ( || get_pending_activations ( num_activations, num_workers, 2 ) ) ;
148148 } )
149149 . bench_function ( "set_status" , |b| {
150150 let runtime = tokio:: runtime:: Builder :: new_multi_thread ( )
151151 . enable_all ( )
152152 . build ( )
153153 . unwrap ( ) ;
154154 b. to_async ( runtime)
155- . iter ( || set_status ( num_activations, num_workers) ) ;
155+ . iter ( || set_status ( num_activations, num_workers, 2 ) ) ;
156+ } ) ;
157+
158+ c. benchmark_group ( "bench_InflightActivationStore_4_shards" )
159+ . sample_size ( 256 )
160+ . throughput ( criterion:: Throughput :: Elements ( num_activations. into ( ) ) )
161+ . bench_function ( "get_pending_activation" , |b| {
162+ let runtime = tokio:: runtime:: Builder :: new_multi_thread ( )
163+ . enable_all ( )
164+ . build ( )
165+ . unwrap ( ) ;
166+ b. to_async ( runtime)
167+ . iter ( || get_pending_activations ( num_activations, num_workers, 4 ) ) ;
168+ } )
169+ . bench_function ( "set_status" , |b| {
170+ let runtime = tokio:: runtime:: Builder :: new_multi_thread ( )
171+ . enable_all ( )
172+ . build ( )
173+ . unwrap ( ) ;
174+ b. to_async ( runtime)
175+ . iter ( || set_status ( num_activations, num_workers, 4 ) ) ;
176+ } ) ;
177+
178+ c. benchmark_group ( "bench_InflightActivationStore_8_shards" )
179+ . sample_size ( 256 )
180+ . throughput ( criterion:: Throughput :: Elements ( num_activations. into ( ) ) )
181+ . bench_function ( "get_pending_activation" , |b| {
182+ let runtime = tokio:: runtime:: Builder :: new_multi_thread ( )
183+ . enable_all ( )
184+ . build ( )
185+ . unwrap ( ) ;
186+ b. to_async ( runtime)
187+ . iter ( || get_pending_activations ( num_activations, num_workers, 8 ) ) ;
188+ } )
189+ . bench_function ( "set_status" , |b| {
190+ let runtime = tokio:: runtime:: Builder :: new_multi_thread ( )
191+ . enable_all ( )
192+ . build ( )
193+ . unwrap ( ) ;
194+ b. to_async ( runtime)
195+ . iter ( || set_status ( num_activations, num_workers, 8 ) ) ;
196+ } ) ;
197+
198+ c. benchmark_group ( "bench_InflightActivationStore_16_shards" )
199+ . sample_size ( 256 )
200+ . throughput ( criterion:: Throughput :: Elements ( num_activations. into ( ) ) )
201+ . bench_function ( "get_pending_activation" , |b| {
202+ let runtime = tokio:: runtime:: Builder :: new_multi_thread ( )
203+ . enable_all ( )
204+ . build ( )
205+ . unwrap ( ) ;
206+ b. to_async ( runtime)
207+ . iter ( || get_pending_activations ( num_activations, num_workers, 16 ) ) ;
208+ } )
209+ . bench_function ( "set_status" , |b| {
210+ let runtime = tokio:: runtime:: Builder :: new_multi_thread ( )
211+ . enable_all ( )
212+ . build ( )
213+ . unwrap ( ) ;
214+ b. to_async ( runtime)
215+ . iter ( || set_status ( num_activations, num_workers, 16 ) ) ;
156216 } ) ;
157217}
158218
0 commit comments