Repository navigation
versions: wait for background merges to settle before benchmarking - #1622
Merged
Merged
Conversation
Since ClickHouse 26.8, a plain INSERT runs with max_insert_threads = all cores (ClickHouse/ClickHouse#109000). The bulk Native load saturates the machine, so background merges barely progress during the load: the load itself finishes ~2x faster (ssb: 737s vs 1569s on 26.7.1.1315 -- exactly the 87 GB / 125 MB/s gp3 throughput floor), and the deferred merge work (~1.7x write amplification) lands in the query phase, where it competes with the queries for CPU, disk bandwidth and page cache on the c7a.4xlarge (16 vCPU, 32 GB). The 2026-08-26 master (26.9.1.170) results show the resulting timeline: mgbench (benchmarked first) is mildly elevated, ssb (second, and the largest single-INSERT dataset) degrades catastrophically with the telltale tapering within and across queries (Q1 hot 0.064s -> 8.4s, Q7 1.5s -> 32s with successive tries 40/45/39/35/32s, while Q8-Q13 are normal), and hits (third) is consistently *faster* on master -- the genuine engine speedups, visible once the merge storm has ended: https://benchmark.clickhouse.com/versions/#version=-&dataset=+sb&metric=hot&queries=- Wait for the server-wide system.merges to drain (up to MERGE_SETTLE_TIMEOUT, default 1 h) before the query phase, so every version is measured against the same, settled table state -- the state the old single-threaded loads reached implicitly within the load window. This also stabilizes the reported data_size (measured on settled parts). Co-Authored-By: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 2026-08-26 master (26.9.1.170) run of the versions benchmark showed strange, massive degradations on
ssb(hot runs up to 130x slower: Q1 0.064s → 8.4s, Q7 1.5s → 32s), visible at https://benchmark.clickhouse.com/versions/#version=-&dataset=+sb&metric=hot&queries=-Investigation showed these are not per-query engine regressions but an artifact of when the queries run relative to deferred background merge work:
INSERTruns withmax_insert_threads= all cores (Support max_insert_threads for plain INSERTs ClickHouse#109000). The bulk Native load saturates the machine, so background merges barely progress during the load window.ssbload: 737s vs 1569s on 26.7.1.1315 — 737s is exactly the 87 GB / 125 MB/s gp3 throughput floor), and the deferred merge work (~1.7x write amplification) lands in the query phase, competing with the queries for CPU, disk bandwidth and page cache on the c7a.4xlarge (16 vCPU, 32 GB).mgbench(benchmarked first) is mildly elevated (hot +12-50%, colds up to 3x),ssb(second, the largest single-INSERT dataset) degrades catastrophically with tapering successive tries (Q7: 40/45/39/35/32s) and recovers from Q8 on, andhits(third) is consistently faster on master (0.6-0.9x) — the genuine engine improvements, visible once the merge storm has ended.ssbqueries, but accumulates ~3.6x more post-load merge wall time under an unconstrained load (MergeTotalMilliseconds8417s vs 2321s for the same inserted data).The fix: after loading, wait for the server-wide
system.mergesto drain (bounded byMERGE_SETTLE_TIMEOUT, default 1 h; requires a few consecutive empty reads; skips gracefully on prehistoric builds withoutsystem.merges) before starting the query phase. Every version is then measured against the same, settled table state — the state the old single-threaded loads reached implicitly within the load window. This also stabilizes the reporteddata_size(measured on settled parts, not mid-merge).The wait mostly displaces time the merge storm would otherwise steal from the query phase, so the total run duration stays within the existing 5 h VM budget.
🤖 Generated with Claude Code