adriangb opened a new pull request, #27807:
URL: https://github.com/apache/datafusion/pull/27807

   ## Which issue does this PR close?
   
   - None. This follows up on benchmark noise seen in 
[#27738](https://github.com/apache/datafusion/pull/27738#issuecomment-7224080539).
 It pairs with [#27805](https://github.com/apache/datafusion/pull/27805), which 
makes `compare.py` use a confidence interval.
   
   ## Rationale for this change
   
   Benchmark runs use a fixed `--iterations` count (5 in `bench.sh`). Under 
`--simulate-latency`, a sub-second query has a 20-35% stddev, so 5 samples 
cannot resolve even a 1.5x difference. A same-SHA run on the bot reported 
changes from 1.43x faster to 1.56x slower. Building the binaries already takes 
minutes, so spending a few more minutes on samples is cheap.
   
   ## What changes are included in this PR?
   
   - A new `Sampler` (`benchmarks/src/util/sampler.rs`) controls the iteration 
loop of one query.
   - New `CommonOpt` flags:
   
   | Flag | Default | Meaning |
   |---|---|---|
   | `--max-time` | not set | Seconds per query. When set, the loop runs 
adaptively. |
   | `--target-precision` | `0.02` | Stop once the 95% CI of the median is 
within this fraction of the median. |
   | `--max-iterations` | `1000` | Hard cap on iterations of each query. |
   
     With `--max-time`, `--iterations` is the minimum count. Without 
`--max-time`, behavior is unchanged.
   - The CI uses order statistics (distribution-free), so it does not assume 
normal timings and one outlier does not widen it.
   - There is no warmup. A warmup of a slow (for example 10 s) query costs as 
much as a measured run.
   - All runners use the shared `Sampler` in place of their own `for i in 
0..iterations` loops.
   
   ## What is the testing strategy for this PR?
   
   Unit tests in `sampler.rs` cover fixed counts, convergence, the minimum and 
maximum, the time budget, and exact CI widths.
   
   A local A/A run (same binary twice) of `sort_pushdown_inexact` with 
`--simulate-latency`, compared with the `compare.py` from 
[#27805](https://github.com/apache/datafusion/pull/27805):
   
   | | Samples / query | Median-ratio CI width | False changes |
   |---|---|---|---|
   | `--iterations 5` | 5 | ~1.0 (e.g. `[0.54, 1.52]`) | 0 / 5 |
   | `--iterations 5 --max-time 30` | ~70 | ~0.2 (e.g. `[0.96, 1.17]`) | 1 / 5 |
   
   All queries used the full 30 s budget, so at this noise level the budget, 
not the precision target, ends the loop. The one false positive (`1.15x 
slower`, CI `[1.07, 1.21]`) comes from drift between the two runs, which ran 
minutes apart. More samples cannot fix drift. Interleaving baseline and branch 
iterations would, and that belongs in the benchmark runner.
   
   ## Are there any user-facing changes?
   
   New optional `dfbench` flags. There are no library API changes.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to