Skip to content

Run four adaptive_aggregation_top_k_threshold queries on hits_10m_single - #131677

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-adaptive-aggregation-top-k-threshold-shorter
Nov 14, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-adaptive-aggregation-top-k-threshold-shorter

Conversation

@groeneai

@groeneai groeneai commented Nov 14, 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

Five queries of adaptive_aggregation_top_k_threshold.xml take more than 1 s on MasterCI since the file landed in #130281: queries 0-3 and 6 (numbered from 0, as in the report) at 1286-1799 ms on amd, and query 6 at 1128 ms on arm. Each is a GROUP BY URL over all 100M rows of hits_100m_single; the shared top-K threshold the file measures is a part of that time (#130281 made these queries 7.5% to 29% faster on CI).

No existing query number or text changes: 4 queries are disabled and 4 are appended. Queries 0, 2, 3 and 6 get disabled="1" and are appended as 7-10 with one word changed: hits_100m_single -> hits_10m_single (10M rows, loaded by every perf job).

Measured with perf.py on official MasterCI release builds (3 A/A passes of up to 25 runs per query): each copy takes 0.12-0.14 of its original's time, so about 170-220 ms on amd and 110-140 ms on arm, and about 64 s (amd) and 40 s (arm) less query time per master perf job. The copies go through the adaptive aggregator like the originals at 8 and 12 threads (AdaptiveAggregation* profile events): every producer freezes, the merge runs, and the ascending ones skip all but 8-13 merge units. On the builds before and after #130281, queries 0, 2, 3 and 6 are 1.25x, 1.31x, 1.20x and 1.42x faster, their copies 1.20x, 1.47x, 1.17x and 1.35x.

Query 1 stays as it is: locally #130281 made it only 1.07x faster, less than three times the A/A noise of my passes, so I have no measurement that a copy would keep that sensitivity.

Queries 7-10 start a new history (CIDB has only 0-6 for this test). 7 queries stay enabled, so every master job still runs all of them.

🤖 Generated with Claude Code


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

Version info

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

Queries 0, 2, 3 and 6 of tests/performance/adaptive_aggregation_top_k_threshold.xml
take 1.29-1.80 s on MasterCI amd (query 6 1.13 s on arm): each is a GROUP BY URL over
the 100M rows of hits_100m_single, and the top-K threshold the file measures is a part
of that time. They get disabled="1" and are appended as queries 7-10 with the table
changed to hits_10m_single, nothing else. No existing query number or text changes.

Measured with perf.py on official MasterCI release builds (ClickHouse#129258 series rig):
- size: each copy takes 0.124-0.138 of its original's time (3 A/A passes x 25 runs),
  projected 174-223 ms amd and 109-140 ms arm; about 64 s amd and 40 s arm less query
  time per master perf job;
- regime: the copies freeze every producer, merge, and the ascending ones settle
  (8-9 of 256 units merged at 8 threads, 9-13 at 12), like the originals do on CI;
- sensitivity, the builds before and after ClickHouse#130281: originals 1.252x / 1.308x /
  1.201x / 1.419x faster, copies 1.196x / 1.465x / 1.167x / 1.353x.

Query 1 stays enabled: its ClickHouse#130281 effect locally (1.066x) is below three times the
A/A noise, so there is no measurement that a copy keeps it.

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; 1 finding) plus my own cold review (2 nits).

# Sev Finding Verdict Evidence / action
1 ⚠️ The XML alone does not prove queries 7-10 still go through the adaptive top-K path with enough signal DISAGREE Measured on every run (3 A/A passes, the #130281 pair, 12 threads): every producer freezes, the merge runs, ascending copies settle after #130281 and not before; A/A threshold 1.3-2.9%; copies keep the #130281 speedup (1.20x / 1.47x / 1.17x / 1.35x). arm: this PR's perf CI
2 💡 The file's header comment numbers the disabled originals; copies are mapped by one appended line AGREE, noted Comment-only: no query, setting or query number is affected
3 💡 "3 passes x 25 runs" overstated the originals' runs (perf.py stops a query at 30 s per server) AGREE, fixed Description reworded

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

Session id: cron:clickhouse-review-slot-11:20261114-195800

@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 since #130281 of queries 0, 1, 2, 3, 6 are 1600 / 1527 / 1286 / 1288 / 1799 ms on amd (6: 1128 ms on arm), and 1.14-1.72 s locally on the same official build.
b Root cause explained? Each is a GROUP BY URL over the 100M rows of hits_100m_single (18M URLs). The threshold #130281 shares between the merge threads is part of that time (CI: 7.5% to 29%). On the 10M-row hits_10m_single (2.8M URLs) the same queries take 0.124-0.138 of the time.
c Fix matches root cause? One word per copy: the table. Query texts, orders, LIMITs and aggregates are unchanged; the originals stay in the file, disabled.
d Test intent preserved / new tests added? The copies freeze every producer, merge, and the ascending ones skip all but 8-13 merge units, like the originals, at 8 and 12 threads (AdaptiveAggregation* events). Before/after #130281: queries 0, 2, 3, 6 are 1.252x / 1.308x / 1.201x / 1.419x faster, their copies 1.196x / 1.465x / 1.167x / 1.353x. Query 1 (1.066x, below 3x the A/A noise) is kept. No new test: the file is the test.
e Both directions demonstrated? The build pair ran twice, with the older build on the left and then on the right; the effect is the mean of both. The older build shows 0 pruned units for every ascending query and copy, the newer one settles them.
f Fix is general across code paths? N/A (test-only). Queries 4 and 5 are below 1 s; query 1 is kept.
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 copies get the new numbers 7-10 (CIDB has only 0-6 for this test).
i Invariants and contracts preserved? 7 queries stay enabled (<= 10, all run every job); the file has no create, fill or drop queries; no disabled query runs (query_log of both servers); no query's time grows run over run in the final file.

Session id: cron:clickhouse-impl-slot-4:20261114-184900

@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [521cf0b]

Summary: ✅


AI Review

Summary

PR #131677 replaces four expensive performance queries with copies using hits_10m_single, retaining the disabled originals to preserve historical query indices. No actionable findings at 521cf0b1717a3caf1b87bbc3183ca6b4f7eefe4b.

The assessment of retained benchmark sensitivity relies on the author's reported A/A measurements, profile events, and comparisons across the optimization in #130281. Benchmarks were not rerun locally; the current CI reports contain no performance-query results.

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 14, 2026
@alexey-milovidov alexey-milovidov self-assigned this Nov 14, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 14, 2026
Merged via the queue into ClickHouse:master with commit 3f5aeae Nov 14, 2026
570 of 572 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 14, 2026
@clickhouse-gh clickhouse-gh Bot added comp-aggregation GROUP BY / aggregation framework (hash tables, spilling, external aggregation). 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-aggregation GROUP BY / aggregation framework (hash tables, spilling, external aggregation). 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