Skip to content

Run a smaller copy of the external_set performance query 13 - #131824

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-external-set-smaller-copies
Nov 16, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-external-set-smaller-copies

Conversation

@groeneai

@groeneai groeneai commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #129258

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

Query 13 of external_set.xml (a set of 10M tuples of four hashes, 32-byte keys) takes 3.43 s on MasterCI amd and 2.83 s on arm, above the perf report's 2 s single-run limit. About 2 s is the single-threaded build of the set; the rest are lookups reading most blocks from the file, as the set is 2.4 times its 128 MiB cache: what the query measures.

No existing query number or text changes: 1 query is disabled and 1 smaller copy appended as 14. It runs the same text at a quarter of its scale: a set of 2.5M tuples with max_bytes_for_external_set_cache = 33554432 (a quarter of the default) and 2.5M lookups in chunks of max_block_size = 16352 (a quarter of 65409). So the set is again 2.4 times its cache and each chunk needs as large a share of its blocks: locally the cache hit share (0.39), block accesses per key (0.42) and bytes per block read (11.7 KB) equal the original's.

On the MasterCI builds before and after #124907, which CI shows moving query 13 1.9-2.1x, the copy keeps 95% of the original's speedup (2.13x vs 2.19x), with the local 480 MiB L3 capped to one way (30 MiB; CI's VMs share theirs with neighbours: 105 MB on amd, 36 MB on arm). The build before #124907 lacks the cache setting, so its server registers it as an inert custom setting.

Query 2 (1.34 s amd, 1.39 s arm) stays: a copy on 15M rows writes 16 parts of 15.0 MB instead of 30 of 16.0 MB.

The copy should take about 0.81 s on amd and 0.67 s on arm: about 30 s less query time per master perf job. The copy restarts the history of query 13.

🤖 Generated with Claude Code


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

Version info

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

Query 13 of external_set.xml (a set of 10M tuples of four hashes,
32-byte keys) takes 3.43 s on MasterCI amd and 2.83 s on arm, above
report.py's 2 s single-run limit. About 2 s is the single-threaded build
of the set; the lookups read most of their blocks from the file because
the set is 2.4 times its 128 MiB cache, which is what the query measures.

No existing query number or text changes: 1 query is disabled and 1
smaller copy appended as 14. The copy is the same text at a quarter of
its scale: a set of 2.5M tuples with max_bytes_for_external_set_cache =
33554432 (a quarter of the default), 2.5M lookups in chunks of
max_block_size = 16352 (a quarter of 65409). Measured with perf.py on the
official MasterCI build, L3 capped to one way: the cache hit share
(0.393), block accesses per key (0.419), bytes per block read (11.7 KB),
Bloom skip share (0.485) equal the original's, and the build share of
the query time is 0.467 vs 0.453. On the MasterCI builds before and
after ClickHouse#124907 (70906e3 -> 1d76716), which CI shows moving query 13
1.9-2.1x, the copy keeps 95% of the original's speedup (2.13x vs 2.19x,
both seat orders); the build before ClickHouse#124907 gets the cache setting as an
inert custom setting through the rig's config only.

Query 2 (1.34 s amd, 1.39 s arm) stays: a copy on 15M rows writes 16
parts of 15.0 MB instead of 30 of 16.0 MB, outside the +-5% bound for
bytes per part.

The copy is projected at 0.81 s on amd and 0.67 s on arm: about 32 s
(amd) and 27 s (arm) less query time per master perf job.

Related: ClickHouse#129258

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; 0 findings), plus my own cold review of the change (2 nits).

# Sev Finding Verdict Evidence / action
1 💡 The copy's 32 MiB cache has 32 shards of 1 MiB, the original's 128 MiB has 64 of 2 MiB (DiskSetBlockCache.cpp:49) AGREE, noted Not blocking: the copy's cache hit share, block accesses per key and bytes per block read equal the original's, and 32 shards stay above the 8 (amd) / 12 (arm) lookup threads
2 💡 The PR body's L3 sentence could read as the copy's 80 MB file fitting in CI's 105 MB L3 on amd AGREE, fixed The body now says the CI VMs share that L3 with their neighbours

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

Session id: cron:clickhouse-review-slot-9:20261115-154900

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The cost is measured, not intermittent: MasterCI medians of query 13 are 3.43 s on amd and 2.83 s on arm (65 / 66 commits), and 4.4 s locally on the official build with the L3 capped to one way.
b Root cause explained? About 2 s is the single-threaded build of a set of 10M 32-byte keys; the lookups read 29.8 GB of blocks from the file because the set is 2.4 times its 128 MiB cache, which is what the query measures. Not an engine defect.
c Fix matches root cause? The same text at a quarter of its scale: the set, its cache (max_bytes_for_external_set_cache = 33554432), the lookups and the rows per chunk (max_block_size = 16352). The original stays in the file, disabled.
d Test intent preserved / new tests added? Locally the copy has the original's cache hit share (0.393), block accesses per key (0.419), bytes per block read (11.7 KB) and Bloom skip share (0.485), and on the MasterCI builds before and after #124907 it keeps 95% of the original's speedup (2.13x vs 2.19x). No new test: the file is the test.
e Both directions demonstrated? The build pair ran in both seat orders (the older build left, then right); the copy is 2.17x and 2.08x faster on the newer build, the original 2.18x and 2.20x.
f Fix is general across code paths? N/A (test-only). Query 2 also takes more than 1 s, but its copy on 15M rows writes parts 6% smaller than the original's, so it stays as it is.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only).
h Backward compatible? (maintainer-approved exception only) No existing query number or text changes; the copy gets the new number 14 (CIDB has only 0-13 for this test). PR perf runs compare against a master reference that has the cache setting.
i Invariants and contracts preserved? 14 queries stay enabled; with CI's --max-queries 10 --soft-max-queries all 14 still run (run_all_queries); no disabled query runs (query_log of both servers); no query's time grows run over run.

Session id: cron:clickhouse-impl-slot-5:20261115-133115

@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [52febd4]

Summary: ✅


AI Review

Summary

PR #131824 disables query 13 in external_set.xml and appends a smaller query 14, scaling the set, lookups, cache budget, and chunk size together. Existing query numbers remain stable. The documented cache counters and before/after measurements support preserving the intended cache-overflow workload and regression sensitivity. No actionable findings.

Missing context / blind spots
  • ⚠️ Benchmarks were not rerun locally. The available Praktika reports contain no performance measurements for this PR; the performance assessment relies on the author's documented measurements. Running query 14 on CI amd and arm would independently confirm the projected sub-second runtimes.
Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 15, 2026
@clickhouse-gh clickhouse-gh Bot added can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 15, 2026
@alexey-milovidov alexey-milovidov self-assigned this Nov 16, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 16, 2026
Merged via the queue into ClickHouse:master with commit 1adbd31 Nov 16, 2026
570 of 572 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 16, 2026
@clickhouse-gh clickhouse-gh Bot added comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. 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-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. pr-ci 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