Repository navigation
bench: add window aggregate filter benchmarks - #24589
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #24589 +/- ##
==========================================
+ Coverage 81.31% 81.53% +0.22%
==========================================
Files 1117 1123 +6
Lines 395911 406102 +10191
Branches 395911 406102 +10191
==========================================
+ Hits 321918 331104 +9186
- Misses 55177 55632 +455
- Partials 18816 19366 +550 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kumarUjjawal
left a comment
There was a problem hiding this comment.
Thank you @lyne7-sc for working on this.
Overall looks good, I had two questions which I mentioned. Please take a look.
| argument_kinds: &[ArgumentKind], | ||
| filter_percents: &[usize], | ||
| ) { | ||
| let mut group = c.benchmark_group(format!("window_aggregate_filter/{name}")); |
There was a problem hiding this comment.
bounded_window sets sample_size(10) on its group, should we set it here too, per group so the microsecond-scale whole-partition cases can keep a higher count?
There was a problem hiding this comment.
Thanks. I've reduced the sample size to 10.
There was a problem hiding this comment.
What I had in mind was setting this per group: 10 for the millisecond-scale bounded frames, and leaving whole-partition at the default.
There was a problem hiding this comment.
Updated. the bounded groups use a sample size of 10, while the whole-partition group uses default of 100.
| &[ArgumentKind::Column, ArgumentKind::Power], | ||
| &[30], | ||
| ); | ||
| benchmark_window_case( |
There was a problem hiding this comment.
A whole-partition frame is constant in partition and does a single update_batch, while the cumulative and sliding frames walk row by row and spend their time in range calculation rather than argument evaluation. Would it be worth giving this group all three argument kinds and all three selectivities and trimming the cumulative group back?
There was a problem hiding this comment.
Thanks for the suggestion. I think this is a reasonable balance. I've updated the benchmark coverage.
| argument_kinds: &[ArgumentKind], | ||
| filter_percents: &[usize], | ||
| ) { | ||
| let mut group = c.benchmark_group(format!("window_aggregate_filter/{name}")); |
There was a problem hiding this comment.
What I had in mind was setting this per group: 10 for the millisecond-scale bounded frames, and leaving whole-partition at the default.
| &[ArgumentKind::Column, ArgumentKind::Power], | ||
| &[30], |
There was a problem hiding this comment.
Could we restore divide here, and the 10 and 50 percent points with it?
| Arc::clone(&schema), | ||
| false, | ||
| false, | ||
| Some(col("include", &schema).unwrap()), |
There was a problem hiding this comment.
Every case here passes a filter, so the run has no baseline without FILTER at the same shape. That makes it hard to read the cost of the filter machinery apart from the base window cost. Would it work to add one case per group that passes None here?
There was a problem hiding this comment.
Makes sense. added no-filter case per group as a baseline
| let value = Float64Array::from_iter_values((start..end).map(|i| i as f64)); | ||
| let include = BooleanArray::from( | ||
| (start..end) | ||
| .map(|i| (i * filter_percent) % 100 < filter_percent) |
There was a problem hiding this comment.
At 10, 30 and 50 percent this expression never selects two rows in a row, so every selected run is one row long. The whole-partition case filters the full batch, and that shape is the most
expensive one for arrow::compute::filter. i % 100 < filter_percent gives the same selectivity with clustered runs. Would it be worth a second pattern with clustered runs, so the numbers show
the range rather than one end of it?
There was a problem hiding this comment.
Thanks again for the feedback. I took a closer look, and whether the selected rows are clustered or scattered does not seem to change the window-specific evaluation or accumulator work. The layout can still affect Arrow's filter kernel, but that feels like a separate dimension from what this benchmark is intended to isolate.
Should we keep this benchmark focused on the window FILTER path? I think we can adjust the existing include distribution so that it has a mix of isolated and consecutive selected rows. Would that address your concern?
There was a problem hiding this comment.
yes, keep the benchmark on the window FILTER path, and the mixed distribution addresses my concern.
There was a problem hiding this comment.
Updated. The filter mask now uses a fixed-seed shuffle to mix isolated and consecutive selected rows.
| c, | ||
| &runtime, | ||
| "bounded_sliding_10_rows", | ||
| &sliding_frame(), |
There was a problem hiding this comment.
The sliding frame filters twice per row, once for the update slice and once for the retract slice. That makes it the heaviest filter path of the three groups, but it skips divide. Would you add it here too?
There was a problem hiding this comment.
Added Divide and aligned the sliding filter selectivities with the other groups.
| let mut group = c.benchmark_group(format!("window_aggregate_filter/{name}")); | ||
| group.sample_size(sample_size); | ||
|
|
||
| let plan = make_window_plan(None, ArgumentKind::Column, window_frame.clone()); |
There was a problem hiding this comment.
The baseline is fixed to ArgumentKind::Column, so divide and power_udf have no unfiltered run at their own shape. The plan evaluates the argument expression once per batch before the filter runs, so power_udf carries a base cost that column/no_filter does not show. Would it work to loop the baseline over argument_kinds?
There was a problem hiding this comment.
Updated. Each argument kind now has its own unfiltered baseline.
kumarUjjawal
left a comment
There was a problem hiding this comment.
Thank you @lyne7-sc for the iterations.
Looks good 👍
|
Thank you @kumarUjjawal |
Which issue does this PR close?
Rationale for this change
Add benchmark coverage for evaluating the performance impact of the window aggregate filter argument evaluation changes in #24508.
What changes are included in this PR?
Adds a Criterion benchmark for window aggregates with
FILTERover pre-ordered input.It covers:
BoundedWindowAggExec.WindowAggExec.powerarguments.FILTERselectivities.This PR only adds benchmark coverage and does not change behavior.
Are these changes tested?
Yes.
Are there any user-facing changes?
No.