Repository navigation
Resize after the sources of a split Parquet file - #131140
Conversation
… threads `ReadFromFile::initializePipeline` added a `Resize` only when there were fewer sources than threads. A split single file has as many sources as threads, so the rows read from a bucket stayed on the chain of transforms of the source that read it. When the rows passing a filter sit in a few row groups (e.g. `CounterID = 62` in ClickBench), a few threads did all the aggregation while the others idled. Analysis and patch by @ snelheidai in ClickHouse#125738 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
`05394_parquet_single_file_parallel_read` checks that the pipeline of a split file has a `Resize` after its sources. The performance test gets a query whose filter keeps only the first two row groups (1.5M and 0.5M rows), so without the `Resize` at most two streams do the per-row work. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the split-file Resize comment to the property it relies on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own review (3 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20261112-215100 |
|
Workflow [PR], commit [dcc2f1c] Summary: ✅
AI ReviewSummaryReviewed #131140 at Final Verdict✅ Approve. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261112-214600 |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units7 translation units recompiled, 22 s compile time in total, 7 of them have a recent master baseline. |
One `Resize` over all streams lets any thread take a source's chunks, so short queries switch threads several times as often. ClickBench on one `hits.parquet`, x86 release, one binary switching the variants, paired rounds, ratio to master (95% CI): - Q1 at 32 threads, x200 in one process: one `Resize 32 -> 32` 1.64 [1.56, 1.73] (3284 context switches per query, master 693), groups of 8 1.12 [1.06, 1.18] (1269). Q7: 1.36 vs 1.04. - Q1/Q7 at 32 threads, fresh process: 1.12/1.11 vs 1.01/1.01. - Gains kept at 16/32/96 threads: Q39 0.60/0.56-0.60/0.62 (one Resize: 0.60/0.57-0.60/0.61), Q36 0.83/0.80-0.84/0.83, Q40 0.86/0.85/0.85. - Results identical for 8 checking queries at 16, 32 and 96 threads. The group size is capped by `min_outstreams_per_resize_after_split`, so 0 still disables the split; its default (24) alone would not split the `Resize` below 48 streams. Below 16 streams it stays one `Resize`. Suggested and measured first by snelheidai: ClickHouse#125738 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review: ClickHouse#131140 (comment) The default of `min_outstreams_per_resize_after_split` (24) splits a `Resize` only from 48 streams, so honouring it would leave one `Resize 16 → 16` or `Resize 32 → 32` after the sources of a split file, which costs short queries (ClickBench Q1 1.64x of master at 32 threads in one process, vs 1.12x with groups of 8). No behaviour change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
When a single local Parquet file is read by several streams, the rows read by each stream are now spread over several threads after the read, so a filter that keeps rows from only a few row groups no longer leaves most threads idle. ClickBench Q39 on a single
hits.parquetis 1.7x faster at 16 and 32 threads.Description
Related: #125738, #130740. Follow-up requested in #125738 (comment); analysis, patch and the grouping by @ snelheidai (#125738 (comment), #125738 (comment)).
A split file has as many sources as threads, and
ReadFromFile::initializePipelineadded aResizeonly when there were fewer sources than threads. So the rows of each bucket stayed on the chain of the source that read it. WithCounterID = 62only 3 of 226 row groups ofhits.parquetpass, and @ snelheidai measured one of 32 threads aggregating 467,687 of 722,688 rows for Q39. This PR adds aResizeafter the sources of a split file, in groups of 8 streams (capped bymin_outstreams_per_resize_after_split, so 0 disables the grouping). OneResizeover all streams made short queries switch threads far more often: Q1 at 32 threads had 3,284 context switches per query, against 693 on master and 1,269 with groups of 8.Measured on x86 (release, one binary switching the variants, 20-30 paired rounds, ratio to master): Q39 0.60 at 16 threads, 0.56-0.60 at 32, 0.62 at 96; Q36 0.80-0.84, Q37 0.77-0.83, Q40 0.85-0.86. Q1/Q7 at 32 threads: 1.00-1.08 in a fresh process, 1.12/1.04 for 200 runs in one process (one
Resize: 1.06-1.22, and 1.64/1.36). Q27 is 3-8% slower. Geomean over all 43 queries at 16 threads 0.975. Results are identical for 8 checking queries at 16-96 threads. #125275 replaces this condition with a stickyResize. aarch64 not measured.Tests:
05394_parquet_single_file_parallel_readchecks theResizeat 4 and 16 threads and with the grouping disabled,02725_parquet_preserve_order.referencegains it, andparquet_single_file_unequal_row_groups.xmlgets a query that only reads the first two row groups (0.30x of master locally).Workflow [PR]
Sync PR [sync-upstream/pr/131140]
Version info
26.11.1.2157-master(included in26.11and later)