Skip to content

Run the polymorphic_parts_m performance inserts on 20 parts - #131896

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-polymorphic-parts-m-20-parts
Nov 16, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-polymorphic-parts-m-20-parts

Conversation

@groeneai

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

Queries 0 and 2 of polymorphic_parts_m.xml (INSERTs into hits_wide and through hits_buffer) take 1.59 and 2.19 s on MasterCI amd (3.00 and 4.09 s on arm); the compact one 0.28 s (0.39 s on arm). Each INSERT writes 100 parts of 100 rows, 475 files per wide part of the hits schema, and the Buffer writes every block into hits_wide with its own nested INSERT: the costs the file measures.

No existing query number or text changes: 2 queries are disabled and 2 copies appended as 3 and 4. The copies are the same INSERTs on 20 parts of the same 100 rows; the compact query keeps 100 parts. Per part, the copies' local time is 0.97-1.00x and user time 1.00-1.03x their originals'.

On the MasterCI builds before and after #109000 (costlier nested INSERTs; CI: query 2 user time 1.38x on amd, 1.70x on arm), the Buffer copy keeps 80-104% of its original's slowdown. On those of #109454 (statistics per written part; CI: query 0 user time 1.07x on amd, 1.06x on arm), the wide copy keeps 93-97% of its original's per-part user time increase, measured with 30 runs per server, which a 6% effect needs.

hits_wide now receives 20 instead of 100 parts per run from each copy, so a cost growing with the parts already in the table, rather than per written part, is smaller in the copies.

The copies should take 0.32 and 0.42-0.43 s on amd, 0.60 and 0.79-0.80 s on arm, saving about 31 s of query time per master perf job on amd and 57 s on arm. The copies restart the history of 2 queries.

Validation: perf.py on the final file runs only queries 1, 3 and 4, also with CI's --max-queries 10, no run trend.

🤖 Generated with Claude Code


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

Version info

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

No existing query number or text changes: 2 queries are disabled and 2
copies appended as 3 and 4. Queries 0 (wide) and 2 (Buffer) take 1.59 and
2.19 s on MasterCI amd (3.00 and 4.09 s on arm); each writes 100 parts of
100 rows. The copies are the same INSERTs on numbers(2000): 20 parts of the
same 100 rows. The compact query (0.28 s) keeps its 100 parts.

Local A/B with perf.py on official MasterCI builds, two repetitions on
different NUMA nodes, both seat orders (decide.py VERDICT ok, GEN_ARGS 1 1):
- per part, copy vs original: time 0.97-1.00x, user time 1.00-1.03x;
  file opens and buffer allocations per part equal, statistics step present
  exactly when in the original.
- ClickHouse#109000 (7a4e895 -> e523465): the Buffer copy keeps 80-104% of
  query 2's client-time slowdown (CI: user time 1.38x amd, 1.70x arm).
- ClickHouse#109454 (2485f14 -> 45cb837): the wide copy keeps 93-97% of
  query 0's per-part user time increase (CI: 1.07x amd, 1.06x arm).
The ClickHouse#109454 passes ran perf.py with --min-runs 30 --cap 30: at CI's 5-7
runs per server a copy that keeps a 6% effect fully misses it in a third
or more of passes.

hits_wide receives 20 instead of 100 parts per run from each copy, so a
cost that grows with the parts already in the table, rather than per
written part, is smaller in the copies.

Projected CI medians: 0.32 / 0.42-0.43 s on amd, 0.60 / 0.79-0.80 s on arm;
about 31 s of query time per master perf job on amd and 57 s on arm.

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 review (0 blocking findings).

# Sev Finding Verdict Evidence / action
1 💡 Queries 0 and 2 end their history; the copies (3 and 4) start new ones noted The disabled + append shape of the #129258 series; stated in the description.
2 💡 hits_wide gets 20 instead of 100 parts per run from each copy noted Per part the copies' time is 0.97-1.00x, user time 1.00-1.03x; 0 delayed inserts. Stated in the description.
3 💡 The compact query no longer runs after the wide one DISAGREE CI already runs the queries in random order (--max-queries 10). Locally its median changes by at most 4% on 3 of 4 passes, and is 9% faster on the first.
4 💡 The wide query is replaced here, while the polymorphic_parts_l sibling keeps its own noted The copy keeps 93-97% of #109454's per-part user time increase (30 runs per server); its noise stays well below the 0.25 unstable threshold.

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

Session id: cron:clickhouse-review-slot-8:20261116-030300

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes: queries 0 and 2 measured on demand with perf.py on the official amd build of the base, 1.57-1.78 s and 2.10-2.27 s locally (MasterCI amd 1.59 / 2.19 s); the copies 0.32-0.34 / 0.42-0.43 s.
b Root cause explained? Input size over the per-part cost the file measures: 100 wide parts of 100 rows (475 files each), and for the Buffer query one nested INSERT per written block. Not an engine defect.
c Fix matches root cause? Yes: the same INSERTs on 20 parts of exactly the same shape; no setting, table or Buffer threshold changes.
d Test intent preserved / new tests added? Yes: per part, the copies' time is 0.97-1.00x and user time 1.00-1.03x the originals'; they keep 80-104% (Buffer, #109000) and 93-97% (wide, #109454 per-part user time) of the originals' effects on the MasterCI build pairs. Perf-test-only change, no other test.
e Both directions demonstrated? Yes: originals and copies both detect #109000 and #109454 in every pass, both seat orders, two repetitions on different NUMA nodes.
f Fix is general across code paths? Both queries above 1 s are covered; the compact query (0.28 s) is unchanged.
g Fix generalizes across inputs (params/datatypes/wrappers)? The copies keep the file's settings (async_insert = 0, max_insert_threads = 1, block sizes 100) and tables; file opens and buffer allocations per part are equal to the originals'.
h Backward compatible? (maintainer-approved exception only) No existing query number or text changes (disabled="1" only); the copies restart the history of 2 queries.
i Invariants and contracts preserved? Creates, settings and drops unchanged; every table is still written by an enabled query; perf.py runs exactly queries 1, 3, 4, also with --max-queries 10, with no run trend.

Session id: cron:clickhouse-impl-slot-5:20261116-014700

@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [88bf0d7]

Summary: ✅


AI Review

Summary

PR #131896 replaces the two expensive wide-part and Buffer performance queries with 20-part variants, retains their disabled originals to preserve query numbering, and leaves the compact-part query unchanged. Reviewed commit 88bf0d79704632a653a4601e510239ba3f678fa9, the full diff, surrounding execution paths, and all prior PR discussion. No actionable findings.

Missing context / blind spots
  • ⚠️ Performance CI jobs were skipped, and benchmarks were not rerun locally during this review. Runtime savings and regression sensitivity are supported by the author's reported before/after measurements; an executed performance comparison would provide independent confirmation.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). can be tested Allows running workflows for external contributors labels Nov 16, 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 755856a 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-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... 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-part-formats Formats of MergeTree data parts in the public repository, that is how a part is laid out on disk ... 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