Skip to content

Add a setting to enable each experimental codec individually - #113824

Merged
rienath merged 11 commits into
masterfrom
per-codec-enable-settings
Aug 20, 2026
Merged

rienath merged 11 commits into
masterfrom
per-codec-enable-settings

Conversation

@rienath

@rienath rienath commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Each experimental compression codec (ALP, SZ3, ZXC, Quantized) is now enabled by its own enable_<codec>_codec setting instead of the all-or-nothing allow_experimental_codecs, so opting in to one experimental codec no longer opts in to all of them. The umbrella setting still works.

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Add settings enable_alp_codec, enable_sz3_codec, enable_zxc_codec, and enable_quantized_codec to enable each experimental compression codec individually.


Workflow [PR]
Sync PR [sync-upstream/pr/113824]

Version info

  • Merged into: 26.8.1.1769 (included in 26.8 and later)

@mintlify

mintlify Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Aug 7, 2026, 1:53 PM

@clickhouse-gh

clickhouse-gh Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8838704]

Summary: ✅


AI Review

Summary

This PR replaces the blanket allow_experimental_codecs gate with per-codec enable_*_codec settings across column codecs, TTL ... RECOMPRESS, codec-valued MergeTree settings, docs, and tests. The dedicated-setting plumbing is mostly consistent and the earlier TTL / MergeTree SETTINGS full-ATTACH gaps are now covered, but one CREATE-like ATTACH TABLE ... (col CODEC(...)) path still bypasses the gate, and the updated English docs/spec still describe the dedicated settings as the exclusive opt-in even though the umbrella setting remains supported.

Findings

⚠️ Majors

  • [src/Interpreters/InterpreterCreateQuery.cpp:648] [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/113824#discussion_r3736467281] Full-definition ATTACH TABLE ... (x Float64 CODEC(ALP)) ENGINE = ... is still treated as trusted metadata. create.attach always produces LoadingStrictnessLevel::ATTACH, getColumnsDescription turns every ATTACH into CodecValidationSettings::trusted(), and CompressionCodecFactory only enforces the new per-codec gate when settings != nullptr. That means a fresh user DDL can still introduce ALP / SZ3 / Quantized column codecs without either enable_*_codec or allow_experimental_codecs, which violates the PR’s stated contract that these codecs now require an explicit opt-in.
    Suggested fix: plumb the same “fresh full-definition attach vs stored metadata” distinction that registerStorageMergeTree.cpp already uses (attach_short_syntax / isLoadingFromExistingMetadata) into getColumnsDescription, and add a focused stateless regression for ATTACH TABLE ... CODEC(...) without the dedicated setting.

💡 Nits

  • [docs/reference/interfaces/specs/NativeFormat.mdx:1427] [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/113824#discussion_r3738066077] The updated English spec/docs say the dedicated enable_*_codec setting is the only valid way to create tables with these codecs, but the implementation still accepts allow_experimental_codecs = 1 as an umbrella opt-in at src/Compression/CompressionFactoryAdditions.cpp:208. That leaves the spec and user docs documenting behavior the server does not actually enforce.
    Suggested fix: describe the dedicated setting as the narrow per-codec alternative while the umbrella setting remains supported, or remove the umbrella path in the same PR before documenting the dedicated setting as exclusive.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
  • Close the full-definition ATTACH TABLE ... CODEC(...) bypass so fresh user DDL is gated the same way CREATE TABLE is.
  • Add a regression test for that ATTACH path.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.90% 86.90% +0.00%
Functions 91.90% 92.00% +0.10%
Branches 79.20% 79.30% +0.10%

Changed lines: Changed C/C++ lines covered: 140/146 (95.89%) · Uncovered code

Full report · Diff report

bool skip_checks = LoadingStrictnessLevel::SECONDARY_CREATE <= mode;
bool sanity_check_compression_codecs = !skip_checks && !context_->getSettingsRef()[Setting::allow_suspicious_codecs];
bool allow_experimental_codecs = skip_checks || context_->getSettingsRef()[Setting::allow_experimental_codecs];
CodecValidationSettings codec_validation_settings = skip_checks ? CodecValidationSettings::trusted() : CodecValidationSettings(context_->getSettingsRef());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoadingStrictnessLevel::ATTACH is still treated as trusted here, so a full-definition ATTACH TABLE ... (x Float64 CODEC(ALP)) ENGINE = ... skips the new per-codec gate entirely. That contradicts the CREATE-like handling you already added for codec-valued MergeTree settings in registerStorageMergeTree.cpp: a user who never enabled enable_alp_codec / enable_zxc_codec can still opt into an experimental column codec just by using full-definition ATTACH.

Please distinguish "loading previously validated metadata" (FORCE_ATTACH / FORCE_RESTORE, plus short ATTACH) from fresh user input. Full-definition ATTACH needs the same CodecValidationSettings(context_->getSettingsRef()) path as CREATE, with a focused regression test for ATTACH TABLE ... CODEC(...) without the dedicated setting.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's same in master, I'd rather not change the semantics in this PR

Comment thread src/Storages/TTLDescription.cpp Resolved
| `0x9f` | `ZXC` |

`0x9d` (`SZ3`) is an **experimental**, error-bounded *lossy* codec for `Float32`, `Float64`, and `Array` of those types. A table can be created with `CODEC(SZ3)` only when `allow_experimental_codecs` is set, but the method byte is always accepted on decompression so that previously written data stays readable. `0x9f` (`ZXC`) is an **experimental** asymmetric LZ codec: slow to compress, but very fast to decompress at a ratio between `LZ4` and `ZSTD`. A table can be created with `CODEC(ZXC)` only when `allow_experimental_codecs` is set, but the method byte is always accepted on decompression so that previously written data stays readable. The bytes `0x99` (`DeflateQpl`) and `0x9b` (`ZSTD_QPL`) were assigned to codecs that have since been removed; they are reserved and not reused.
`0x9c` (`ALP`) is an **experimental** lossless codec for `Float32` and `Float64` (adaptive lossless floating-point compression). A table can be created with `CODEC(ALP)` only when the `enable_alp_codec` setting is set, but the method byte is always accepted on decompression so that previously written data stays readable. `0x9d` (`SZ3`) is an **experimental**, error-bounded *lossy* codec for `Float32`, `Float64`, and `Array` of those types. A table can be created with `CODEC(SZ3)` only when the `enable_sz3_codec` setting is set, but the method byte is always accepted on decompression so that previously written data stays readable. `0x9f` (`ZXC`) is an **experimental** asymmetric LZ codec: slow to compress, but very fast to decompress at a ratio between `LZ4` and `ZSTD`. A table can be created with `CODEC(ZXC)` only when the `enable_zxc_codec` setting is set, but the method byte is always accepted on decompression so that previously written data stays readable. The bytes `0x99` (`DeflateQpl`) and `0x9b` (`ZSTD_QPL`) were assigned to codecs that have since been removed; they are reserved and not reused.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/Compression/CompressionFactoryAdditions.cpp still accepts the umbrella opt-in here: it throws only when both the dedicated enable_*_codec setting and allow_experimental_codecs are false. As written, this spec/doc text turns a valid configuration (SET allow_experimental_codecs = 1) into "unsupported" behavior on paper.

Please phrase this as the dedicated setting being an additional per-codec opt-in, not the exclusive way to enable the codec, and mirror that wording in the matching codec docs/examples.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, the umbrella still works here. It's kept only as a transitional opt-in and will be made obsolete in a follow-up PR, so the spec and docs advertise only the per-codec settings

@Ergus Ergus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it is fine But I will request the first two changes to approve it.

  1. Consult allow_experimental_codecs before the missing-setting LOGICAL_ERROR
  2. The system.codecs/system.settings invariant test so the string convention can't silently rot

if (settings && result_codec->isExperimental())
{
const String enable_setting_name = fmt::format("enable_{}_codec", Poco::toLower(codec_family_name));
Field enable_setting_value;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this check order is not correct, if Setting::allow_experimental_codecs is not enabled then we shouldn't check dedicated settings.

The Setting::allow_experimental_codecs must be checked as an umbrella condition in the outer if.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that the two checks interact. The gate is deliberately an OR. A dedicated setting alone must be enough, since the point of this PR is enabling one experimental codec without opting into all of them

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow_experimental_codecs = 1 cannot rescue an experimental codec that has no enable_* setting; it hits LOGICAL_ERROR first.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, experimental codec without enable_*_codec setting would be a developer bug. It can't reach users, the test you proposed here guards against it

Comment thread src/Compression/CompressionFactory.h Resolved
codec_family_name,
enable_setting_name);
if (!enable_setting_value.safeGet<bool>() && !(*settings)[Setting::allow_experimental_codecs])
throw Exception(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new error message omits the umbrella condition, and dropped the production warning. IMO the "is experimental and not meant to be used in production" is important information.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had dropped the warning deliberately since it's true of any experimental setting, but now I think about it, I agree with you. Here it's worth spelling out as the cost of an error is high.

Leaving the umbrella out of the message is intentional as we want to point to narrowest possible setting rather than enabling all experimental codecs.

@rienath
rienath requested a review from Ergus August 17, 2026 15:44
@clickhouse-gh

clickhouse-gh Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 8838704db with master 8a4c746fd (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 702.07 MiB 699.05 MiB -3.02 MiB (-0.43%)

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 units

104 translation units recompiled, 718 s compile time in total, 104 of them have a recent master baseline.

Job report

@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

🟢 AI verdict: improvement — 4 query(s) improved out of 35 analysed

This PR adds per-codec enable__codec settings and refactors codec-validation plumbing (CREATE/ALTER/TTL and network-compression negotiation); it does not touch the SELECT execution path that these ClickBench and TPC-H queries exercise. All flagged queries improved and none regressed, which — together with the differing run counts between the two builds and co-located benchmark instances — points to baseline/environment differences rather than a real change. Seven ClickBench queries were downgraded to not-sure on that basis. Four large deltas (ClickBench Q23 ×2.3 faster and Q31 -26.2%, TPC-H Q7 ×8.4 faster and Q8 ×2.1 faster) remain locked in for being large and consistent, but given what the diff actually changes they should be verified against the baseline environment before being treated as PR wins.

clickbench

🟢 2 improved · ⚠️ 7 inconclusive

Flagged queries (9 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
🟢 23 improvement 164 72 ×2.3 faster <0.0001 ×2.3 faster is large enough to lock the verdict, but this PR changes only codec-validation and DDL plumbing, not execution, so verify the delta against the baseline environment.
🟢 31 improvement 408 301 -26.2% <0.0001 -26.2% is large and consistent, so the verdict is locked, but the diff only touches codec-validation and DDL plumbing, not query execution; confirm against the baseline environment.
⚠️ 13 not_sure 422 338 -19.8% <0.0001 This ClickBench SELECT does not touch codec validation or DDL, the only paths this PR changes, so the -19.8% delta reflects environment variance rather than a PR effect.
⚠️ 15 not_sure 192 163 -15.1% <0.0001 Q15 exercises the scan/aggregate execution path, which this codec-validation-only change leaves untouched; the -15.1% shift is not plausibly caused by this PR.
⚠️ 16 not_sure 734 595 -18.9% <0.0001 The PR only adds per-codec enable settings and refactors CREATE/ALTER/network-compression validation; Q16's -18.9% improvement is off that path and looks like baseline variance.
⚠️ 18 not_sure 1244 1045 -16.0% <0.0001 Q18's execution path is unaffected by codec-validation plumbing changes, so the -16.0% delta is environment variance, not a PR win.
⚠️ 30 not_sure 279 229 -17.9% <0.0001 Nothing in this PR touches what Q30 executes at query time; the -17.9% improvement is not attributable to the change.
⚠️ 33 not_sure 1250 1156 -7.5% <0.0001 Q33 does not exercise codec validation or DDL; the -7.5% delta is off-path from this PR and reads as run-to-run variance.
⚠️ 34 not_sure 1233 1156 -6.2% <0.0001 Same as Q33: the execution path is untouched by this codec-validation change, so the -6.2% improvement is not a PR effect.

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

🟢 2 improved

Flagged queries (2 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
🟢 7 improvement 560 67 ×8.4 faster <0.0001 A codec-validation-only diff cannot plausibly speed this query ×8.4 faster; the magnitude locks the verdict, but this almost certainly reflects a baseline or co-location difference.
🟢 8 improvement 166 78 ×2.1 faster <0.0001 ×2.1 faster is locked by the trust override, but the change touches only codec-validation and DDL paths, so confirm against the baseline before reading it as a PR win.

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
  • StressHouse run: f3ad176d-9f6c-438f-a89a-21ddde68e8ed
  • MIRAI run: 7f9150d9-6451-4c75-afea-42778fbc41ec
  • PR check IDs:
    • clickbench_1922894_1787057385
    • clickbench_1922900_1787057385
    • clickbench_1922906_1787057385
    • tpch_adapted_1_official_1922923_1787057386
    • tpch_adapted_1_official_1922935_1787057385
    • tpch_adapted_1_official_1922965_1787057386

if (settings && result_codec->isExperimental())
{
const String enable_setting_name = fmt::format("enable_{}_codec", Poco::toLower(codec_family_name));
Field enable_setting_value;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow_experimental_codecs = 1 cannot rescue an experimental codec that has no enable_* setting; it hits LOGICAL_ERROR first.

Comment thread src/Compression/CompressionFactory.h Resolved
@rienath
rienath requested a review from Ergus August 19, 2026 15:34
@rienath
rienath added this pull request to the merge queue Aug 20, 2026
Merged via the queue into master with commit 429f1d3 Aug 20, 2026
345 of 346 checks passed
@rienath
rienath deleted the per-codec-enable-settings branch August 20, 2026 14:51
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants