Skip to content

Update zstd to upstream dev with pending performance PRs - #127206

Open
Algunenano wants to merge 5 commits into
ClickHouse:masterfrom
Algunenano:zstd-dev-20261021
Open

Algunenano wants to merge 5 commits into
ClickHouse:masterfrom
Algunenano:zstd-dev-20261021

Conversation

@Algunenano

@Algunenano Algunenano commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Updates contrib/zstd to a rebase of the ClickHouse/zstd fork onto upstream dev (49cf5179, 2026-10-05; the old fork was 199 non-merge commits behind), plus pending upstream PRs and one new patch of ours. Fork branch: ClickHouse/dev-20261021 (8388bfae). The overlap-copy patches of the old fork are kept; its unwind-info patches are upstream already.

Changes on top of upstream dev:

Compressed output is byte-identical to the current fork at levels 1, 3, 6, 9 and 16, and the checksum of all columns of ClickBench hits is the same after decompression.

ClickBench hits (100M rows in one ZSTD(3) part, no columns cache, median of 20 hot runs, non-LTO local build) on AMD EPYC 9R14 (Zen 4), speedup vs current master:

Query 16 threads on 8 cores 64 threads on 32 cores
SELECT count() FROM hits WHERE NOT ignore(SearchPhrase) 1.22x 1.19x
same with URL 1.14x 1.12x
same with Title 1.17x 1.13x
same with ClientIP 1.21x 1.14x
same with RegionID 1.14x 1.13x
same with UserID 1.08x 1.03x
SELECT sum(cityHash64(*)) FROM hits 1.06x 1.06x
SELECT COUNT(DISTINCT SearchPhrase) FROM hits 1.12x 1.11x

zstd CLI on the same data, single core, ZSTD(3), ClickHouse block sizes, vs current master: compression 1.018x, decompression 1.175x (geomean over 7 numeric columns and the separate characters and sizes streams of 4 String columns). The short-offset copy alone, vs the same set without it: ClientIP 1.15x, UserID 1.12x, RegionID 1.085x, ResolutionWidth 1.065x, and the characters streams of long strings 1-2% slower; in ClickHouse it is 1.12x on the ClientIP scan, 1.08x on UserID, 1.06x on RegionID, 0.98x on URL and Title, 1.01x on sum(cityHash64(*)) and 1.02x on COUNT(DISTINCT SearchPhrase) (16 threads). On Graviton4 it is +5.6% CLI decompression geomean, ClientIP +45%, UserID +14%, and 1.20x on the ClientIP scan in ClickHouse.

Earlier measurements of the same set without the short-offset copy, vs current master:

Evaluated and not included:

Related: #124405

Changelog category (leave one):

  • Performance Improvement

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

Update zstd to the latest upstream development version with pending performance improvements. Decompression of ZSTD(3) data is up to 20% faster on x86.


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

Algunenano and others added 2 commits October 21, 2026 14:59
Rebase of the `ClickHouse/zstd` fork onto upstream `dev` (`49cf5179`), keeping the vectorized overlap-copy patches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Algunenano Algunenano self-assigned this Oct 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [50e6d81]

Summary: ❌

job_name test_name status info comment
La Casa Del Dolor (amd_tsan) FAIL
ThreadSanitizer: data race (STID: 3437-4705) FAIL cidb

AI Review

Summary

Updates zstd to upstream development code with compression and decompression optimizations, including a custom SIMD copy for short match offsets. No actionable findings remain at 50e6d816baa75c49e4e0fc922d97d0f999332ac3; the earlier big-endian and legacy-streaming issues are addressed.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-performance Pull request with some performance improvements submodule changed At least one submodule changed in this PR. labels Oct 21, 2026
Comment thread contrib/zstd Resolved
Comment thread contrib/zstd Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. label Oct 21, 2026
Drop the row matchfinder change, which has a big-endian bug and no gain at `ZSTD(3)`, and add the fix for the legacy v0.5 streaming regression.

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

clickhouse-gh Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 50e6d816b with master 77c29e32d (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.

Object file sizes

18 object files changed (+86.26 KiB total), 0 added.

Object file Master PR Δ
contrib/zstd-cmake/CMakeFiles/_zstd.dir/__/zstd/lib/compress/zstd_double_fast.c.o 56.91 KiB 117.44 KiB +60.54 KiB (+106.38%)
contrib/zstd-cmake/CMakeFiles/_zstd.dir/__/zstd/lib/decompress/zstd_decompress_block.c.o 47.63 KiB 69.63 KiB +22.00 KiB (+46.19%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

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

Median compile-time ratio to the baselines is ×1.30 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +9.8 s (+60%) in total before that adjustment.

Job report

`contrib/zstd` moves to `8388bfaec` on `ClickHouse/dev-20261021` of
https://github.com/ClickHouse/zstd: the same set as before (`984dab56b`)
plus a branchless copy of matches with offsets below 16 (NEON `tbl`,
SSSE3 `pshufb`, AVX2 `vpshufb`). It replaces the `offset < 8` branch of
`ZSTD_overlapCopy8`, which mispredicts often on numeric columns.

Graviton4, ClickBench `hits` columns at level 3 with ClickHouse block
sizes: decompression +5.6% geomean over 13 columns (`ClientIP` +45%,
`UserID` +14%), no column slower. In ClickHouse with 16 threads, the
`ClientIP` scan is 1.20x and the `UserID` scan 1.07x faster.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Algunenano

Copy link
Copy Markdown
Member Author

Failures are unrelated and fixed in #127186

@Algunenano
Algunenano marked this pull request as ready for review November 3, 2026 18:52
@Algunenano Algunenano removed their assignment Nov 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. performance pr-performance Pull request with some performance improvements submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant