Skip to content

Pin max_insert_threads = 1 in the polymorphic_parts_{s,m,l} performance tests - #127696

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/polymorphic-parts-single-insert-thread
Oct 25, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/polymorphic-parts-single-insert-thread

Conversation

@groeneai

@groeneai groeneai commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #100759
Related: #109006

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):

The polymorphic_parts_s, polymorphic_parts_m and polymorphic_parts_l performance tests set max_insert_threads = 1, so each INSERT writes its parts in one thread, as it did before 26.8.

Description

polymorphic_parts_m, _l and _s are #2, #3 and #5 of the noisiest performance tests in #100759: over the report floors in 319, 289 and 156 of 672 query runs on master (2026-10-22..24), never flagged because the learned thresholds absorb it, e.g. amd_release 2/6 @ 3954b49b: polymorphic_parts_m #0 +31%, stat threshold 0.96.

The noise starts at #109006 (max_insert_threads default 1 -> auto). For arm polymorphic_parts_m #0 the stat threshold is 0.06 on the merge's parent and 0.23-0.56 on the next five master commits; from April to June at most 1% of their query #0 runs were over the floors. Each INSERT ... SELECT now writes its 50 to 500 parts from 8 (amd) or 12 (arm) threads, and a Wide part of this schema is about 475 files. On the CI disk they wait: per amd polymorphic_parts_m #0 INSERT, OSIOWaitMicroseconds went from 0.17 s to 8 s for the same OSWriteBytes and FileOpen. In m and l the Wide and Buffer inserts slow down run over run (the last of 7 runs takes 1.7-2.9x the first); s does not grow but is noisy too.

The pin is the previous behavior, as #109006 documents. The queries, parts and files written are unchanged, and the inserts get slower, not faster. Parallel INSERT SELECT stays covered by parallel_insert.xml and insert_parallel.xml.

Validation: locally (CI release build, two servers, 5 x 7 runs per variant), the pin gives 2 thread pool jobs per INSERT instead of 12 with identical parts, files and bytes; all 9 queries have a stat threshold <= 0.10 in at least 4 of 5 invocations, and the mean last run is within 8% of the mean first. The CI disk regime does not reproduce on local NVMe, so this PR's own performance comparison is the real check.

🤖 Generated with Claude Code


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

Version info

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

Since ClickHouse#109006 (26.8) `max_insert_threads` defaults to auto, so each
`INSERT ... SELECT` of these tests writes its 50-100 parts from 8 (amd)
or 12 (arm) threads instead of one. A Wide part of the `hits_10m_single`
schema is ~475 files; on the IOPS-capped CI disk the parallel writers
wait for the write-back of the previous runs (OSIOWaitMicroseconds per
INSERT 0.17 s -> 8 s, same OSWriteBytes and FileOpen), so every run is
slower than the one before and the three tests became ranks ClickHouse#2, ClickHouse#3 and
ClickHouse#5 of the noisiest performance tests on master (ClickHouse#100759), from 0% over
the report floors before ClickHouse#109006.

Pin the setting to 1, as ClickHouse#109006 documents for restoring the previous
behavior. The queries, parts and files written are unchanged; parallel
INSERT SELECT stays covered by parallel_insert.xml and insert_parallel.xml.

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 cold review (2 nits).

# Sev Finding Verdict Evidence / action
1 💡 The PR description attributed the noise of polymorphic_parts_s to the same I/O wait, but its Compact query has no I/O wait on CI AGREE, fixed in the description sentence reduced to "s does not grow but is noisy too"
2 💡 The one-line XML comment describes the Wide/Buffer mechanism only; the Compact queries got noisier through parts-lock contention of the parallel writers AGREE, noted, not blocking the pin removes both; comment kept to one line

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding. Findings on hunks unchanged by the fix round are auto-dropped.

Session id: cron:clickhouse-review-slot-9:20261024-070600

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @CurtizJ, could you review this and add the can be tested label so CI runs? Since #109006 the INSERT ... SELECT queries of these tests write their 50-500 parts from 8 (amd) or 12 (arm) threads, and on the CI disk the m and l Wide and Buffer inserts slow down run over run; the pin restores the single writer they had before 26.8, with the same queries and parts. One question, as you wrote these tests: should they keep measuring the single-writer insert (this PR), or should they measure the parallel insert instead?

@clickhouse-gh

clickhouse-gh Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3729795]

Summary: ✅


AI Review

Summary

The PR pins max_insert_threads = 1 in the three polymorphic_parts performance tests to reduce insert timing noise. The change is narrowly scoped, but its CI-specific stabilization claim still needs validation on the affected storage.

Findings
  • ⚠️ Major — CI noise reduction remains unverified (tests/performance/polymorphic_parts_m.xml:31, applies to all three tests). The description acknowledges that local NVMe does not reproduce the CI disk regime. This head's performance comparison jobs were skipped because pr-performance is absent, so the local measurements do not establish that the pin removes CI write-back drift and noise. Run the affected performance tests on CI storage before merging. CI report.
Tests
  • ⚠️ Enable performance comparison and report statistical thresholds and first-to-last-run drift for the nine affected queries against the unpinned measurements. No additional test implementation is needed.
Final Verdict

⚠️ Request changes — provide CI-storage measurements confirming the claimed reduction in noise and run-time drift.

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Oct 24, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 25, 2026
<max_block_size>100</max_block_size>
<min_insert_block_size_rows>100</min_insert_block_size_rows>
<!-- Write the parts in one thread: parallel writers make each run wait for the disk writes of the runs before it -->
<max_insert_threads>1</max_insert_threads>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Validate the noise reduction on CI storage

The description explicitly says the local NVMe runs do not reproduce the CI disk regime, but this head's performance jobs are skipped because the PR is not labeled pr-performance. The local measurements support the thread-count change, but leave the actual CI write-back drift and noise reduction unverified. Please run performance CI for the three changed tests and compare their statistical thresholds and first-to-last-run drift with the unpinned results before merging. This needs measurements from the affected storage, rather than an additional test.

@alexey-milovidov alexey-milovidov self-assigned this Oct 25, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 25, 2026
Merged via the queue into ClickHouse:master with commit 0970789 Oct 25, 2026
526 of 528 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 25, 2026
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-ClickHouse__ClickHouse that referenced this pull request Nov 10, 2026
…wer run over run

perf.py repeats every measured query on the same tables without a reset. A
query that changes what its next run reads (a growing table, an UPDATE that
rewrites its own rows, a file each run appends to) gets slower run over run
and is then noisy on master for weeks: 8 of the 10 noisiest tests of the last
round in ClickHouse#100759 were this class, all fixed after merge. A PR run could not
notice: its status ignores slower/unstable rows, and the A/B diff of a new
test mixes noise with the PR's own change.

In master_head PR runs (not nightly, not the Iceberg configuration), read the
job's own analyze/query-runs.tsv for the tests the PR adds or changes and fail
Check Results when a query has, on the tested server, at least 5 runs with
corr(run, time) > 0.8 and last/first > 1.2. Only the tested server counts:
after the merge both master servers run that code, and requiring both servers
drops recall to 0.34-0.94 of heads on last round's offenders against
0.60-0.98. One FAIL child per query carries both servers' run times. A missing
file or a malformed row of a changed test fails the check; unknown changed
files add a workflow warning instead. test_discovery.changed_tests is the
selection, which changed_iceberg_tests now reuses.

Validated on 16 real job logs: flagged on master before ClickHouse#127696 / ClickHouse#127380 and
on all 8 head jobs of ClickHouse#119147, not flagged after the fixes, 1 of 273 tests on
today's master (a query rising on both servers).

Related: ClickHouse#100759

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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