Add dfbench statistics command - #23975
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23975 +/- ##
==========================================
+ Coverage 80.75% 81.83% +1.08%
==========================================
Files 1096 1103 +7
Lines 373282 397640 +24358
Branches 373282 397640 +24358
==========================================
+ Hits 301440 325416 +23976
- Misses 53869 54627 +758
+ Partials 17973 17597 -376 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
d5d9de6 to
280897d
Compare
6f2a30b to
8b7b5ac
Compare
There was a problem hiding this comment.
@gabotechs
Thanks for adding this new statistics command.
I found a few issues that could make benchmark reports incomplete, stale, or nondeterministic.
I also left a testing suggestion to help protect the command's repeatability guarantees.
| .map_err(|error| DataFusionError::External(Box::new(error))) | ||
| } | ||
|
|
||
| fn query_files(path: &Path, query: Option<&str>) -> Result<Vec<PathBuf>> { |
There was a problem hiding this comment.
It would be helpful to add focused unit tests for SQL-aware multi-statement parsing, partial-run persistence and exit status, and duplicate table-name rejection. These cases define the repeatability contract for the new standalone CLI and would help prevent regressions.
There was a problem hiding this comment.
Added some tests here 6366a30.
I want to be careful in not introducing too many tests, as those also require maintenance, and this is just a benchmarking tool that is not in a production path.
Let me know if you think we should be covering some more.
|
I think @Omega359 is in the process of porting dfbench code -- maybe we should use the new format |
8b7b5ac to
13ccf04
Compare
|
@alamb I imagine you are referring to #23772. Unless I misinterpreted the intentions there, I see that's focusing on performance benchmarks, while this PR focuses on planning-time statistics vs execution-time metrics statistical divergence. I've tried several things already for shipping a tool that can qualify improvements to DataFusion stats system:
As there's really not any precedence about what I'm trying to do here, and it does not quite fit neither in the existing benchmark infrastructure or the current integration tests, I preferred to ship something as isolated as possible, so that:
Also @Omega359, if you have ideas about how to integrate this with your work, they are more than welcome, but my impression is that integrating this with the existing or future (#23772) is going to require some shoehorning that is likely to get in the way of other efforts rather than being helpful. |
Fair enough. Another thing we could do potentially is to add some sort of mode to the benchmark runner ("stats verification mode" perhaps?) that runs the query and then verifies that the actual metrics match the statistics 🤔 |
Most of the benchmarks in dfbench will be redirected to the SQL benchmark suite, and their corresponding Rust-based implementations will be removed in the somewhat near future. However, dfbench itself will remain because a few benchmarks are not well suited for SQL benchmarking. From a quick look at the code for this PR this looks like it'll be one of those. I don't think it's a concern at this point. |
What I found challenging is how to integrate this with existing benchmark runner without it getting in the way of the classical "performance benchmarks" path. For example, typical performance benchmarks have the option to specify the number of iterations, which does not make much sense with planing stats vs execution metrics benchmarks, and planing stats vs execution metrics benchmarks need to render the output in a very certain way for them to be useful (plans displayed with q-error per operator), which does not make sense for classical benchmarks. What I found is that integrating it in existing benchmarks would require some "if normal_path; do this; else if stats_vs_metrics_path; do this other different thing" conditional logic that could end up getting in the way of other people contributing to the classical benchmarks. Most of the code added in this PR is kind of very specific to this planning stats vs execution metrics benchmarks, but there are some common bits that could potentially be reused with other types of benchmarks: fn query_files(), fn register_parquet_files() and fn collect_parquet_files(), making a total of 80 LOC that could potentially be reused from the ~650 LOC these new benchmarks have. Even if 80 LOC out of 650 is something, it's still not a lot to be reused with existing benchmarks, the other 570 LOC are very specific to this new type of benchmark. |
Which issue does this PR close?
Rationale for this change
Provide a repeatable way to measure how closely planning cardinality statistics match runtime output for benchmark query suites.
The goal is not to have an automated benchmark suite, and not something to enforce in the CI. Instead, this is meant to be a development tool for developers to locally iterate over stats estimation improvements.
What changes are included in this PR?
dfbench statisticsaccepts any Parquet data directory and SQL file or directory, so it can be used with TPC-DS, TPC-H, or another compatible query suite. It:--compare.Example: verify a TPC-DS Q21 improvement
Compare against a baseline from
mainTPC-H works with its partitioned data layout as well:
Are these changes tested?
No unit tests were added: this is a reporting CLI over planner statistics and runtime metrics, exercised by the benchmark-suite smoke runs above.
If reviewers think this type of code needs to be covered by unit tests let me know.
Are there any user-facing changes?
No, this is just for extending the
dfbenchcommand with a newdfbench statisticssubcommand