Skip to content

Use data without long LZ4 matches in the adaptive_codec_merge performance test - #124741

Merged
rienath merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/adaptive-codec-merge-perf-data
Oct 9, 2026
Merged

rienath merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/adaptive-codec-merge-perf-data

Conversation

@groeneai

@groeneai groeneai commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #123798

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Description

Performance Comparison (amd_release, master_head, 5/6) failed on #123798: adaptive_codec_merge #0 0.607 -> 0.745 s (+23%). Since 2026-10-06 some amd builds, including official master builds 47a31cd, 1200a74 and 12e23c6, run this query ~20% slower on whichever side of the comparison they are; no other query moves consistently.

The table's data has an exact 8 KiB period, so every 64 KiB block compresses to 8 KiB of literals plus one ~56 KiB match and the merge is dominated by LZ4's match-length loop (LZ4_count). Its machine code is identical in all builds, but in some code layouts the CPU front end runs it at about half speed (same instruction count, 2x the cycles in LZ4_compress_fast_extState). A plain LZ4 merge of the same data (enable_adaptive_codec_selection = 0) shows the same slow draw.

The new data repeats each of 1024 random hashes 8 times. LZ4 still wins every block, and adaptive selection is now ~71% of the merge instead of ~37%. On 9 official master builds (3 slow on the old data), 3 rounds of 5 merges each: 0.56-0.58 s, every build within 3% of the median. Queries 1 and 2 are unchanged.


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

Version info

  • Merged into: 26.10.1.1927-master (included in 26.10 and later)

…ance test

`adaptive_codec_merge` was filled with `cityHash64(number % 1024)`, an
exact 8 KiB period. Every 64 KiB compressed block is then 8 KiB of
literals plus one ~56 KiB match, so query 0 (`OPTIMIZE TABLE ... FINAL`)
spends its LZ4 time in the match-length loop `LZ4_count`, which adaptive
selection runs twice per block (raw block and T64 chain output).

That loop's machine code is byte-identical in the official amd_release
builds, but some code layouts make it slow: on build 47a31cd vs its
parent cbbf13b, instructions 4.81e10 vs 4.86e10, `baclears.any` 2.62e8
vs 6.42e6, `int_misc.unknown_branch_cycles` 3.14e9 vs 1.12e8, `lsd.uops`
1.62e10 vs 2.22e10, backend counters equal, `LZ4_compress_fast_extState`
1857 vs 892 samples with every other frame equal. A plain LZ4 merge of the
same data (`enable_adaptive_codec_selection = 0`) shows the same slow
draw, so it is not adaptive selection code. Such builds (official master
47a31cd, 1200a74, 12e23c6 and several PR builds since
2026-10-06) run query 0 ~20% slower on either side of a comparison, and
the dashboard gate reports it as a confirmed regression on unrelated PRs.

The new data repeats each of 1024 random 64-bit hashes 8 times: many
short matches instead of one long one. LZ4 still wins every block
(3663/3663), and adaptive selection is ~71% of the merge time instead of
~37% (plain LZ4 0.164 s vs 0.567 s). On 9 official master builds, 3 of
them slow on the old data, 3 rounds of 5 merges: medians 0.562-0.584 s,
every build within 3% of the median and within 2% of its own parent.
30M rows keeps query 0 near its old run time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 8, 2026
@groeneai

groeneai commented Oct 8, 2026

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

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (3 nits).

# Sev Finding Verdict Evidence / action
1 💡 PR description overstated "no other query moves" AGREE, fixed in the description now "no other query moves consistently", matching the 12 CI cross runs
2 💡 PR body dropped the example lines inside the template's leading HTML comment AGREE, fixed in the description comment block restored verbatim
3 💡 The dashboard's master history of adaptive_codec_merge #0 gets one level step at merge AGREE, noted, not blocking both servers of every run use the PR's checked-out XML (ci/jobs/performance_tests.py), so later comparisons stay like-for-like

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

Session id: cron:clickhouse-review-slot-8:20261008-204300

@clickhouse-gh

clickhouse-gh Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5efd1ca]

Summary: ✅


AI Review

Summary

This PR changes tests/performance/adaptive_codec_merge.xml so adaptive_codec_merge no longer uses the exact-period dataset that turns query #0 into a code-layout-sensitive LZ4_count benchmark instead of an adaptive-codec benchmark. The new generator keeps repeated values and a similar amount of compressed work, while breaking the short exact period that caused unrelated ~20% swings; I also sanity-checked that intHash64(intDiv(number, 8)) % 1024 does not collapse to a short exact cycle that would recreate the old long-match pathology. I did not find any unresolved correctness, metadata, or review-thread issues in the current diff.

Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Oct 8, 2026
@rienath rienath self-assigned this Oct 8, 2026
@rienath rienath added the pr-performance Pull request with some performance improvements label Oct 9, 2026
@rienath
rienath added this pull request to the merge queue Oct 9, 2026
Merged via the queue into ClickHouse:master with commit 1bd0435 Oct 9, 2026
152 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 9, 2026
@clickhouse-gh clickhouse-gh Bot added comp-codecs Compression/encoding codecs (LZ4/ZSTD/etc.), archive formats (tar/zip/7z), codec selection and IO... and removed comp-testing Test content only (no production code). labels Nov 22, 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... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai pr-ci pr-performance Pull request with some performance 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