Skip to content

Add ZXC compression codec - #110620

Merged
alexey-milovidov merged 14 commits into
masterfrom
zxc-codec
Jul 19, 2026
Merged

alexey-milovidov merged 14 commits into
masterfrom
zxc-codec

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

Integrates zxc, an asymmetric LZ codec built for very fast decompression, as a new general-purpose compression codec CODEC(ZXC[(level)]) (levels 1..7, default 3).

ZXC trades slow compression for fast decompression at a compression ratio between LZ4 and ZSTD — a good fit for the compress-once/read-many pattern of analytical columns, and it decodes especially fast on modern ARM cores (e.g. AWS Graviton).

Implementation notes:

  • New contrib/zxc submodule plus a curated contrib/zxc-cmake build that mirrors zxc's per-ISA variant objects with runtime CPU dispatch (portable binary), without zxc's own -march=native/LTO/PGO defaults, since ClickHouse manages its own flags.
  • CompressionCodecZXC uses zxc's one-shot frame API with zxc's internal checksum disabled, because ClickHouse already checksums every compressed block.
  • Compression method byte 0x9e. Available like LZ4/ZSTD (not experimental).

Tested on AArch64 (AWS Graviton4): full build, a new stateless test 04545_zxc_codec (all levels roundtrip + detach/attach + error handling), and a real ClickBench hits load where CODEC(ZXC) roundtrips byte-exact through MergeTree and out-compresses LZ4 at the default level.

Raw-codec benchmark on ClickBench hits (single-threaded, Graviton4): results on pastila.

Note

Per ClickHouse's supply-chain policy, contrib/zxc points at a fork under the ClickHouse organization: https://github.com/ClickHouse/zxc (forked from https://github.com/hellobertrand/zxc). The pinned commit is unchanged.

Changelog category (leave one):

  • New Feature

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

Added a new codec ZXC — an asymmetric LZ codec with slow compression and very fast decompression, with a compression ratio between LZ4 and ZSTD.

Documentation entry for user-facing changes

  • Documentation is written (the ZXC codec is documented in the compression codecs reference).

Integrate zxc (https://github.com/hellobertrand/zxc), an asymmetric LZ codec
built for very fast decompression, as a new general-purpose codec
`CODEC(ZXC[(level)])` (levels 1..7, default 3, compression method byte 0x9e).

`ZXC` trades slow compression for fast decompression at a ratio between `LZ4`
and `ZSTD`, which suits the compress-once/read-many pattern of analytical
columns and decodes especially fast on modern ARM cores.

- `contrib/zxc` submodule plus a curated `contrib/zxc-cmake` build that mirrors
  zxc's per-ISA variant objects with runtime dispatch, without its own
  `-march=native`/LTO/PGO defaults (ClickHouse manages its own flags).
- `CompressionCodecZXC` uses zxc's one-shot frame API with zxc's internal
  checksum disabled, since ClickHouse already checksums every compressed block.
- Documentation and a stateless roundtrip test (all levels plus error handling).

Note: `contrib/zxc` points at the upstream repository as a placeholder; before
merging it must be replaced with a fork under github.com/ClickHouse.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6208458]

Summary: ✅


AI Review

Summary

This PR adds a new general-purpose compression codec, ZXC, together with build wiring, docs, and stateless coverage. The codec implementation itself is coherent, but it still makes a brand-new on-disk compression method writable in production with no experimental gate, which makes mixed-version rollouts unsafe. I would not merge it in that state.

Findings

❌ Blockers

  • [src/Compression/CompressionCodecZXC.h:38-39] The PR introduces a new on-disk method byte (0x9f) and immediately exposes it through CODEC(ZXC) as a normal generic codec. That violates the rollout contract for new storage formats: as soon as one upgraded replica writes a part with ZXC, an older server that still does not know 0x9f cannot read it, and there is no allow_experimental_codecs gate or compatibility knob to keep the cluster on old codecs during a mixed-version rollout. The existing gate path is already in src/Compression/CompressionFactoryAdditions.cpp:175-179, but ZXC never opts into it. Suggested fix: make CompressionCodecZXC::isExperimental() return true for now, and update the user docs/spec text that currently advertise ZXC as unconditionally available.
Final Verdict

Status: ❌ Block

@clickhouse-gh clickhouse-gh Bot added pr-feature Pull request with new product feature submodule changed At least one submodule changed in this PR. labels Jul 15, 2026
@mintlify

mintlify Bot commented Jul 15, 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 Jul 15, 2026, 9:28 PM

@alexey-milovidov

Copy link
Copy Markdown
Member Author

ClickBench benchmark — CODEC(ZXC) vs LZ4 / ZSTD

Full hits (100M rows, all 105 columns wrapped in the codec), on AArch64 (AWS Graviton4), single-threaded loads. Queries measured warm (min of 3) in one session; 35 of 43 ClickBench queries — the other 8 error on the parquet-derived EventDate UInt16 vs string-date comparison, unrelated to the codec.

Storage and load

Codec On-disk Ratio Load time
LZ4 14.29 GiB 4.16× 663 s
ZSTD(1) 9.32 GiB 6.39× 621 s
ZXC(3) 12.85 GiB 4.63× 1156 s

Query time (sum over 35 queries)

Codec Total Fastest on
LZ4 3.82 s 8 / 35
ZSTD(1) 3.83 s 9 / 35
ZXC(3) 3.65 s 25 / 35

ZXC(3) is the fastest on the query suite — the decode-bound scans benefit most (e.g. Q21–Q23, Q34–Q35 are ~20–30% faster than both LZ4 and ZSTD). It compresses better than LZ4 (but not ZSTD) at the cost of ~1.8× slower compression — the expected write-once/read-many trade-off. ZSTD(1) remains the best on ratio.

One rough edge to investigate as a follow-up: ZXC has a small fixed per-query overhead on trivial queries (e.g. COUNT(*) ~33 ms vs ~1 ms for LZ4/ZSTD), likely a per-block decode-context setup cost.

Raw single-column codec comparison (whole-column, not per-block): https://pastila.nl/?cafebabe/16ae94cb2aba1cd26c656f3ded96d882.md

@alexey-milovidov

Copy link
Copy Markdown
Member Author

ClickBench geomean of ratios — all 43 queries

Using ClickBench's own summary metric (per-query baseline = the fastest of the compared systems, ratio = (0.01 + t) / (0.01 + baseline), geometric mean over queries; lower is better). Full hits, 100M rows, warm (min of 3), AArch64 / Graviton4. EventDate is Date and EventTime read as toDateTime so all 43 queries run.

Codec Geomean relative time Query sum Fastest on
LZ4 1.310 5.70 s 6 / 43
ZSTD(1) 1.298 5.91 s 9 / 43
ZXC(3) 1.013 4.16 s 37 / 43

By the geomean metric ZXC(3) is 1.29× better than LZ4 and 1.28× better than ZSTD(1), and is the per-query fastest on 37 of 43 queries — its fast decode shows up consistently across the suite, not just on the heaviest scans. (Storage remains: ZSTD best at 6.39×, ZXC 4.63×, LZ4 4.16×; ZXC compresses ~1.8× slower.)

The trivial-query overhead I flagged earlier was a measurement artifact of running each query in a fresh process (first-touch table open); warmed in a single session, COUNT(*) is 0.001 s for all three codecs.

Fast test only checks out a curated subset of submodules
(ci/jobs/fast_test.py), and contrib/zxc was missing from that list.
add_contrib() in contrib/CMakeLists.txt silently skips a submodule
whose directory is empty, so ch_contrib::zxc was never defined and
CMake failed at the src/CMakeLists.txt target_link_libraries step
that links clickhouse_compression against it.
The compression frame's method-byte table in the spec enumerates
every assigned CompressionMethodByte value; add the 0x9e entry that
this PR assigns to the new ZXC codec, per docs/en/interfaces/specs/NativeFormat.md
being the single source of truth for the frame's byte encoding.
UInt32 doDecompressData(const char * source, UInt32 source_size, char * dest, UInt32 uncompressed_size) const override;

bool isCompression() const override { return true; }
bool isGenericCompression() const override { return true; }

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.

This makes a brand-new on-disk method byte (0x9e) immediately available in CODEC(...) without any allow_experimental_codecs gate. That is risky for mixed-version rollouts: as soon as one new replica writes a part with ZXC, older servers cannot read it, and there is no compatibility knob to keep the cluster on the old codecs while this format soaks in production. Recent new codecs such as ALP and SZ3 stay behind isExperimental() for exactly this reason. Please gate ZXC the same way for now (while still allowing decompression of already-written 0x9e parts).

Comment thread .gitmodules Resolved
alexey-milovidov and others added 3 commits July 16, 2026 15:23
zxc's x86-64 runtime SIMD dispatch calls `__builtin_cpu_init` /
`__builtin_cpu_supports`, which reference compiler-rt's `__cpu_model`.
That symbol is not linked into ClickHouse's macOS cross-build, so the
`Build (amd_darwin)` job failed with `undefined ___cpu_model`.

macOS builds are for local development only, so on Darwin x86-64 restrict
zxc to its portable scalar core: `ZXC_DISABLE_SIMD` forces the dispatcher
to the `_default` variant (dropping the `__builtin_cpu_*` calls), and we
skip building the now-unused per-ISA variant objects.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
# Conflicts:
#	docs/en/interfaces/specs/NativeFormat.md
#	src/Compression/CompressionInfo.h
#	src/Compression/registerCompressionCodecs.h
The `amd_msan` flaky check reported `use-of-uninitialized-value` when
running the new `04545_zxc_codec` test. zxc's fast decoder copies literals
with 32-byte SIMD "wild" loads that can read up to `ZXC_PAD_SIZE` (32)
bytes past the end of the compressed input. `CompressionCodecZXC` did not
override `getAdditionalSizeAtTheEndOfBuffer`, so it inherited the base
default of `0` and ClickHouse sized the compressed source buffer with no
initialized tail slack — the SIMD load then read the uninitialized tail.

Override `getAdditionalSizeAtTheEndOfBuffer` to reserve 64 bytes of slack
at the end of the (de)compression buffers, exactly as `CompressionCodecLZ4`
does for the identical over-read pattern. This is a ClickHouse-side fix; no
change to the zxc sources is required (the decoder never over-writes the
destination and the compressor leaves no uninitialized bytes in its output).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
alexey-milovidov and others added 3 commits July 16, 2026 21:56
The previous MSan fix (64 bytes of allocated slack after the compressed
source) did not clear the `use-of-uninitialized-value` reports in the
`amd_msan` jobs, because allocation does not make the bytes defined and,
more importantly, the source-tail over-read was never the trigger: those
bytes are only wild-copied and never influence a branch.

The real cause is toolchain-level: clang's MSan has no precise shadow
model for the x86 byte-shuffle intrinsics (`pshufb` and friends) — input
shadows are OR-ed positionally instead of being routed through the
shuffle, so poisoned lanes that the shuffle discards still poison the
logical result. zxc's SIMD kernels deliberately do speculative 16/32-byte
loads whose tail lanes fall into malloc'ed scratch buffers or
not-yet-written output and are then discarded by such shuffles (e.g.
`zxc_decode_copy_overlap_run`, `zxc_pivco_merge`), producing false
positives that either fire inside the decoder (level 7 token decoding) or
propagate into the decompressed output and fire downstream. AArch64 NEON
`tbl` has a precise shadow model, which is why the same code is clean
under an aarch64 MSan build.

Fix: under `SANITIZE=memory`, build only zxc's scalar core by defining
`ZXC_DISABLE_SIMD` on the core and on the `_default` kernel objects and
skipping the per-ISA variant objects. The scalar fallbacks branch only on
initialized bytes; a scalar MSan build of zxc runs all levels and
encodings with poisoned source slack with zero reports. Also correct the
`getAdditionalSizeAtTheEndOfBuffer` comment: the slack is still required
so the (real, bounded) source over-read stays inside allocated memory,
but it is not an MSan mechanism.

CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110620&sha=80b9c579e742e8044028edbe00afa80e376e6440&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20flaky%20check%29
PR: #110620

Co-Authored-By: Claude Fable 5 <[email protected]>
The `amd_debug` flaky check failed the test with "Test runs too long
(> 180s)" (252 s): 300k rows compressed through nine `ZXC` columns is too
much work for a debug build, since `ZXC` compression is slow by design at
the higher levels. Reduce to 50k rows — still multiple compressed blocks
per column across all levels, which keeps the roundtrip coverage.

CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110620&sha=80b9c579e742e8044028edbe00afa80e376e6440&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29
PR: #110620

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110620&sha=80b9c579e742e8044028edbe00afa80e376e6440&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29 (Received signal 8 (signal sent by pid ...) in Stress test (amd_tsan)) and provide a fix in a separate PR. If the fix is already in progress, link it here.

It is unrelated to this PR: the same failure hit 25 runs across 23 different PRs (including master, pull_request_number = 0) on 2026-07-16 alone, per the CIDB checks table (test_name LIKE 'Received signal 8%'), and there is no open issue or fix PR for it yet.

@groeneai

Copy link
Copy Markdown
Collaborator

Investigated. This SIGFPE is unrelated to this PR and a fix is already in progress: #110346 (approved by @PedroTadim), issue #110343.

Root cause (from the crash stack in the report):

src/Access/EnabledQuota.cpp:176  EnabledQuota::Interval::Interval(...)
src/Access/EnabledQuota.cpp:215  getEndOfInterval(...)
src/Access/EnabledQuota.cpp:237  getEndOfInterval(...)  // std::chrono duration division

A quota created with a non-positive (zero-length) interval leaves Interval::duration == 0. getEndOfInterval computes the interval boundary by dividing the elapsed time by duration, so a zero duration is an integer division by zero, which raises SIGFPE (signal 8). It reproduces under Stress because the fuzzed/random workload creates such a quota and then consumes it.

Fix in #110346:

  • QuotaCache skips legacy non-positive intervals (never constructs a zero-duration Interval).
  • CREATE QUOTA rejects a non-positive interval up front.
  • Regression test 04000_quota_zero_interval.sh.

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110620&sha=80b9c579e742e8044028edbe00afa80e376e6440&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29 (STID 4141-584d / 4141-5867).

alexey-milovidov and others added 2 commits July 17, 2026 02:30
Per ClickHouse's supply-chain policy, the contrib/zxc submodule must point at
a fork under github.com/ClickHouse rather than the upstream repository.

