Repository navigation
Adaptive codec selection: sampling - #124882
Conversation
Make it a baseline codec selection starts from s.t. we don't have to keep track of it in many places
A candidate without a chain that could report its size through tryGetCompressedSize was measured rather than compressed, and compressed at the end only if it won. Since chains were merged, the path was never taken there. It stayed live for a default that is not LZ4/ZSTD. This is a very rare scenario and significantly complicates API for sampling. Thus, removing. If it happens we need it later, we can reintroduce taking current infra into account.
CodecSelectorSampled prices one block per selection_period, reuses the winner in between, re-prices when it loses ground. Period 1 for now (so sampling all)
A chain whose first codec is the best in previous plan runs off the previously saved best buffer instead of compressing the base again
|
Workflow [PR], commit [9f4ce4c] Summary: ✅
AI ReviewSummaryThe PR samples adaptive codec selection once per configurable window, preserves compression state per stream, and reprices when the remembered winner degrades. Reviewed head Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes82 object files changed (+139.29 KiB total), 2 added.
720 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units782 translation units recompiled, 6667 s compile time in total, 779 of them have a recent master baseline. Translation units without a recent master baseline:
Symbol sizes
|
|
📊 Cloud Performance Report ✅ AI verdict: This PR adds sampled per-block codec selection behind the experimental clickbenchFlagged queries (1 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_official🟢 No significant changes Debug info
|
The trigger compared the best size so far, which is capped at the raw block. When the raw block was the runner-up of the priced block and the winner then grew past it, the two sides were equal and the stream kept writing raw blocks
rienath
left a comment
There was a problem hiding this comment.
Thanks @Michicosun, I addressed your feedback
Retain the per-stream state introduced for adaptive compression in `CompressedWriteBuffer`. Pass that state to the configured codec and `nullptr` to bypassed `NONE` frames, preserving state between larger frames. Keep the 128-byte network default and protocol revision 54497. Related: ClickHouse#120191 Related: ClickHouse#124882
…a home of their own Since ClickHouse#116042, clickhouse-local without --tmp or --path works in a designated directory in the home ($XDG_DATA_HOME/clickhouse-local or ~/.local/share/clickhouse-local; ~/Library/Application Support on macOS) and holds a lock on its `status` file for the whole run. That change gave $CLICKHOUSE_LOCAL a --tmp, but these three tests start clickhouse-local through the bare ${CLICKHOUSE_BINARY}, so all their local-mode runs in a CI job share the job's one default directory. When two of them overlap (two of these tests at the same time in a parallel job, or two copies of one test in the flaky check), the second fails with "Code: 76 ... Cannot lock file .../clickhouse-local/status". Seen on PR ClickHouse#124882 (03267, Stateless tests (amd_debug, parallel)) and PR ClickHouse#127774 (03536, Fast test). Prefix each local-mode line with a per-test HOME under CLICKHOUSE_TMP and an empty XDG_DATA_HOME (an absolute one wins over HOME on Linux), the same form ClickHouse#116042 uses in its own default-directory tests. The argv of every invocation is unchanged, so the dispatch rules of programs/main.cpp that these tests pin stay covered, including the no-argument rule that only 03267 exercises (`clickhouse < file`); --tmp would have turned that line into the dash-option rule. Client-mode lines and $CLICKHOUSE_LOCAL lines are untouched. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adaptive codec selection compressed every block with every candidate codec, keeping the smallest output.
Now one block per window of
adaptive_codec_selection_periodblocks (a new MT setting, default 8) is priced and the blocks in between reuse its winner. A codec may keep per-stream memory in aCompressionStateowned by itsCompressedWriteBuffer, andCompressionCodecAdaptivedelegates which candidates run on a block to anAdaptiveCodec::ICodecSelector(currently onlyCodecSelectorSampled). A few rules:Five new profile events describe an adaptive merge:
AdaptiveCodecBlocksPriced,AdaptiveCodecBlocksRepricedandAdaptiveCodecBlocksReusedsplit its blocks by treatment.AdaptiveCodecBytesDefaultandAdaptiveCodecBytesWrittensum the default codec's size and the written size on the sample blocks so their ratio is the saving against the default codec.Judging by hits, TPC-H SF10 lineitem table, NYC taxi and cell towers datasets, merges on integer data now have the same speed as without adaptive codec selection. Merges on floats are up to 35% slower, but wins are large (about 20% smaller files).
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Adaptive codec selection tries every codec on one block in
adaptive_codec_selection_period(default 8) and reuses the winner on the rest until it stops winning. Merges withenable_adaptive_codec_selectionnow cost about the same as without it.Workflow [PR]
Sync PR [sync-upstream/pr/124882]
Version info
26.11.1.1716-master(included in26.11and later)