Repository navigation
Parquet: check the bloom filter before reading the dictionary page - #120907
Conversation
When a column chunk carries both a bloom filter and a dictionary page, the reader read and decoded the dictionary page first and kept the bloom filter only as a runtime fallback. The dictionary page is by far the larger of the two - up to `input_format_parquet_dictionary_filter_push_down` bytes against one 32-byte bloom filter block per queried value - so for every row group the bloom filter alone could already rule out, the dictionary was read for nothing. Reading `hits.parquet` written by ClickHouse (which writes bloom filters by default) shows it: `SELECT UserID FROM file(...) WHERE UserID = <constant>` over a file of 16 row groups reads 4,608 bytes with `input_format_parquet_dictionary_filter_push_down = 0` and 8,017,209 bytes at the default - the 16 `UserID` dictionary pages - to arrive at the same answer. That is what made query no. 5 of the `clickbench_parquet_short` performance test slower in both #106952 and #110567, on `arm` and on `amd`: `DiskReadElapsedMicroseconds` +34..75%, `memory_usage` +17..22%, `OSCPUVirtualTimeMicroseconds` +9..10%. The bloom filter is now evaluated in its own stage, before the dictionary pages are fetched. It has no false negatives, so a row group it rules out is ruled out for good and no dictionary page is read. A row group it does not rule out goes on to the dictionary stage exactly as before, and the dictionary costs nothing extra there: either the row group is read anyway - which needs the dictionary page to decode it - or the dictionary rules it out exactly, which is the bloom filter's false positive. Pruning power is therefore unchanged, and files without bloom filters, which is what the feature was written for, take the same path as before. After the change the same query reads 4,608 bytes at the default setting, the same as with the filter turned off. `BloomFilterHeader` and `BloomFilterBlocks` share one stage's worth of the per-stage memory budget, so `Dictionary`, the index stages and `ColumnData` keep exactly the share they had when the bloom filter and the dictionary were one stage - `input_format_parquet_memory_high_watermark` means the same thing for the dictionary-pruning path as before. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Workflow [PR], commit [0db98b8] Summary: ✅
AI ReviewSummaryThis PR splits the Parquet pruning path so Final Verdict
LLVM Coverage ReportMeasured on commit 0db98b8.
Changed lines: Changed C/C++ lines covered: 103/108 (95.37%) · Uncovered code |
|
📊 Cloud Performance Report ✅ AI verdict: This PR changes only the Parquet v3 reader. It adds a separate bloom-filter stage that runs before dictionary-page pruning, and it no longer reads a dictionary page early when that page is only needed for filtering. Neither ClickBench (MergeTree) nor TPC-H reads Parquet files, so these benchmarks don't exercise the changed code. Q30 (-16.7%) and Q31 (-15.5%) were held at no change because both PR medians are inside master's current range, and that call holds up: CPU time barely moved (2353 to 2339 ms and 2812 to 2795 ms), and the diff can't explain the shift. No query shows a performance effect that can be traced to this PR. clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
…r-before-dictionary
|
🕵 The only red check, |
The queries ran in 3-17 ms, far below the 0.1 s minimum from `tests/performance/scripts/README.md`, so fixed per-query overhead dominated and the test produced spurious regressions and instability in unrelated PRs, e.g. `promql_duplicate_series_if #0` +15.6% in https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120907&sha=4772aa1520e801ada8bde3d7fe7f922dbd4d603e&name_0=PR&name_1=Performance%20Comparison%20%28amd_release%2C%20master_head%2C%204%2F6%29 (ClickHouse#120907). Drop the 1M-row query, which duplicated the 10M-row one and only measured overhead, and scale the remaining two to about 0.2 s each. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…r-before-dictionary
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units19 translation units recompiled, 156 s compile time in total, 19 of them have a recent master baseline. |
…r-before-dictionary
… already ruled out In `a = 1 OR b = 2`, `applyBloomFilters` can prove `a = 1` false while the row group survives because `b = 2` is unresolved. The `Dictionary` stage still read `a`'s dictionary page, which could only confirm the miss. `BloomFilterLookup` now records whether it was probed and whether any probe reported a possible match. For a column whose bloom filter reported a definite miss on every probe, `applyBloomFilters` clears `use_dictionary_filter`, so its dictionary page is not read and the second pass uses its bloom filter instead. Added a test with a mixed-column disjunction that checks `a`'s dictionary page is not read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…filtered column The bloom filter is now checked before the dictionary page, but the dictionary page was still registered with `likely_to_be_used = true`, so `Prefetcher` could coalesce it into a nearby bloom-filter read and read it even when the bloom filter rules the row group out. Register it as not likely to be used for columns with `use_dictionary_filter`; the `Dictionary` and `ColumnData` stages request it explicitly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120907&sha=89cfb3974d415e2d2d19d1f8c2b327e90ab16ffd&name_0=PR&name_1=Integration%20tests%20%28arm_binary%2C%20distributed%20plan%2C%20targeted%29 ( |
|
This is the lost-messages failure tracked in #116417 ( |
When a Parquet column chunk carries both a bloom filter and a dictionary page, the v3 reader read and decoded the dictionary page first and kept the bloom filter only as a runtime fallback. The dictionary page is by far the larger of the two — up to
input_format_parquet_dictionary_filter_push_downbytes against one 32-byte bloom filter block per queried value — so for every row group the bloom filter alone could already rule out, the dictionary was read for nothing.Reading a
hits.parquetwritten by ClickHouse (which writes bloom filters by default) shows it.SELECT UserID FROM file(...) WHERE UserID = <constant>over a file of 16 row groups:input_format_parquet_dictionary_filter_push_down01048576(default), before1048576(default), afterThe 8 MB is the 16
UserIDdictionary pages, read to reach a conclusion the bloom filters had already reached. That is what made query no. 5 of theclickbench_parquet_shortperformance test slower in both #106952 and #110567, onarmand onamd:DiskReadElapsedMicroseconds+34..75%,memory_usage+17..22%,OSCPUVirtualTimeMicroseconds+9..10%,client_time+1..2.5%.The bloom filter is now evaluated in its own stage, before the dictionary pages are fetched. A bloom filter has no false negatives, so a row group it rules out is ruled out for good and no dictionary page is read. A row group it does not rule out goes on to the dictionary stage exactly as before, and the dictionary costs nothing extra there: either the row group is read anyway — which needs the dictionary page to decode it — or the dictionary rules it out exactly, which is the bloom filter's false positive. Pruning power is therefore unchanged, and files without bloom filters, which is what dictionary filtering was written for, take the same path as before.
BloomFilterHeaderandBloomFilterBlocksshare one stage's worth of the per-stage memory budget, soDictionary, the index stages andColumnDatakeep exactly the share they had when the bloom filter and the dictionary page were one stage, andinput_format_parquet_memory_high_watermarkmeans the same thing for the dictionary-pruning path as before.Verified locally against a master build of the same tree, in the same rig:
parquetstateless subset (188 tests) is unchanged — the only non-environmental difference was04615_parquet_v3_dictionary_filter_hash_set_budget, which the budget split above restores;The new test
05229_parquet_v3_dictionary_filter_after_bloomfails on master (FAIL: 25872 > 576) and passes here.Related: #106952
Related: #110567
Related: #120834
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Parquet: check a column chunk's bloom filter before reading its dictionary page. A row group that the bloom filter rules out no longer reads the (much larger) dictionary page to reach the same conclusion, so
input_format_parquet_dictionary_filter_push_downcosts nothing on files that carry both, while pruning as much as before.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/120907]
Version info
26.10.1.1716-master(included in26.10and later)