@@ -35,9 +35,36 @@ const BATCH_SIZE: usize = 1 << 10;
3535const BASE_SEED : u64 = 0xA55AA55A ;
3636const AVG_SELECTOR_LENGTHS : & [ usize ] = & [ 4 , 8 , 12 , 16 , 20 , 24 , 28 , 32 , 36 , 40 ] ;
3737const SHAPE_FOCUS_SELECTED_RUN_LENGTHS : & [ usize ] = & [ 1 , 2 , 4 , 8 , 32 ] ;
38+ const DENSE_SHAPE_FOCUS_SELECTED_RUN_LENGTHS : & [ usize ] = & [ 4 , 8 , 32 ] ;
3839const COLUMN_WIDTHS : & [ usize ] = & [ 2 , 4 , 8 , 16 , 32 ] ;
3940const UTF8VIEW_LENS : & [ usize ] = & [ 4 , 8 , 16 , 32 , 64 , 128 , 256 ] ;
4041const BENCH_MODES : & [ BenchMode ] = & [ BenchMode :: ReadSelector , BenchMode :: ReadMask ] ;
42+ const SHAPE_FOCUS_SCENARIOS : & [ ShapeFocusScenario ] = & [
43+ ShapeFocusScenario {
44+ name : "sparse10" ,
45+ select_ratio : 0.1 ,
46+ start_with_select : false ,
47+ selected_run_lengths : SHAPE_FOCUS_SELECTED_RUN_LENGTHS ,
48+ } ,
49+ ShapeFocusScenario {
50+ name : "sparse20" ,
51+ select_ratio : 0.2 ,
52+ start_with_select : false ,
53+ selected_run_lengths : SHAPE_FOCUS_SELECTED_RUN_LENGTHS ,
54+ } ,
55+ ShapeFocusScenario {
56+ name : "moderate40" ,
57+ select_ratio : 0.4 ,
58+ start_with_select : false ,
59+ selected_run_lengths : SHAPE_FOCUS_SELECTED_RUN_LENGTHS ,
60+ } ,
61+ ShapeFocusScenario {
62+ name : "dense80" ,
63+ select_ratio : 0.8 ,
64+ start_with_select : true ,
65+ selected_run_lengths : DENSE_SHAPE_FOCUS_SELECTED_RUN_LENGTHS ,
66+ } ,
67+ ] ;
4168
4269struct DataProfile {
4370 name : & ' static str ,
@@ -209,29 +236,6 @@ fn criterion_benchmark(c: &mut Criterion) {
209236}
210237
211238fn bench_shape_focus ( c : & mut Criterion ) {
212- let scenarios = [
213- ShapeFocusScenario {
214- name : "sparse10" ,
215- select_ratio : 0.1 ,
216- start_with_select : false ,
217- } ,
218- ShapeFocusScenario {
219- name : "sparse20" ,
220- select_ratio : 0.2 ,
221- start_with_select : false ,
222- } ,
223- ShapeFocusScenario {
224- name : "moderate40" ,
225- select_ratio : 0.4 ,
226- start_with_select : false ,
227- } ,
228- ShapeFocusScenario {
229- name : "dense80" ,
230- select_ratio : 0.8 ,
231- start_with_select : true ,
232- } ,
233- ] ;
234-
235239 let profiles = [
236240 DataProfile {
237241 name : "int32" ,
@@ -245,25 +249,21 @@ fn bench_shape_focus(c: &mut Criterion) {
245249
246250 for profile in profiles {
247251 let parquet_data = build_parquet_data ( TOTAL_ROWS , profile. build_batch ) ;
248- for scenario in & scenarios {
249- for & selected_run_len in SHAPE_FOCUS_SELECTED_RUN_LENGTHS {
252+ for scenario in shape_focus_scenarios ( ) {
253+ for & selected_run_len in scenario . selected_run_lengths {
250254 let selectors =
251255 generate_shape_focus_selectors ( selected_run_len, TOTAL_ROWS , scenario) ;
252- if selectors. is_empty ( ) {
253- continue ;
254- }
255-
256- let stats = SelectorStats :: new ( & selectors) ;
257- let selection = RowSelection :: from ( selectors) ;
258- let suffix = format ! (
259- "shape-focus-{}-{}-run{:02}-avg{:.1}-sel{:02}" ,
256+ assert ! (
257+ !selectors. is_empty( ) ,
258+ "invalid shape focus case {} maxrun {}" ,
260259 scenario. name,
261- profile. name,
262- selected_run_len,
263- stats. average_selector_len,
264- ( stats. select_ratio * 100.0 ) . round( ) as u32
260+ selected_run_len
265261 ) ;
266262
263+ let suffix =
264+ shape_focus_suffix ( scenario, profile. name , selected_run_len, & selectors) ;
265+ let selection = RowSelection :: from ( selectors) ;
266+
267267 let bench_input = BenchInput {
268268 parquet_data : parquet_data. clone ( ) ,
269269 selection,
@@ -431,10 +431,11 @@ struct Scenario {
431431 distribution : RunDistribution ,
432432}
433433
434- struct ShapeFocusScenario {
435- name : & ' static str ,
434+ pub ( crate ) struct ShapeFocusScenario {
435+ pub ( crate ) name : & ' static str ,
436436 select_ratio : f64 ,
437437 start_with_select : bool ,
438+ pub ( crate ) selected_run_lengths : & ' static [ usize ] ,
438439}
439440
440441#[ derive( Clone ) ]
@@ -497,7 +498,11 @@ fn generate_selectors(
497498 selection. into ( )
498499}
499500
500- fn generate_shape_focus_selectors (
501+ pub ( crate ) fn shape_focus_scenarios ( ) -> & ' static [ ShapeFocusScenario ] {
502+ SHAPE_FOCUS_SCENARIOS
503+ }
504+
505+ pub ( crate ) fn generate_shape_focus_selectors (
501506 selected_run_len : usize ,
502507 total_rows : usize ,
503508 scenario : & ShapeFocusScenario ,
@@ -557,6 +562,23 @@ fn generate_shape_focus_selectors(
557562 selection. into ( )
558563}
559564
565+ pub ( crate ) fn shape_focus_suffix (
566+ scenario : & ShapeFocusScenario ,
567+ profile_name : & str ,
568+ selected_run_len : usize ,
569+ selectors : & [ RowSelector ] ,
570+ ) -> String {
571+ let stats = SelectorStats :: new ( selectors) ;
572+ format ! (
573+ "shape-focus-{}-{}-maxrun{:02}-avg{:.1}-sel{:02}" ,
574+ scenario. name,
575+ profile_name,
576+ selected_run_len,
577+ stats. average_selector_len,
578+ ( stats. select_ratio * 100.0 ) . round( ) as u32
579+ )
580+ }
581+
560582fn sample_length ( mean : f64 , distribution : & RunDistribution , rng : & mut StdRng ) -> usize {
561583 match distribution {
562584 RunDistribution :: Constant => mean. round ( ) . max ( 1.0 ) as usize ,
0 commit comments