Created https://github.com/ClickHouse/zxc as a fork of
https://github.com/hellobertrand/zxc and repointed the submodule URL there.
The pinned commit b9890cfe3466b19d0eb5005874ce81728efb9565 is unchanged and is
reachable from the fork (it is the parent of the fork's main HEAD).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

The two CI failures on ee4b5b86 are both unrelated to this PR (which only adds the ZXC codec — no changes to interpreters, DDL, or locking):

  1. 02122_join_group_by_timeout (Stateless tests (amd_tsan, parallel)) — a long-known flaky test (issue Flaky test 02122_join_group_by_timeout #41820). Per the CIDB checks table it fails across many unrelated PRs (e.g. 110156, 109060, 108096, 96886, 109344, 110395 in the last two weeks), not on this PR's code.

  2. Logical error: RWLockImpl::getLock(): Cannot acquire exclusive lock while RWLock is already locked (STID: 2043-3c5c) (Stress test (arm_debug)). The stack is a re-entrant DDL lock: InterpreterCreateQuery::doCreateOrReplaceTable → InterpreterDropQuery::executeToTableImpl → IStorage::lockExclusively — a CREATE OR REPLACE whose internal DROP re-acquires an exclusive lock the outer statement already holds. This is a fresh manifestation of the known logical-error class from Logical error: Cannot acquire exclusive lock while RWLock is already locked #79413 / LOGICAL_ERROR: RWLockImpl::getLock(): Cannot acquire exclusive lock while RWLock is already locked #47023 and is structurally impossible to be caused by adding a compression codec.

@groeneai, could you investigate the RWLockImpl::getLock re-entrant deadlock (item 2) and provide a fix in a separate PR? If a fix or tracking issue is already in progress, please link it here. I've merged the latest master into this branch, so a fresh CI run will re-test both.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

The two CI failures on 23d8d0eb are both unrelated to this PR, which only adds the ZXC compression codec (no changes to access/quotas, DDL, or the Replicated database):

  1. UndefinedBehaviorSanitizer: undefined behavior (STID: 4141-5b13) (Stress test, amd_asan_ubsan) — the report is in EnabledQuota::Interval::getEndOfInterval (src/Access/EnabledQuota.cpp:236, contrib/llvm-project/libcxx/include/__chrono/duration.h:460), i.e. the zero-length-interval quota division. Already tracked as UndefinedBehaviorSanitizer: undefined behavior (STID: 4141-5b13) #110343 with an open fix in Disable zero-length interval quotas #110846.

  2. Error message in clickhouse-server.log (Upgrade check, amd_release) — the flagged lines are Code: 57 ... Mapping for table with UUID=... already exists ... UUID collision from DDLWorker(rdb_test_7_2/_3) initialization, i.e. a Replicated-database upgrade-check artifact, structurally unrelated to a compression codec.

@groeneai, could you take a look at failure 2 and open a tracking issue / fix in a separate PR if it recurs? I've merged fresh master (ZXC keeps method byte 0x9f, still unique; clickhouse_compression build verified locally) to re-trigger CI.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov, findings on both items. Both confirmed structurally unrelated to the ZXC codec.

Item 2 - RWLockImpl::getLock re-entrant deadlock (STID 2043-3c5c, Stress test arm_debug)

CIDB (30d): exactly 1 occurrence, this PR, 0 on master, 0 on any other PR. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110620&sha=ee4b5b869d5d3656964166ce79cdc044545bf273&name_0=PR&name_1=Stress%20test%20%28arm_debug%29

Root cause (from the stack + source): the internal cleanup DROP inside InterpreterCreateQuery::doCreateOrReplaceTable (InterpreterCreateQuery.cpp:2525, the post-EXCHANGE / catch-block drop) runs on a context built by make_drop_context = Context::createCopy(current_context), which inherits the OUTER statement's query_id. RWLockImpl::getLock (RWLock.cpp:145) keys its fast-path on query_id: when the same query_id already owns the drop_lock and a Write acquisition is requested, it throws Cannot acquire exclusive lock while RWLock is already locked (read->write upgrade / double-write is unsupported). So the inner DROP collides with a lock the outer CREATE OR REPLACE query already holds under the shared query_id.

This is the same LOGICAL_ERROR class as #79413 / #47023. #86751 (merged, Closes #79413) fixed the sibling PARALLEL WITH surface by giving each parallel branch a distinct query_id, but the CREATE OR REPLACE internal-DROP path still inherits the outer query_id via createCopy. No open issue/PR covers this surface.

Candidate fix direction (mirrors #86751): give the internal DROP context a distinct query_id (or clear it - an empty query_id bypasses the RWLock fast-path entirely, so the acquisition can never re-enter). I could not yet reproduce deterministically locally (serial, self-referential AS SELECT FROM t, and PARALLEL WITH variants of CREATE OR REPLACE all pass; the reproducer appears to need the stress thread-fuzzer scheduling). Per our no-speculative-fix policy I will not push the fix until I have a repro that fails without it and passes with it. Continuing to isolate a deterministic trigger; will open the fix PR once validated, else a tracking issue.

Failure 2 - Replicated-DB UUID collision (Upgrade check, amd_release)

This is a chronic upgrade-check artifact, not a regression. CIDB (30d) for Mapping for table with UUID=... already exists ... UUID collision on rdb_test_*: 18 hits across 16 unrelated PRs, 0 on master; this PR shows exactly 1. clickhouse-test --replicated-database names each test DB rdb_test_<rnd>_<shard> (ENGINE=Replicated); on the upgrade restart its DDLWorker runs initializeReplication -> recoverLostReplica, and a stale local table still owning a UUID makes DatabaseCatalog::addUUIDMapping return the non-fatal TABLE_ALREADY_EXISTS branch (code 57, not a crash - server stays up, self-heals via digest reset). It only trips the "Error message in clickhouse-server.log" scrub.

Already tracked, with an open harness allow-list PR: #107126 (masks only the benign rdb_test_ DDLWorker recovery line, preserving real UUID-collision errors). No action needed on this PR.

@groeneai

Copy link
Copy Markdown
Collaborator

Item 2 (RWLockImpl re-entrant deadlock, STID 2043-3c5c): tracking issue opened at #110893 with the full root cause and the candidate fix (give the internal DROP context a distinct/empty query_id in make_drop_context so it bypasses the RWLock query_id fast-path).

Still not reproducible deterministically locally: under the stress thread-fuzzer env I hammered concurrent same-table CREATE OR REPLACE, forced catch-path drops (max_table_size_to_drop=1), forced fill-throw (max_memory_usage), and self-referential CREATE OR REPLACE ... AS SELECT FROM t. All exercise the internal-DROP path but none hit the re-entrant window (holders destruct on unwind before the internal DROP). Per no-speculative-fix I will validate the fix against a failing repro before opening the PR; #110893 tracks it.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

The single CI failure on 71004993 is unrelated to this PR (which only adds the ZXC compression codec — no changes to JOINs, DISTINCT, or sorting):

Logical error: 'Equal values are not contiguous within the range assumed to be sorted' (Stress test, arm_debug) — https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110620&sha=7100499318bf13779891fecf10fe2b5fdd3e4ddf&name_0=PR&name_1=Stress%20test%20%28arm_debug%29

This is the known optimize_distinct_in_order assertion (chassert in findEqualRangeEndAssumeSorted.h, fires only in debug builds), tracked in #109216. Per the CIDB checks table, the identical stack (STID 2508-3796) appears on many unrelated PRs (#110105, #109433, #110196, #108909, #107567), and the same assertion fails on master itself three times on 2026-07-17 alone (MasterCI, amd_tsan/azure).

@groeneai, the fix is already in progress: #109225 (partial_merge JOIN trigger) and #110778 (ARRAY JOIN trigger) — no new fix needed; linking here for attribution.

The branch has been updated with the latest master (no conflicts; ZXC remains 0x9f, no new method-byte collision) and a fresh CI run is starting on the new head.

@clickhouse-gh

clickhouse-gh Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.10% 86.10% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 78.20% 78.20% +0.00%

Changed lines: Changed C/C++ lines covered: 45/52 (86.54%) · Uncovered code

Full report · Diff report

# symbol is not linked into ClickHouse's macOS cross-build, so linking fails
# with "undefined ___cpu_model". macOS builds are for local development only,
# so restrict zxc to its portable scalar core there.
set(ZXC_FORCE_SCALAR TRUE)

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.

Ok, as it is a very old platform.

@alexey-milovidov alexey-milovidov left a comment

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.

Reviewed.

@alexey-milovidov alexey-milovidov self-assigned this Jul 19, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jul 19, 2026
Merged via the queue into master with commit a8f5d15 Jul 19, 2026
178 checks passed
@alexey-milovidov
alexey-milovidov deleted the zxc-codec branch July 19, 2026 05:24
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 19, 2026
alexey-milovidov added a commit that referenced this pull request Jul 19, 2026
Resolve the method-byte collision: ZXC (PR #110620) merged to master
taking `0x9f`, the slot PCO used. Move `PCO` to the next free byte `0xa0`
(160) and keep `ZXC = 0x9f` (159). Updated `CompressionInfo.h` enum,
`01222_system_codecs.reference` (PCO byte 159->160, added the ZXC row,
count 17->18), the `NativeFormat.md` byte table + PCO per-column frame
section header, and the `PCO` block-layout comment in
`CompressionCodecPco.cpp`. Both codecs are registered in
`CompressionFactory.cpp`; both submodule entries kept in `.gitmodules`.
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @alexey-milovidov — a couple of suggestions to make this PR easier for reviewers and the changelog reader.

Description (currently misleading):

  • Why: The body's implementation notes state 'Compression method byte 0x9e', but the code and committed docs assign ZXC = 0x9f; 0x9e is already Quantized (see src/Compression/CompressionInfo.h:54-55 and docs/en/interfaces/specs/NativeFormat.md). The prose contradicts the actual (correct) implementation. This is a body typo only — all committed artifacts consistently use 0x9f, so there is no code bug.

  • Suggested addition:

    Correct the implementation note to: 'Compression method byte 0x9f.' (0x9e is already assigned to Quantized.)

Ignore this if the current title/body is intentional.

@rschu1ze

Copy link
Copy Markdown
Member

Per ClickHouse's supply-chain policy, contrib/zxc points at a fork under the ClickHouse organization: https://github.com/ClickHouse/zxc (forked from https://github.com/hellobertrand/zxc).

Just clarified with the internal security team, such a policy currently doesn't exist. The security comes from pinning a commit SHA, not from where the repository lives.

pull Bot pushed a commit to AKJUS/ClickHouse that referenced this pull request Jul 22, 2026
The `ZXC` codec was added in ClickHouse#110620 but, unlike the other recently added
codecs (`ALP`, `SZ3`), it was not placed in the experimental category. Mark
it experimental so that using it requires `SET allow_experimental_codecs = 1`,
matching the convention for new codecs that are not yet meant for production.

- `CompressionCodecZXC::isExperimental` now returns `true`, so the codec is
  rejected with `BAD_ARGUMENTS` unless `allow_experimental_codecs` is enabled,
  and `system.compression_codecs` reports it as experimental.
- Test `04545_zxc_codec` enables the setting and adds a negative case that the
  codec is rejected without it.
- Documentation gets an experimental badge and note.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The `ZXC` codec was added in ClickHouse#110620 but, unlike the other recently added
codecs (`ALP`, `SZ3`), it was not placed in the experimental category. Mark
it experimental so that using it requires `SET allow_experimental_codecs = 1`,
matching the convention for new codecs that are not yet meant for production.

- `CompressionCodecZXC::isExperimental` now returns `true`, so the codec is
  rejected with `BAD_ARGUMENTS` unless `allow_experimental_codecs` is enabled,
  and `system.compression_codecs` reports it as experimental.
- Test `04545_zxc_codec` enables the setting and adds a negative case that the
  codec is rejected without it.
- Documentation gets an experimental badge and note.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The previous MSan fix (64 bytes of allocated slack after the compressed
source) did not clear the `use-of-uninitialized-value` reports in the
`amd_msan` jobs, because allocation does not make the bytes defined and,
more importantly, the source-tail over-read was never the trigger: those
bytes are only wild-copied and never influence a branch.

The real cause is toolchain-level: clang's MSan has no precise shadow
model for the x86 byte-shuffle intrinsics (`pshufb` and friends) — input
shadows are OR-ed positionally instead of being routed through the
shuffle, so poisoned lanes that the shuffle discards still poison the
logical result. zxc's SIMD kernels deliberately do speculative 16/32-byte
loads whose tail lanes fall into malloc'ed scratch buffers or
not-yet-written output and are then discarded by such shuffles (e.g.
`zxc_decode_copy_overlap_run`, `zxc_pivco_merge`), producing false
positives that either fire inside the decoder (level 7 token decoding) or
propagate into the decompressed output and fire downstream. AArch64 NEON
`tbl` has a precise shadow model, which is why the same code is clean
under an aarch64 MSan build.

Fix: under `SANITIZE=memory`, build only zxc's scalar core by defining
`ZXC_DISABLE_SIMD` on the core and on the `_default` kernel objects and
skipping the per-ISA variant objects. The scalar fallbacks branch only on
initialized bytes; a scalar MSan build of zxc runs all levels and
encodings with poisoned source slack with zero reports. Also correct the
`getAdditionalSizeAtTheEndOfBuffer` comment: the slack is still required
so the (real, bounded) source over-read stays inside allocated memory,
but it is not an MSan mechanism.

CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110620&sha=80b9c579e742e8044028edbe00afa80e376e6440&name_0=PR&name_1=Stateless%20tests%20%28amd_msan%2C%20flaky%20check%29
PR: ClickHouse#110620

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The `amd_debug` flaky check failed the test with "Test runs too long
(> 180s)" (252 s): 300k rows compressed through nine `ZXC` columns is too
much work for a debug build, since `ZXC` compression is slow by design at
the higher levels. Reduce to 50k rows — still multiple compressed blocks
per column across all levels, which keeps the roundtrip coverage.

CI: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110620&sha=80b9c579e742e8044028edbe00afa80e376e6440&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29
PR: ClickHouse#110620

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026

This branch was successfully deployed

1 active deployment
staging - docs — 62084586 Deployed Jul 17, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants