Repository navigation
Merge the insert_statistics_uniq_v2 statistics tables into one part before measuring - #126505
Conversation
…efore measuring Since 2f07f3f (ClickHouse#122231) `t_materialize_uniq_v2_{i64,f64}` no longer stop merges, so background merges run while the fill commits its 20 1M-row parts and keep running during queries #0-ClickHouse#3. Each compared server ends up with its own layout (CI server logs: 8 servers, 8 layouts, from [6,6,6,1,1] to [20] million rows). The measured `ALTER ... CLEAR STATISTICS ALL, MATERIALIZE STATISTICS ALL` runs one single-threaded mutation task per part, so its time follows the largest part, and the layout lasts the whole job, so the dashboard confirmation restart reproduces the gap (`confirmed_regression` on unrelated PRs, e.g. ClickHouse#126296: ClickHouse#4 0.1445 -> 0.1933 s). Merge both tables into one part in the fill with `OPTIMIZE TABLE ... FINAL SETTINGS optimize_throw_if_noop = 1` and assert one active part per table with `throwIf`, as `and_compare_chain_derived.xml` does. Without `optimize_throw_if_noop` a failed merge assignment only logs and returns success, leaving a random layout. A table that background merges already collapsed to one part is still rewritten under FINAL, so the pin never throws on it. `projection_materialize.xml` measures a mutation over one merged part the same way and is stable on the same harness. Validated on the official master release build (26.11.1.120): before, 10 fills gave 5 i64 layouts and a 1.92x spread of ClickHouse#4, and perf.py on two servers gave right/left 1.249, 0.892, 0.841 in 3 of 5 fills; after, one 20M-row part per table in 10 of 10 fills, ClickHouse#4/ClickHouse#5 spread 1.029/1.041, and perf.py right/left within 5% in 5 of 5. Replacing one OPTIMIZE with `SELECT 1` fails the fill. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 (1 nit).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261017-165100 |
|
cc @naushniki, could you review this? Since |
|
Workflow [PR], commit [f03df96] Summary: ✅
AI ReviewSummaryThe PR stabilizes Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; normal CI validation remains pending. |
naushniki
left a comment
There was a problem hiding this comment.
LGTM once this PR's own perf run is green; I'll approve then.
#122231 caused this: the SYSTEM STOP MERGES it removed also blocked the measured mutations (StorageMergeTree::scheduleDataProcessingJob returns before selecting mutations while merges are blocked), so #4 and #5 never ran in CI before, and after the removal the layout was left to background merges. The NightlyExtendedPerformance runs show the same: in all four so far #4/#5 differ by 19–62 % with opposite signs in one run (2026-10-17: #4 −50 %, #5 +58 %), which only a per-server layout explains. Besides #109455 and #114577, #126296 and #122069 went red on it.
OPTIMIZE ... FINAL waits for running merges and rewrites an already merged part (optimize_skip_merged_partitions = 0), so the pin is deterministic.
Optional:
- With
optimize_throw_if_noop = 1eachOPTIMIZE ... FINALleaves one part in the only partition or throws, so thethrowIfis redundant. Keeping it as an explicit guard, as inand_compare_chain_derived.xml, is also fine. - The description could say that #4/#5 never completed in CI before #122231, so this pins their first layout rather than restoring an old one.
This PR's own Performance Comparison (arm_release, master_head, …) run uses the new XML on both servers, so it checks #4/#5 on arm directly.
|
Thanks. I added that sentence to the description. I am keeping the |
400b1d9
Related: #122231
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
insert_statistics_uniq_v2performance test now merges eacht_materialize_uniq_v2_*table into one part before measuringMATERIALIZE STATISTICS, so both compared servers mutate the same layout.Description
Performance Comparison (arm_release, master_head, 6/6)failed on #126296 (a CI-scripts-only diff) withinsert_statistics_uniq_v2 #4as its red reason: report, 0.1445 -> 0.1933 s,confirmed_regressionafter the restart. #109455 and #114577 went red the same way on 2026-10-17, and about 19 PRs that day had#4/#5slowerorunstable.Before #122231,
SYSTEM STOP MERGESon the two tables underALTER ... CLEAR STATISTICS ALL, MATERIALIZE STATISTICS ALLalso blocked the measured mutations, so#4/#5never completed in CI. Since #122231 background merges run while the fill inserts its 20 parts, and each server ends with its own layout (CI server logs: 8 servers, 8 layouts, from[6,6,6,1,1]to[20]million rows). The ALTER runs one mutation task per part, so its time follows the largest part, and the layout lasts the whole job, which is why the restart reproduces the gap.The fill now runs
OPTIMIZE TABLE ... FINAL SETTINGS optimize_throw_if_noop = 1on both tables and athrowIffails the job unless each has one active part, the shape ofand_compare_chain_derived.xml.projection_materialize.xmlmeasures a mutation over one part the same way and is stable on arm (0 of 5642 runs off by more than 10%). The queries are unchanged; this pins the first layout#4/#5are measured on rather than restoring an old one.Validated on the official master release binary with
perf.pyon two servers: before,#4right/left was 1.249, 0.892 and 0.841 in 3 of 5 fills (different layouts); after, every ratio of#4/#5was within 5% in 5 of 5, with one 20M-row part per table. Replacing oneOPTIMIZEwithSELECT 1makes thethrowIffail the fill.#4/#5settle at about 0.24 s locally (amd), and the fill takes about 0.9 s longer.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/126505]
Version info
26.11.1.189-master(included in26.11and later)