Skip to content

Run the single-threaded prefetch_in_aggregation performance queries on 20 million rows - #129625

Merged
murphy-4o merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-prefetch-in-aggregation-disabled
Nov 6, 2026
Merged

murphy-4o merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-prefetch-in-aggregation-disabled

Conversation

@groeneai

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

Part of the #129258 audit (queries over 1 s). The two single-threaded numbers(50000000) aggregations of prefetch_in_aggregation take 1062 ms (set, #4) and 1383 ms (count() map, #8) on amd MasterCI, 862 / 1049 ms on arm (14-day medians): they share their <query> elements with the numbers_mt variants, so one thread inserts 5e7 distinct keys.

The two elements get disabled="1". That also stops their four sub-second expansions (#5, #6, #7, #9), so verbatim copies of those are appended together with the two queries on numbers(20000000). No existing query number or text changes: 2 queries (6 expansions) are disabled and 5 queries (6 expansions) are appended (#14-#19). #12 and #13 held the numbers_mt(1e8) pair until #129303 moved it to #10/#11, so two disabled placeholders keep those numbers. The appended queries start a fresh history, but their CI threshold stays the same: every threshold this test has learned is below the compare.sh floors (0.15 / 0.25).

The test still measures prefetching: at 2e7 rows the hash tables are 256 MiB (set) and 512 MiB (count() map), above the L3 of both CI hosts (105 MB m7i, 36 MB m8g), and prefetch still saves 10% / 13% on them locally. On the same official master binary the two new queries take 0.41 / 0.43 of the old time (about 430 / 590 ms on amd, projected).

select a|b from t_str_key_* (#0-#3) are also over 1 s on master now, but only because of the libfiu fast-path flag that #129334 resets (67-600 ms without it), so they stay.

Validation: perf.py --print-queries lists the 12 master queries unchanged, then the 2 placeholders and the 6 new ones; local perf.py runs measured only the 12 enabled queries, and --max-queries 10 picked 10 of them.

🤖 Generated with Claude Code


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

Version info

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

… rows

The two single-threaded `numbers(50000000)` aggregations of this test take
1.1 s (set) and 1.4 s (`count()` map) on amd MasterCI: `numbers()` is one
stream, so one thread inserts 5e7 distinct keys, a row count sized for the
`numbers_mt` variant of the same `<query>` element.

Following the performance-history rule for existing tests (never change,
delete or renumber a query), the two `<query>` elements are marked
`disabled="1"` and replacements are appended after the last query:
`numbers(20000000)` for the set and the `count()` map, plus verbatim copies
of the four sub-second expansions the attribute also stops (`numbers_mt`
5e7 set, `count()` on `numbers` / `numbers_mt` 1e7 and `numbers_mt` 5e7),
so every case measured today is still measured. Numbers 12 and 13 held the
`numbers_mt(1e8)` pair until it moved to 10 and 11, so two disabled
placeholders keep them and the new queries start at 14. Indexes 0-11 keep
their texts; 6 expansions are disabled, 2 placeholders added and 6
expansions appended (14-19).

The 2e7 hash tables are 256 MiB (set, 8-byte cells) and 512 MiB (`count()`
map, 16-byte cells): well above L2, where aggregation turns prefetch on,
and above the L3 of both CI hosts, so the lookups still miss the caches.
Locally the two replacements take 0.41 / 0.43 of the 5e7 time on the same
binary.

Related: ClickHouse#129258

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

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (2 rounds)
  • ⚠️ history-key-reuse (major): the appended queries reused numbers 12/13, which held the numbers_mt(1e8) pair until Remove performance test queries that are also measured in another file #129303. AGREE, fixed: two disabled placeholders keep 12/13, the new queries are 14-19 (CI history has numbers 0-13 only for this test).
  • ⚠️ prefetch-gate-liveness (major): a full prefetch loss may stay under the 0.15 floor. DISAGREE: the 5e7 queries were already under it (gap 0.131 / 0.040 on the same binary), the 2e7 ones measure 0.104 / 0.133.
  • 💡 commit message wording on L2/L3: fixed.
  • 💡 Related: lines for every cited PR: DISAGREE, the template keeps only the needed relationship lines; the issue is linked and the PRs are cited inline.

@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The cost is not intermittent: MasterCI 14-day medians 1062 / 1383 ms amd (862 / 1049 arm) for #4 / #8; locally 1022-1088 / 1427-1461 ms on the same official binary.
b Root cause explained? #4 and #8 share their <query> elements with the numbers_mt variants, so the single-threaded numbers expansions run 5e7 rows; numbers() is one stream, so one thread inserts 5e7 distinct keys.
c Fix matches root cause? Only the two single-threaded expansions get 2e7 rows. The elements are disabled (no text or number change) and the replacements appended, the shape agreed on #129366. Two disabled placeholders keep #12 and #13, the old numbers of the numbers_mt(1e8) pair, so the appended queries start at #14.
d Test intent preserved / new tests added? The file is the test. The 2e7 tables are 256 MiB (set) / 512 MiB (count() map), above both CI L3s (105 / 36 MB); prefetch still saves 10% / 13% locally. The four sub-second expansions the attribute also stops are appended verbatim.
e Both directions demonstrated? Old texts 1022-1461 ms locally, new 429 / 610 ms (median of 6 per-server medians over 3 runs); ratio 0.41 / 0.43 on the same binary.
f Fix is general across code paths? N/A (test-only). Every expansion of the two disabled elements is replaced (#4, #8) or copied (#5, #6, #7, #9).
g Fix generalizes across inputs (params/datatypes/wrappers)? Both key layouts (8-byte set cells, 16-byte map cells), numbers and numbers_mt, the 1e7 / 2e7 / 5e7 / 1e8 points all stay.
h Backward compatible? (maintainer-approved exception only) Yes: queries #0-#11 keep their texts and numbers, disabled entries keep their numbers, no perf.py change.
i Invariants and contracts preserved? t_str_key_{size} create/fill/drop unchanged (read by #0-#3); 12 enabled queries as before, so --max-queries 10 still samples 10 of 12 (checked locally).

Session id: cron:clickhouse-impl-slot-7:20261105-204900

@groeneai

groeneai commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

cc @egor-click, could you review this and add the can be tested label so CI runs? Following the disabled approach from #129366: the two single-threaded numbers(50000000) queries (over 1 s) are disabled and replaced by appended 20 million row versions plus verbatim copies of the four sub-second expansions the attribute also stops; no existing query number or text changes, and #12/#13 stay as disabled placeholders.

@clickhouse-gh

clickhouse-gh Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e9f5b49]

Summary: ✅


AI Review

Summary

PR #129625, head e9f5b496a485f2c3184b0d45eae2ba931a1f730d, reduces the two single-threaded prefetch_in_aggregation workloads from 50 million to 20 million rows. It disables the original templates, appends replacements for their unaffected expansions, and reserves historical query numbers. No actionable findings. Validation using the current harness's expansion and selection code confirms unchanged query texts and indices 0–11, preservation of the 12 enabled workloads, and correct sampling with --max-queries 10. The PR provides before/after timings and prefetch measurements; runtime benchmarks were not independently rerun, and the PR's performance comparison jobs were skipped.

Final Verdict

Status: ✅ Approve. No required changes.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Nov 5, 2026
@egor-click egor-click added the can be tested Allows running workflows for external contributors label Nov 5, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Nov 5, 2026
@murphy-4o
murphy-4o added this pull request to the merge queue Nov 6, 2026
Merged via the queue into ClickHouse:master with commit 358b830 Nov 6, 2026
366 of 367 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 6, 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.

4 participants