Repository navigation
Allow flattenable Tuple leaves to participate in Vertical merge - #120225
JasonLi-cn wants to merge 17 commits into
Conversation
f3ee27c to
ed29344
Compare
Refuse leaf-by-leaf gathering when a flattened leaf spelling resolves to multiple serialization paths, including synthetic subcolumn collisions. Add stateless coverage for nested and synthetic ambiguities. Related: ClickHouse#120225 Co-authored-by: Cursor <[email protected]>
Encapsulate flattened-leaf size accounting, pending serialization state, and parent metadata commits in `MergeTreeVerticalMergeTupleSubcolumns`. Keep only the required algorithm-selection and per-column hooks in `MergeTask`. Related: ClickHouse#120225 Co-authored-by: Cursor <[email protected]>
Remove redundant merging and expired-column inputs whose invariants are already established by `MergeTask`. Derive the flatten decision directly from whether classification produced leaves. Related: ClickHouse#120225 Co-authored-by: Cursor <[email protected]>
Traverse the parent serialization tree once and look up gathered leaf data by name instead of rescanning the tree for every leaf. Pin `materialize_statistics_on_insert` on the INSERT queries whose merge-path assertions require existing part statistics. Related: ClickHouse#120225 Co-authored-by: Cursor <[email protected]>
Attempt gathering-column flattening only when both the experimental feature and the Vertical merge algorithm are enabled. Keep `tryFlattenGatheringColumns` focused on classification and transformation. Related: ClickHouse#120225 Co-authored-by: Cursor <[email protected]>
Drop cases already covered by dedicated tests, and fold implicit `basic` copy-stats into 05188 so 05219 only pins flatten when statistics must be rebuilt. Related: ClickHouse#120225 Co-authored-by: Cursor <[email protected]>
|
Workflow [PR], commit [bd34447] Summary: ✅
AI ReviewSummaryThis PR adds the experimental Final Verdict✅ No actionable findings in the current revision. |
Use gathered row counts for leaves without their own `SerializationInfo`, including all-non-sparse leaf groups after row-reducing merges. Related: ClickHouse#120225
Require ambiguous-leaf optimization to succeed and verify that update and rename scenarios actually use Vertical merge. Related: ClickHouse#120225
Expect the duplicate physical stream schema to be rejected while retaining the valid synthetic-subcolumn case for Vertical merge classification. Related: ClickHouse#120225
Classify parent dependencies from active index and statistics rebuild worklists, and ignore disabled or excluded merge-time materialization. Related: ClickHouse#120225
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/CMakeFiles/dbms.dir/Storages/MergeTree/MergeTreeVerticalMergeTupleSubcolumns.cpp.o |
new | 268.97 KiB | +268.97 KiB |
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
380 translation units recompiled, 3663 s compile time in total, 379 of them have a recent master baseline.
Translation units without a recent master baseline:
src/Storages/MergeTree/MergeTreeVerticalMergeTupleSubcolumns.cpp: 8.2 s
`Fast test (arm_darwin)` exposes part data streams as symbolic links, so `find -type f` omitted them. Include both regular files and symbolic links when checking generated stream, index, and statistics files. CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120225&sha=c508767ac1793df9d7cf5c13e1ab49366435b322&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29 PR: ClickHouse#120225
|
🕵 @groeneai, investigate the unrelated |
BSD `find` on macOS does not support `-maxdepth`, and the trailing `sort` masked that failure. Enumerate immediate children with a shell glob while preserving regular-file and symbolic-link filtering. CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120225&sha=c508767ac1793df9d7cf5c13e1ab49366435b322&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29 PR: ClickHouse#120225
|
The fix is in flight: #121048 ("CI: It covers your shape exactly. In your job log the readiness probe passed every time (zero Two things about clearing the red in the meantime, since #121048 is not merged:
Related: #120462 |
|
🕵 @groeneai, investigate the unrelated performance failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120225&sha=528c7f8d6a280795ecf4672dcd51e549b878bbc5&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%201%2F6%29 and provide a fix in a separate PR. |
|
I confirmed this is not your change. That shard's Fixes are already in flight, so I am not opening a separate PR:
|
|
🕵 @groeneai, investigate the unrelated The failing |
Flattenable `Tuple` inner fields can be gathered as stream-scheduling tasks of their parent storage column. The output schema stays one column. The feature is experimental and off by default; classify and I/O still need follow-up tuning. Squashes the 24 feature commits on `vertical-merge-tuple-subcolumns-minimal` onto the latest `master`. Related: ClickHouse#120225
cd4781a to
97b5846
Compare
The classifier received the full `text_indexes_to_merge` list, so a parent `Tuple` stayed pinned whenever any text index referenced it, even on ordinary merges where `MergeTextIndexStage::prepare` reuses the index's existing segment files (every source part already has the materialized index) and the merge never reads the parent Tuple data at all. That kept steady-state tables with e.g. `INDEX idx toString(t) TYPE text` on Horizontal forever, defeating the setting's memory-saving path. Compute an effective rebuild worklist instead, mirroring the skip-index and statistics handling: when `merge_may_reduce_rows` is false, a text index pins the parent only if some non-empty source part lacks the materialized index (`getDeserializedFormat`), matching `MergeTextIndexStage::prepare` and `addBuildTextIndexesStep`. A row-reducing merge always rebuilds text indexes from column data, so every text index still pins in that case. The full `text_indexes_to_merge` is left untouched for the merge itself. `05234_vertical_merge_tuple_subcolumns_effective_metadata` now expects Vertical for a fully materialized parent text index, and gains two cases that keep the parent pinned: a source part missing the index, and a row-reducing `ReplacingMergeTree` merge. Addresses review feedback on ClickHouse#120225
…e-subcolumns-minimal Resolve the conflict with the move of the settings changes history into the setting declarations (ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as trailing arguments of the `DECLARE` of each setting. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…n column list `tryGetColumn` answers from the shared `columns_description` cache, so part load order could count a leaf the source part's parent type cannot express and unlock Vertical merge.
…e leaf writers Synthesizing the parent substreams from an empty column dropped data-dependent streams, so a multi-bucket `Map` leaf was recorded as a single bucket in `columns_substreams.txt`.
…e-subcolumns-minimal
…e-subcolumns-minimal
`Map` reports `hasDynamicSubcolumns` because bucket streams depend on the data, so flatten was refused and `05259_vertical_merge_tuple_subcolumns_map_buckets` stayed on Horizontal merge. Refuse only a dynamic structure (`Dynamic`, `JSON`). The leaf writer still records `Map` bucket streams for the parent `columns_substreams`. CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120225&sha=971f4f117da8443a93c689d0e10b376cfe86b8c6&name_0=PR&name_1=Fast%20test Related: ClickHouse#120225
|
🕵 Fast test |
`MergeTask` only needs to call flatten before `chooseMergeAlgorithm` and finalize each gathering unit. Keep the text-index rebuild worklist, checksum split, and parent `columns_substreams` commit in `MergeTreeVerticalMergeTupleSubcolumns`. Related: ClickHouse#120225
…e-subcolumns-minimal
Style check `failpoint_tests_are_isolated` requires failpoint tests to stay out of the fast test as well as out of parallel runs. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120225&sha=035454121a6bb48d1309ac50943998dc051d3d10&name_0=PR&name_1=Style%20check ClickHouse#120225
|
🕵 Tagged |
…hecks `getPatchesForColumns` already maps `t2` back to the `t` a patch still stores after `RENAME COLUMN`. The readability proof must use the same mapping, or a rename plus `apply_patches_on_merge` silently keeps the merge on Horizontal. ClickHouse#120225
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120225&sha=fcfa631c1bc25eed8d42bd205bccb9e9acdeab8b&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20azure%2C%20sequential%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. The job hit its 9000 s timeout after 1170/1176 tests with no failing test. This matches the open split in #123849. |
|
The fix is in progress: #123849 splits |
`SYSTEM STOP MERGES` also stops mutations, so `ALTER TABLE ... RENAME COLUMN` never finished. Start merges first so the rename can rewrite ordinary parts while the patch still stores `t`. ClickHouse#120225
…e-subcolumns-minimal
…_constraint`. After merging current `master`, `parkOneRequest` from ClickHouse#113697 still instantiates the removed `FifoQueue`, which breaks `Build (arm_tidy, 2/4)`. Use `RequestQueue`, matching ClickHouse#124798. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120225&sha=520b56a12537be7c7c34950caa17a042c6d7ac8d&name_0=PR&name_1=Build%20(arm_tidy,%202/4) ClickHouse#120225
…he dynamic serialization fuzzer. The setting was renamed on `master`; keep the fuzzer compiling after the merge. Same adaptation as ClickHouse#124798. ClickHouse#120225
|
🕵 Merged current The earlier |
…e-subcolumns-minimal
Motivation
A flattenable
Tupleis one gathering column for Vertical merge even though its leaves are independent on-disk streams. Tables that store a few wideTuplecolumns therefore stay on Horizontal merge and keep every leaf live at once.Approach
New experimental
MergeTreesettingallow_experimental_vertical_merge_tuple_subcolumns(default off). When it is on, flattenable gathering parents are replaced with leafNameAndTypePairs beforechooseMergeAlgorithm, so leaf count (including nested flattenable tuples) feedsvertical_merge_algorithm_min_columns_to_activate. Skip indexes that only need one leaf are re-keyed onto that leaf. After each parent group is gathered, parentcolumns_substreamsare copied from the substreams the leaf writers opened, and parentSerializationInfois folded from those leaves, so the output part schema is unchanged:columns.txtstill lists the originalTuplecolumns.Flatten is refused when a source is Compact, a leaf has a dynamic structure (
DynamicorJSON), a skip index or non-implicit statistic needs the parent as a whole, this merge must rebuild parent statistics from the gather pipeline, a leaf name collides with a storage column, or a source/patch part cannot read the leaf as a subcolumn. AMapleaf is gathered; its bucket streams are copied from the leaf writer. Implicitbasicstatistics on a flattenableTupledo not pin flatten when existing part stats can be merged by parent name.Performance
Before/after measurement on a representative wide-
Tupleworkload:id UInt32, t Tuple(e0 String, ..., e10 String)(11Stringleaves, eachrepeat('x', 100)), two Wide parts merged byOPTIMIZE TABLE ... FINAL. A third shape flattens the same data into standalone columns (id, e0, ..., e10) as the ideal baseline. Metrics are the median of 3 runs fromsystem.part_log(peak_memory_usage,duration_ms), release build.Tuple, setting offTuple, setting onTuple, setting offTuple, setting onThe setting flattens the
Tupleinto 11 leaf gathering columns, so Vertical merge holds one leaf in memory at a time instead of the whole row. This cuts peak merge memory by ~90% and matches the ideal manually-flattened-columns baseline exactly (+0.0% memory), while also finishing ~26-29% faster. Data after merge is byte-identical to the flattened-columns table.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Added experimental
MergeTreetable settingallow_experimental_vertical_merge_tuple_subcolumns. When enabled, namedTuplefields can be merged one leaf at a time by Vertical merge, which can cut peak memory for wide tuples. The on-disk table schema is unchanged. Disabled by default.Workflow [PR]
Sync PR [sync-upstream/pr/120225]