Repository navigation
Compress each substream in a separate block in Compact parts - #118162
Conversation
Add MergeTree setting compress_per_substream_in_compact_parts (default true). Like compress_per_column_in_compact_parts but at substream granularity: each column substream in a granule starts a new compressed block, so reading a single subcolumn (an Array size, a Tuple element, a JSON path, ...) decompresses only that substream instead of the whole column's block. Applied only when per-substream marks are written (write_marks_for_substreams_in_compact_parts). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Workflow [PR], commit [8fdac81] Summary: ✅
AI ReviewSummaryThe PR adds Consumers traced: The focused stateless test passed at the reviewed head in Fast test. Earlier performance artifacts at Missing context / blind spots
Final VerdictStatus: ✅ Approve |
Cutting a new compressed block at every substream boundary of a Compact part granule fragments columns with many small substreams, which costs compression ratio and read requests. Cut only once the current block reached min_compress_block_size, matching the Wide writer and the Object shared data serialization; an explicit min_compress_block_size = 0 still cuts at every boundary. Also record the setting in the current version block of the settings changes history: it was recorded in 26.4, but 26.4 through 26.9 are released and never had the setting, so a server with compatibility pinned to one of them would get the new default. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Use `getEffectiveMinCompressBlockSize` for the substream block cut, so a column that overrides `min_compress_block_size` gets the same treatment as in Wide parts, and record the setting in the 26.10 block: master moved to 26.10.1, which makes the 26.9 block a released version that never had this setting. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`index_granularity_bytes = 0` disables adaptive granularity, and non-adaptive granularity is only supported in Wide parts, so `min_bytes_for_wide_part` was ignored and every measurement compared two Wide parts. Keep the row-based granularity by raising the byte limit instead. Also replace the part size assertion: on a column of many one-byte substreams the adaptive layout costs ~26% over packing a whole granule into one block, so assert that it stays near the packed size while cutting at every boundary costs more than twice as much. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units316 translation units recompiled, 2646 s compile time in total, 316 of them have a recent master baseline. |
…eam-in-compact-parts 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]>
…s is off `compress_per_column_in_compact_parts = 0` keeps all streams sharing a codec in one compressed block per granule, so cutting at substream boundaries broke that contract for tables that had pinned the setting. It also let the cut at a column boundary be decided by the next column's `min_compress_block_size`, because the stream is carried over when per-column blocks are disabled. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The part size checks compare compressed layouts, and the randomized codec, serialization versions and part storage type move the baseline more than the layout does: in CI the same measurement ranged from 933 to 3563 bytes while the extra layout cost stayed constant, so the ratio bound could not hold. Also cover the `compress_per_column_in_compact_parts = 0` opt-out, which must decompress the same bytes whether or not per-substream blocks are enabled. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: I marked all four flagged improvements as not sure (ClickBench Q33 -7.1% and Q34 -9.5%, TPC-H Q1 -18.5% and Q7 -23.5%). This PR only changes how Compact parts are written: a column's substream (Tuple element, Array sizes, JSON path) starts a new compressed block once the current block reaches min_compress_block_size. These benchmarks read plain-typed columns from large Wide parts, so the new code never runs for them. All four queries have noisy master history, and three PR runs shared one node, so the shifts are best read as environment variance; subcolumn-read gains should be judged by the PR's new dedicated perf test instead. clickbenchFlagged queries (2 of 43)
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. 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
|
…tream-in-compact-parts
The test has a JSON column (and forces Compact MergeTree parts to measure subcolumn reads), so the Iceberg performance configuration cannot run it, like the existing compact_part_subcolumns.xml entry. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ClickHouse/ClickHouse into compress-per-substream-in-compact-parts
Master advanced to 26.12 after the merge; the settings-history record must be under the current development version. Co-Authored-By: Claude Opus 4.8 <[email protected]>


In Compact parts a column's substreams are packed into the same compressed block; only whole columns are separated into blocks (via
compress_per_column_in_compact_parts). Reading a single subcolumn — anArraysize, aTupleelement, aJSONpath, etc. — therefore had to decompress the whole column's block, including unrelated substreams.This adds a MergeTree setting
compress_per_substream_in_compact_parts(enabled by default) that starts a new compressed block at a column substream boundary once the current block reachedmin_compress_block_size, so a selective subcolumn read decompresses only that substream while small substreams keep sharing a block. It applies when per-substream marks are written (write_marks_for_substreams_in_compact_parts) and per-column blocks are enabled (compress_per_column_in_compact_parts) — a table that pinned the latter to0keeps one block per granule for all streams sharing a codec. A per-columnmin_compress_block_sizeoverride is honoured, matching what the Wide part writer and theJSONshared data serialization already do. The setting respectscompatibility: with an older pinned compatibility version parts keep the previous packed layout.The change is write-time only and format-compatible — it just moves compression-block boundaries, so old and new servers read each other's parts.
Reading one subcolumn of a Compact part, decompressed bytes before → after:
Tupleelement 2.19 MiB → 0.13 MiB;Arraysize 2.00 MiB → 0.13 MiB. In the CI performance comparisonselect t.small from compress_per_substream_compactis 2.35x faster on amd64 and 2.21x faster on aarch64, and the existingjson_shared_data_compactread is 1.69x faster.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Compact parts can now start a new compressed block at column substream boundaries once the current block reaches
min_compress_block_size, controlled by the new settingcompress_per_substream_in_compact_parts(enabled by default). Reading a single subcolumn (anArraysize, aTupleelement, aJSONpath, etc.) decompresses only that substream instead of the whole column's block, while small substreams stay packed together.Workflow [PR]
Sync PR [sync-upstream/pr/118162]
Version info
26.12.1.433-master(included in26.12and later)