Repository navigation
Extend adaptive codec selection to all types - #115639
Conversation
Since #113511 selection compresses each candidate at most once, so the isCandidateType saves nothing. Types with no specialized candidate now get NONE / default codec
|
Workflow [PR], commit [0c7408e] Summary: ✅
AI ReviewSummaryThis PR removes the candidate-type gate from adaptive codec selection, so default-coded data streams without a specialized candidate can now choose between the part default codec and PR Metadata
Findings💡 Nits
Final VerdictNo new blocking code issue found in the implementation. The remaining follow-up is to tighten the docs wording and fix the changelog entry's setting name. LLVM Coverage ReportMeasured on commit 0c7408e.
Changed lines: Changed C/C++ lines covered: 54/54 (100.00%) · Uncovered code |
| The specialized codecs above can shrink the right data dramatically, but choosing them takes expertise, and no single choice fits a column whose data changes over time. With the MergeTree setting [`allow_experimental_adaptive_codec_selection`](/reference/settings/merge-tree-settings) enabled, ClickHouse chooses for you. For columns that use the default codec (`CODEC(Default)` or no `CODEC` at all), each block is written with whichever codec would compress it smallest, chosen among the table's default codec, `NONE`, and specialized codecs suited to the column type. | ||
|
|
||
| <Note> | ||
| Specialized codecs are currently chosen for integers up to 64 bits, enums, dates and times, `Decimal32`/`Decimal64`, and `IPv4`. Other columns select between the default codec and `NONE`. |
There was a problem hiding this comment.
This still overstates the current coverage. Structural substreams like String.size, ArraySizes, and NullMap stay on the default path because isSpecialCompressionAllowed filters them out; the new 05023 reference already shows incompressible.size staying LZ4. Please phrase this in terms of the eligible/non-structural data substreams so it matches what users will see in mergeTreeCodecBlockCounts.
There was a problem hiding this comment.
The user that cares about these substreams is the one familiar enough with our repo to check the code. User that doesn't shouldn't care about this information.
Also, even if you are in first category, it's quite obvious that structural substreams shouldn't be compressed with the same codec as the data
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 units10 translation units recompiled, 26 s compile time in total, 10 of them have a recent master baseline. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
| static const CompressionCodecPtr none_codec = CompressionCodecFactory::instance().get("NONE", {}); | ||
| Codecs pool{none_codec, deployment_default}; |
There was a problem hiding this comment.
Is a single allocation being optimized here?
There was a problem hiding this comment.
Yes. Not much, but it's free
…-every-type Co-Authored-By: Claude Fable 5 <[email protected]>
The test guarded against an excessive loop in `skipPrefixBeforeHeader` by putting `timeout 10` around a query that skips `1000000000` lines of a two-line file. Both sides of that bound were too close to each other: - With the fix in place the query is instant, but the server can be stalled by something unrelated for seconds. In the reported failure the query took 8.8 s of wall time and only 0.17 s of CPU time, and all nine `Real` profiler samples show the `TCPHandler` thread blocked in `__sanitizer::SizeClassAllocator64::ReturnToAllocator` -> `Semaphore::Wait` while destroying the pipeline executor - contention inside the msan allocator, not in ClickHouse. That is 88% of the 10 s budget spent on nothing. - Without the fix the loop is a plain userspace spin: `readImpl` returns early at EOF once the file size is known, so there is not even a syscall per iteration. At the measured ~40 ns per iteration, `1000000000` lines is only tens of seconds - the same order of magnitude as the timeout itself. Skip `1000000000000000000` lines instead. A fixed server still stops at the end of the file in constant time, while an unfixed one would need centuries, so the timeout can be raised to 60 s and the verdict no longer depends on how fast the machine is. Closes: ClickHouse#116161 CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115639&sha=6d410fc0ff3ed27db04af7aabdf2dc8020438899&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20WasmEdge%2C%20parallel%2C%202%2F3%29 Related: ClickHouse#115639 Co-Authored-By: Claude Fable 5 <[email protected]>
Adaptive codec selection only worked with data types that had specified specialised candidates as we used to compress the default codec twice (once during selection, once during compression). This was fixed in #113511.
With this PR, adaptive codec would be applied to all types and select between the default codec and
NONEper block, when no specialised codec is specified. Thus, incompressible data would be stored raw and we'd save time on decompression and some space.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
With adaptive codec selection (
allow_experimental_adaptive_codec_selection), columns without a specialised candidate now select between the default codec andNONEper block, so incompressible data is no longer stored larger than raw.Workflow [PR]
Sync PR [sync-upstream/pr/115639]