Skip to content

Run the polymorphic_parts_l Buffer insert on 20 parts - #131888

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

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-polymorphic-parts-l-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

Query 2 of polymorphic_parts_l.xml, the INSERT through hits_buffer, takes 2.30 s on MasterCI amd (4.22 s on arm); the wide and compact INSERTs take 1.68 and 0.32 s (3.09 and 0.44 s on arm). Each INSERT writes 100 parts of 1000 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: 1 query is disabled and 1 copy appended as 3. The copy is the Buffer INSERT on 20 parts of the same 1000 rows; the wide and compact queries keep their 100 parts. Per part, the copy's local time is 0.97-1.01x and its user time 1.01-1.03x its original's.

On the MasterCI builds before and after #109000, which made the Buffer's nested INSERT for every block more expensive (CI: query 2 user time 1.48x on amd, 1.65x on arm), the copy keeps 100-110% of its original's slowdown locally (both seat orders, two repetitions on different NUMA nodes). The wide query stays enabled: a 20-part copy of it missed the 4-14% per-part user time increase of #109454 (statistics for every written part) in one of four passes.

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

Projected CI time of the copy: 0.45-0.46 s on amd, 0.82-0.85 s on arm, saving about 19 s of query time per master perf job on amd and 34 s on arm. The copy restarts the history of 1 query.

Validation: perf.py runs only queries 0, 1 and 3, also with CI's --max-queries 10, with no run trend.

🤖 Generated with Claude Code


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

Version info

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

Query 2 of polymorphic_parts_l.xml (INSERT through hits_buffer) takes 2.30 s
on MasterCI amd and 4.22 s on arm. No existing query number or text changes:
1 query is disabled and 1 copy appended as 3, the same INSERT on
numbers(20000), i.e. 20 parts of the same 1000 rows.

Decision (deterministic, two repetitions on NUMA nodes 5 and 0, official amd
release builds, both seat orders):
- copy of query 2: per-part time 0.971 / 1.010 of the original's, per-part
  user time 1.005 / 1.026; on the MasterCI pair of ClickHouse#109000 (7a4e895 ->
  e523465) it keeps 1.002 / 1.097 of the original's client-time slowdown
  (original 1.217 / 1.214, copy 1.217 / 1.234).
- query 0 (wide) is not replaced: on the ClickHouse#109454 pair (2485f14 ->
  45cb837) its 20-part copy's per-part user time moved by 0.972 in one of
  four passes, and the rule asks for > 1 in every pass.

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

Saving: about 19 s of query time per master perf job on amd and 34 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 💡 Query 2's history ends; the copy (query 3) starts a new one 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 the Buffer query noted The copy starts from the original's table state; per part its time is 0.97-1.01x, user time 1.01-1.03x; 0 delayed inserts. Stated in the description.

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

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

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes: query 2 measured on demand with perf.py on the official amd build of the base, 2.13-2.28 s locally (MasterCI amd 2.30 s); the copy 0.44-0.46 s.
b Root cause explained? Input size over the per-part cost the file measures: 100 wide parts of 1000 rows (475 files each), each written by the Buffer through its own nested INSERT. Not an engine defect.
c Fix matches root cause? Yes: the same INSERT 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 copy's time is 0.97-1.01x and its user time 1.01-1.03x the original's; it keeps 100-110% of the original's slowdown on the MasterCI build pair of #109000. Perf-test-only change, no other test.
e Both directions demonstrated? Yes: original and copy both detect #109000 (s 1.21-1.26 in every pass, both seat orders, two NUMA nodes).
f Fix is general across code paths? The wide and compact queries are unchanged; a copy of the wide query was evaluated and not used (it did not keep the #109454 effect in every pass).
g Fix generalizes across inputs (params/datatypes/wrappers)? The copy keeps 20 blocks, so it takes the same async-insert fallback route as the original; file opens and buffer allocations per part are equal.
h Backward compatible? (maintainer-approved exception only) No existing query number or text changes (disabled="1" only); the copy restarts the history of 1 query.
i Invariants and contracts preserved? Creates, settings and drops unchanged; every table is still written by an enabled query; perf.py runs exactly queries 0, 1, 3, also with --max-queries 10, with no run trend.

Session id: cron:clickhouse-impl-slot-4:20261115-224700

@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [fa66ef4]

Summary: ✅


AI Review

Summary

PR #131888 replaces the 100-part Buffer insert benchmark with a 20-part copy, retaining the original query index through disabled="1". The replacement preserves the 1,000-row blocks and direct writes into hits_wide; the other two benchmarks remain unchanged. The reported timings and historical-regression comparisons support the reduction. Review of the current code, full diff, and prior discussion found no actionable issues. Benchmarks were not rerun during this review.

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 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 870a541 Nov 16, 2026
384 of 385 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 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