Skip to content

Commit 1814c6c

Browse files
bench: expand dictionary group-by coverage (apache#25303)
## Which issue does this PR close? - Part of apache#24117. ## 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. I rebased this PR onto current `main` after apache#25185 merged and reran the relevant matrix, so the evidence includes the new cached dictionary-value-hash path. The crossover remains clear; the cache optimization does not make dictionary grouping universally profitable. Current-main results (`700ad9cf2`, release/LTO, Apple M5 Max, Rust 1.98.1; 10M rows, 8,192-row input batches, one target partition; median of iterations 2-6 after two warmups; output normalized back to `Utf8`): | value bytes | NDV | `Utf8View` | dict/shared | vs view | dict/per-batch | vs view | |---:|---:|---:|---:|---:|---:|---:| | 16 | 1,000 | 50.29 ms | 43.48 ms | -13.5% | 43.52 ms | -13.5% | | 16 | 10,000 | 54.24 ms | 91.61 ms | +68.9% | 94.03 ms | +73.3% | | 64 | 1,000 | 72.65 ms | 47.02 ms | -35.3% | 47.69 ms | -34.4% | | 64 | 10,000 | 79.69 ms | 115.85 ms | +45.4% | 115.04 ms | +44.4% | These are local measurements, not a proposed universal threshold. They show why apache#24117 needs a cost decision based on absolute NDV and value width rather than a blanket dictionary rewrite. Runtime encoding also lost in every earlier measured case, which is why the planned optimizer work targets native Parquet dictionary reads rather than inserting a runtime cast. ## 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 apache#24117; it does not add an optimizer rule or select a universal threshold. ## What is the testing strategy for this PR? On rebased head `5fb605471`: - `cargo test -p datafusion-benchmarks --lib` (153 passed) - `cargo test -p datafusion-benchmarks --lib --no-default-features` (153 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` - Current-main CLI benchmark matrix above; every case returned exactly the requested NDV ## Are there any user-facing changes? No DataFusion runtime or public API behavior changes. This only adds benchmark CLI controls. --------- Co-authored-by: kosiew <[email protected]>
1 parent c1fdd6e commit 1814c6c

1 file changed

Lines changed: 473 additions & 12 deletions

File tree

0 commit comments

Comments
 (0)