Skip to content

Run the uniq_multi_place performance query for up to 1024 groups - #131785

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-uniq-multi-place
Nov 15, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-uniq-multi-place

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

The 2048- and 4096-group entries of uniq_multi_place.xml (query indexes 5, 6, 12, 13, 19, 20) take 1.03-2.96 s on MasterCI amd and 1.15-2.58 s on arm; the three 4096-group ones are above the perf report's 2 s single-run limit. Each group gets 16384 distinct values, so their time is the groups * 16384 single-threaded state insertions.

No existing query number or text changes: the one query (21 entries) is disabled, and the same query over 64 to 1024 groups is appended as 21-35, byte-identical to entries 0-4, 7-11 and 14-18.

The file measures the batched hash-and-prefetch insert of #119594, and 1024 groups already show it. On the 457 master commits of 2026-09-12..24 with that path (before #117009 or after #120578) and without it (between the two), 1024 groups keep 95-128% of the 2048/4096-group speedup on amd, and on arm 91-97% of the 2048-group one and 69-88% of the 4096-group one (the 69% is uniqCombined64). At 64-128 groups the path changes nothing; it sets in at 256.

This saves about 1 minute of query time per master perf job on each architecture. Checked locally with perf.py on the official MasterCI release build of the base, 8 pinned cores: each copy runs within 5% of its original, and no disabled entry runs. The copies restart the history of 15 sub-second queries.

🤖 Generated with Claude Code


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

Version info

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

The 2048- and 4096-group entries of uniq_multi_place.xml (query indexes
5, 6, 12, 13, 19, 20) take 1.03-2.96 s on MasterCI amd and 1.15-2.58 s
on arm; the three 4096-group ones are above report.py's 2 s single-run
limit. Each group gets 16384 distinct values, so the time is the
groups x 16384 single-threaded state insertions.

No existing query number or text changes: the one query (21 entries) is
disabled, and the same query over 64 to 1024 groups is appended as
21-35, byte-identical to entries 0-4, 7-11 and 14-18.

The batched hash-and-prefetch insert of ClickHouse#119594 that the file measures
already shows at 1024 groups. On the 457 master commits of
2026-09-12..24, with that path (before ClickHouse#117009 or after ClickHouse#120578) and
without it (between the two), 1024 groups keep 95-128% of the
2048/4096-group speedup on amd, and on arm 91-97% of the 2048-group one
and 69-88% of the 4096-group one (bootstrap p5 0.64, arm
uniqCombined64).

About 1 minute less query time per master perf job on each architecture.

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 an own cold review (0 findings).
Both checked the perf.py expansion (entries 0-20 keep their text and numbers, disabled; 21-35 are byte-identical
copies of 0-4, 7-11 and 14-18), that --max-queries samples only enabled entries, and that this test never had
a query number above 20.

Severity: ❌ blocker / ⚠️ major / 💡 nit. No finding was raised, so nothing was adjudicated.

Session id: cron:clickhouse-review-slot-8:20261115-120000

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. The six 2048/4096-group entries are the six longest on every run: 0.81-2.52 s locally with perf.py on the official release build of the base, 1.03-2.96 s on MasterCI. With the change the 15 enabled entries take at most 0.54 s.
b Root cause explained? Each group gets 16384 distinct values, so 2048/4096 groups are 33M/67M single-threaded state insertions per entry. Input size, not an engine cost: 41 ns per row on amd at 64 groups and at 4096, query analysis 0.5 ms.
c Fix matches root cause? Yes. Only the two group counts that cost more than 1 s are dropped, and they add no measured signal over 1024 groups. Values per group are not reduced (that would skip the HyperLogLog transition).
d Test intent preserved / new tests added? Preserved: the 15 (function, groups) combinations run verbatim with the same settings. At 1024 groups the prefetch effect of #119594 keeps at least 69% of the effect at 2048 and 4096 groups on both architectures (MasterCI; the minimum is arm uniqCombined64 at 4096, bootstrap p5 0.64). No new test, since this is a perf-test-only change.
e Both directions demonstrated? Master's file: 21 entries, six of them above 0.8 s, 203 s per local pass. New file: 15 entries, all under 0.55 s, 44 s per pass. Every copy is within 5% of its original, and no disabled entry runs in a prewarm or a run.
f Fix is general across code paths? N/A: no engine code. The other long-query files of #129258 get separate PRs.
g Fix generalizes across inputs (params/datatypes/wrappers)? All three functions stay, with 64-1024 groups: the in-cache controls 64/128 and the regime 256-1024. With 15 entries against max_queries 10, the master sampling still samples (checked with --max-queries 10).
h Backward compatible? (maintainer-approved exception only) Yes. Query numbers 0-20 are kept (disabled), and 21-35 are new numbers this test never had. No settings change. perf.py and CI are untouched.
i Invariants and contracts preserved? Existing query text and order are unchanged, and the copy is appended after the last query. The CI run-trend check of changed tests passes locally.

Session id: cron:clickhouse-impl-slot-6:20261115-114400

@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1792d23]

Summary: ✅


AI Review

Summary

PR #131785, head 1792d23442487f5236a033886142de991dd75a5b, shortens uniq_multi_place by disabling the historical queries and appending their unchanged 64–1024-group cases. Existing query indexes remain intact. The supplied timing and sensitivity measurements support the reduced workload. No actionable findings.

Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-ci 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 15, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 15, 2026
Merged via the queue into ClickHouse:master with commit 1962958 Nov 15, 2026
570 of 572 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 Nov 15, 2026
@clickhouse-gh clickhouse-gh Bot added comp-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). 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-aggregate-functions Aggregate function implementations (sum, avg, count, quantile, combinators, etc.). 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