Skip to content

bench: expand dictionary group-by coverage - #25303

Open
yinli-systems wants to merge 2 commits into
apache:mainfrom
yinli-systems:feature/automatic-dictionary-encoding
Open

yinli-systems wants to merge 2 commits into
apache:mainfrom
yinli-systems:feature/automatic-dictionary-encoding

Conversation

@yinli-systems

@yinli-systems yinli-systems commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

The existing dictionary benchmark only measures pre-encoded dictionaries with cardinality expressed as a fraction of row count. That is not enough to derive a safe automatic encoding policy: native dictionaries, per-batch dictionaries, Utf8View, plain strings, and runtime encoding have materially different costs, and the crossover also depends on absolute NDV, value width, and batch layout.

The initial benchmark evidence is recorded in #24117 (comment). Runtime encoding lost in every measured case, while pre-encoded dictionaries changed from a substantial win at low NDV to a loss at higher NDV.

A follow-up using Utf8View, the relevant default Parquet scan representation, confirmed that NDV ratio and value width must be considered together. With 10M rows and 8,192-row batches, a per-batch dictionary was roughly 18% faster than Utf8View for 16-byte values and 37% faster for 64-byte values at NDV 1,000. At NDV 10,000 it was roughly 67% and 44% slower, respectively. These are local measurements rather than a proposed universal threshold.

What changes are included in this PR?

  • Compare pre-encoded dictionaries, Utf8View, plain strings, and runtime dictionary casts.
  • Configure absolute NDV, value width, and input batch size.
  • Model shared dictionary values and independent per-batch values.
  • Optionally normalize dictionary group keys back to Utf8 in the output so output-type preservation is included in the measurement.
  • Preserve the existing default benchmark behavior and case names.
  • Reject invalid benchmark configurations instead of silently changing the requested workload.
  • Verify that all encodings produce identical grouped counts.

This PR only establishes the benchmark surface needed to evaluate #24117; it does not add an optimizer rule or select a universal threshold.

What is the testing strategy for this PR?

  • cargo test -p datafusion-benchmarks --lib (148 passed)
  • cargo test -p datafusion-benchmarks --lib --no-default-features (148 passed)
  • cargo clippy -p datafusion-benchmarks --all-targets --no-deps -- -D warnings
  • cargo clippy -p datafusion-benchmarks --all-targets --all-features --no-deps -- -D warnings
  • cargo fmt --all -- --check
  • Runtime-dictionary and Utf8View CLI runs with fixed NDV, input batching, value width, and output normalization

A full transitive clippy run currently stops on the pre-existing unused_async_trait_impl lint in datafusion/datasource-parquet/src/opener/encryption.rs after the Rust 1.98 toolchain update; the benchmark crate itself is clean with both default and all features.

Are there any user-facing changes?

No DataFusion runtime or public API behavior changes. This only adds benchmark CLI controls.

@codecov-commenter

codecov-commenter commented Sep 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.18868% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.92%. Comparing base (6bbd3f4) to head (67df706).

Files with missing lines Patch % Lines
benchmarks/src/dict.rs 80.18% 56 Missing and 7 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main   #25303    +/-   ##
========================================
  Coverage   81.91%   81.92%            
========================================
  Files        1134     1134            
  Lines      425708   426014   +306     
  Branches   425708   426014   +306     
========================================
+ Hits       348726   349004   +278     
- Misses      56305    56321    +16     
- Partials    20677    20689    +12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants