Skip to content

Promote the ZXC codec to beta - #131397

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/zxc-codec-beta
Nov 15, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/zxc-codec-beta

Conversation

@groeneai

@groeneai groeneai commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #131071

Changelog category (leave one):

  • Improvement

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

The ZXC compression codec is promoted from experimental to beta. It is still enabled with the enable_zxc_codec setting, which servers with allow_feature_tier set to 1 or 2 now allow.

Description

This follows #131071 (zxc 1.0.0, merged), which moved ZXC to wire format v9, frozen as of 1.0. I checked the format guarantee and audited the zxc 1.0.0 code: no code defect, and two upstream issues about docs and fuzz coverage (analysis). The upstream author confirmed that later formats will be additive and every future decoder reads v9 (comment).

The change is the tier of enable_zxc_codec (EXPERIMENTAL -> BETA) plus a 26.11 history record; the 26.8 record is unchanged. Since #116337 a codec's maturity is the tier of its gate setting, so system.codecs.tier, system.settings.tier, the gate error ("is in beta and not yet recommended for production use") and allow_feature_tier follow from it. The rest of the diff is text naming the tier: the codec docs badge and note, the native protocol spec, the 01222_system_codecs reference, the three assertions on the gate message in test_experimental_codec_config_default, and two test comments. The default stays false.

Validation: the fix binary reports Beta in system.codecs and system.settings, and accepts SET enable_zxc_codec = 1 with allow_feature_tier 1 and 2 (master rejects it as EXPERIMENTAL; 3 rejects it as BETA). The 10 related stateless tests pass, the 3 edited ones 150/150 with random settings, and 01222_system_codecs with the new reference fails against master only on the ZXC row. test_experimental_codec_config_default passes 5/5; its 3 gated cases fail with the old assertions on the fix binary and with the new ones on master.


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

Version info

  • Merged into: 26.11.1.2342-master (included in 26.11 and later)

zxc 1.0.0 (ClickHouse#131071) freezes the wire format at v9; the upstream author
confirmed that later formats will be additive and that every future
decoder reads v9, and an audit of the 1.0.0 code found no defect.

Since ClickHouse#116337 a codec's maturity is the declared tier of its gate
setting, so moving `enable_zxc_codec` from EXPERIMENTAL to BETA is the
whole promotion: the gate error, `system.codecs.tier`,
`system.settings.tier` and `allow_feature_tier` all follow from it.
`allow_feature_tier` 1 and 2 now allow the setting; 3 still rejects it.

The 26.8 history record stays as released; a 26.11 record documents the
move, in the same shape as the other "moved to Beta" records. The rest of
the diff is text naming the tier: the codec docs badge and note, the
native protocol spec, the `01222_system_codecs` reference, the three
assertions on the gate message in `test_experimental_codec_config_default`
and two test comments. The default stays `false`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 2 findings; 1 full pass).

# Sev Finding Verdict Evidence / action
1 ⚠️ The spec's "previously written data stays readable" (format.mdx, ZXC paragraph) over-promises after the v8 to v9 format change DISAGREE It is the shared gate sentence of every gated codec (SZ3, PCO, GDeflate): the gate covers creation only, so data written with the setting on stays readable after it is turned off. This PR changes only the tier word. The v8 to v9 break is documented in #131071's Backward Incompatible changelog entry.
2 💡 Some test comments still say "experimental" / "non-experimental"; stray parenthesis in the 04616 header comment DISAGREE Those comments are generic or refer to the LZ4/ZSTD overrides and stay true; the parenthesis is pre-existing. No assertion is affected.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-48:20261113-175700

@mintlify

mintlify Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit c6353db.

Approve preview

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @rienath, could you review this? It moves enable_zxc_codec from EXPERIMENTAL to BETA (new 26.11 history record), so the tier-aware codec gating from #116337 reports ZXC as Beta; zxc 1.0.0 (#131071) froze the on-disk format.

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? N/A as a bug (tier promotion). Deterministic check: SELECT tier FROM system.codecs WHERE name = 'ZXC' is Experimental on master and Beta with this PR.
b Root cause explained? ZXC's maturity is the declared tier of enable_zxc_codec (since #116337); it was EXPERIMENTAL. zxc 1.0.0 froze the format and the audit found no code defect, so it moves to BETA.
c Fix matches root cause? Yes: the tier word at its single source; gate error, system.codecs.tier, system.settings.tier and allow_feature_tier derive from it.
d Test intent preserved / new tests added? Yes: the tests still assert the gate (BAD_ARGUMENTS without the setting, the gate message in the integration test); only the tier text they name changes.
e Both directions demonstrated? Yes: 01222_system_codecs with the new reference fails on master only on the ZXC row; the integration test's 3 gated cases fail with the old assertions on this binary and with the new ones on master, and pass 5/5 here.
f Fix is general across code paths? Yes: every gate path (column CODEC, MergeTree codec settings, ALTER ... MODIFY/RESET SETTING, ATTACH) reads the same tier; 10 related stateless tests pass.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (per-codec gate). allow_feature_tier 0-3 measured: 1 and 2 now allow the setting, 3 rejects it as BETA.
h Backward compatible? (maintainer-approved exception only) Yes: default stays false, no format change, the 26.8 history record is unchanged and a 26.11 record documents the move.
i Invariants and contracts preserved? Yes: setting tier equals codec tier (05024 empty), newest history value equals the default (03999 passes), the settings history check passes.

Session id: cron:clickhouse-impl-slot-5:20261113-173100

@clickhouse-gh

clickhouse-gh Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [c6353db]

Summary: ✅


AI Review

Summary

PR #131397, reviewed at c6353db456ccb1f3d2cfd40936020cfc08e5e771, promotes ZXC from experimental to beta through the tier of enable_zxc_codec and updates documentation and test expectations. The codec remains disabled by default and requires explicit opt-in. No actionable findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Nov 13, 2026

@rienath rienath 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.

I have not seen an example, where ZXC would be useful. It's an interesting experiment though. As such I lean towards deleting it rather than promoting. Happy to change my mind though

@rienath rienath 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.

See above

@rienath rienath self-assigned this Nov 13, 2026
@alexey-milovidov

alexey-milovidov commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

I have not seen an example, where ZXC would be useful.

I did, and a long time ago even with 0.* versions! It is a pareto-optimal algorithm between LZ4 and ZSTD, and sometimes it beats LZ4 by every measure - quite an achievement. I'd say it is one-in-ten-years finding!

@alexey-milovidov

Copy link
Copy Markdown
Member

When I first saw zxc, I was in shock - like I see a miracle. Before it, I've reviewed and tried many related algorithms: LZSSE, Lizard, Iguana, LZTurbo, but none of them were working up to our standards. The fact that zxc exists is unbelievable, but it does.

@alexey-milovidov

alexey-milovidov commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

I was dreaming about something like this since when we replaced QuickLZ with LZ4 and since when Yann Collet published ZHuff and then the first version of ZSTD - also 0.x, and with bugs and data corruption that we quickly found :)

@clickhouse-gh clickhouse-gh Bot added the can be tested Allows running workflows for external contributors label Nov 13, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

@groeneai

Copy link
Copy Markdown
Collaborator Author

Measured numbers for this. ClickBench hits with every column in the codec, geomean of query-time ratios (lower is better):

  • x86, today's master with zxc 1.0.0 (Xeon 6975P-C, warm, max_threads=16, min of 5 runs, two passes): ZXC 1.010 / 1.016, LZ4 1.026 / 1.031, ZSTD(1) 1.147 / 1.154. On disk: ZXC 13.16 GiB, LZ4 14.25 GiB, ZSTD(1) 9.53 GiB. A single-threaded copy into each table: ZXC 311 s, LZ4 235 s, ZSTD(1) 243 s.
  • AArch64 (Graviton4, zxc before 1.0), from Add ZXC compression codec #110620 (comment): ZXC 1.013, LZ4 1.310, ZSTD(1) 1.298.

So on x86 it reads at LZ4 speed with 8% less storage but writes slower; on AArch64 it reads about 1.3x faster than both.

@clickhouse-gh clickhouse-gh Bot added the comp-codecs Compression/encoding codecs (LZ4/ZSTD/etc.), archive formats (tar/zip/7z), codec selection and IO... label Nov 13, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing c6353db45 with master ef2e7afa2 (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

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Slowest function optimization changes (ThinLTO)

Median per-function time ratio to the master baseline: programs/clickhouse ×0.67, programs/clickhouse-keeper ×0.68 (each binary is linked separately, on a different machine and with different build flags); deltas below are relative to it.

Binary Function Master PR Δ vs median
programs/clickhouse DB::registerFunctionConversion(DB::FunctionFactory&) 5.7 s 11.0 s +7.3 s (+193%)
programs/clickhouse _ZN6detail10static_forITk7is_enumN2DB23AttributeUnderlyingTypeEZNS1_29callOnDictionaryAttributeType… 3.3 s 7.9 s +5.6 s (+256%)
Compile time of recompiled translation units

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

Job report

@rienath rienath 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.

I've ran a few benchmarks on datasets that first came to mind. We see that ZXC(3) is roughly LZ4 with a worse write path. 1–10% smaller files and similar hot-read speed, but inserts at 0.65–0.77x and merges at 0.47–0.70x of LZ4, and on two of three it’s also slower than the current default. A few percent of disk doesn’t justify that write cost, so I’d lean towards not promoting this codec to beta.

Dataset Codec Size, MB Insert, MB/CPU-s Merge, MB/CPU-s Hot scan, MB/CPU-s Hot queries, s
TPC-H SF10 Current default 2,578 198 310 1,212 2.59
ZXC(3) as default 4,007 (+55%) 162 (0.82x) 255 (0.82x) 2,143 (1.77x) 2.00 (0.77x)
LZ4 4,419 (+71%) 248 (1.25x) 547 (1.76x) 2,171 (1.79x) 1.92 (0.74x)
ZSTD(1) 2,537 (-2%) 200 (1.01x) 312 (1.01x) 1,086 (0.90x) 2.72 (1.05x)
TPC-DS SF10 Current default 3,908 187 280 1,052 25.92
ZXC(3) as default 5,945 (+52%) 186 (0.99x) 295 (1.05x) 1,956 (1.86x) 22.50 (0.87x)
LZ4 5,981 (+53%) 242 (1.29x) 538 (1.92x) 1,808 (1.72x) 22.95 (0.89x)
ZSTD(1) 3,873 (-1%) 197 (1.05x) 295 (1.05x) 935 (0.89x) 26.36 (1.02x)
hits, 100M rows Current default 9,409 240 231 1,460 4.67
ZXC(3) as default 14,112 (+50%) 194 (0.81x) 191 (0.83x) 1,914 (1.31x) 3.96 (0.85x)
LZ4 15,286 (+62%) 280 (1.17x) 271 (1.17x) 1,788 (1.22x) 4.09 (0.88x)
ZSTD(1) 10,213 (+9%) 243 (1.01x) 229 (0.99x) 1,231 (0.84x) 4.76 (1.02x)

@rienath
rienath dismissed their stale review November 15, 2026 11:39

However, I don't want to block you if you've made up your mind @alexey-milovidov

@groeneai

Copy link
Copy Markdown
Collaborator Author

Same picture here, and a faster level does not change it. Single-threaded clickhouse compressor over 5M hits rows (3.17 GB, all columns, sorted by the ClickBench key), today's master:

Codec CPU, s Size vs LZ4
LZ4 3.06 819 MB
ZSTD(1) 4.05 -30%
ZXC(1) 3.65 +25%
ZXC(2) 4.27 +13%
ZXC(3) 8.64 -6%
ZXC(4) 10.93 -11%
ZXC(5) 18.06 -17%

Levels 1-2 cost about as much CPU as LZ4 but are larger than LZ4. Level 3 is the first one smaller, at 2.8x the CPU of LZ4, and it is also slower to write than ZSTD(1). This matches my earlier copy (ZXC 311 s, LZ4 235 s) and upstream's own level table.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 15, 2026
Merged via the queue into ClickHouse:master with commit 9901351 Nov 15, 2026
607 of 609 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-codecs Compression/encoding codecs (LZ4/ZSTD/etc.), archive formats (tar/zip/7z), codec selection and IO... 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.

4 participants