Repository navigation
Parquet: fuse dictionary-index decoding with the dictionary gather - #115819
Conversation
Dictionary-encoded data pages were decoded in two passes: expand the RLE/bit-packed indexes into a temporary UInt32 column, then gather the dictionary values at those indexes into the output column (Dictionary::index). In hits.parquet, ~74% of all values sit in RLE runs of a repeated index (average run length 91), so most of that work was expanding runs into explicit indexes only to gather the very same dictionary value again and again - plus a full write + read pass over the temporary indexes column for everything else. Fuse the two passes (PageDecoder::decodeAndIndex, overridden by BitPackedRLEDecoder): an RLE run becomes a single dictionary lookup and a bulk fill of the value, and bit-packed runs are unpacked into a small stack buffer - with the bounds check hoisted out of the inner loop to once per batch - and gathered from there. Mode::Column dictionaries keep the old path (IColumn::index needs the indexes as a column anyway), as does anything else through the base-class fallback. On ClickBench query 3 (SELECT SUM(AdvEngineID), COUNT(*), AVG(ResolutionWidth) FROM hits) over hits.parquet on 2 cores this is 21% faster (0.46 s -> 0.36 s); the dictionary gather that took 27% of the query's CPU disappears from the profile. Results are bit-identical on checksums over seven dictionary-encoded hits columns (including strings) and on nullable dictionary-encoded columns. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Workflow [PR], commit [3e02764] Summary: ✅
AI ReviewSummaryThis PR fuses Parquet dictionary-index decoding with the dictionary gather for dictionary-encoded data pages, while keeping the existing fallback for dictionary modes that still require materialized index columns. I read the current diff and touched files in full, checked prior PR discussion and review threads, and did not find a correctness, safety, compatibility, test-coverage, or PR-metadata issue in the current head. Final Verdict✅ No findings. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 105/115 (91.30%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units17 translation units recompiled, 143 s compile time in total, 17 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.93 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
|
📊 Cloud Performance Report
This change is entirely in the Parquet dictionary-decoding reader (fused decode-and-gather). The two flagged queries are TPCH Q7 and Q17, which run against native storage and never touch the Parquet reader, so neither delta can plausibly be attributed to this PR. Both were already marked not_sure because their baselines are unstable and, for Q17, the underlying measurements are very noisy. No actionable regression here; the deltas are run-to-run variance on an unrelated code path. clickbench🟢 No significant changes tpch_adapted_1_officialFlagged queries (2 of 22)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
Dictionary-encoded Parquet data pages were decoded in two passes: expand the RLE/bit-packed indexes into a temporary
UInt32column, then gather the dictionary values at those indexes into the output column (Dictionary::index). Inhits.parquet, ~74% of all values sit in RLE runs of a repeated index (average run length 91 — the stats are quoted in a comment in the decoder), so most of that work was expanding runs into explicit indexes only to gather the very same dictionary value again and again — plus a full write + read pass over the temporary indexes column for everything else.This fuses the two passes (
PageDecoder::decodeAndIndex, overridden byBitPackedRLEDecoder):Mode::Columndictionaries keep the old path (IColumn::indexneeds the indexes as a column anyway), as does anything else through the base-class fallback in the reader.On ClickBench Q3 (
SELECT SUM(AdvEngineID), COUNT(*), AVG(ResolutionWidth) FROM hits) overhits.parqueton 2 cores this is 21% faster (0.46 s → 0.36 s, best of 3, interleaved A/B of otherwise identical builds); in the profile, the dictionary gather that took 27% of the query's CPU disappears, closing about half of the gap to DuckDB on this query (0.25 s). Results are bit-identical on checksums over seven dictionary-encodedhitscolumns (including strings) and on nullable dictionary-encoded columns; the Parquet dictionary-filter, prewhere, filter-pushdown and preserve-order stateless tests all pass. The existingclickbench_parquet_short.xmlperformance test covers these query shapes.Profiling context, for the record: after this change the remaining CPU of such queries is snappy decompression, the (now leaner) bit-unpacking, and the aggregation itself. Possible future refinements: SIMD bit-unpacking and batching the per-run
insertRawUninitializedbookkeeping.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Reading dictionary-encoded Parquet data got faster: the dictionary indexes are now decoded and resolved to values in one fused pass, turning runs of a repeated value into bulk fills instead of per-row gathers (~20% faster scans of dictionary-encoded numeric columns).
Workflow [PR]
Sync PR [sync-upstream/pr/115819]
Version info
26.9.1.343(included in26.9and later)