Repository navigation
Pin the part layout of the index_bulk_filtering performance test - #121260
Conversation
The fixture fills its tables with min_insert_block_size_rows = 1, which disables squashing, so every block numbers(1000000) emits becomes its own part: 16 parts, 15 x 65409 + 18865 rows. Nothing stops merges, so the background scheduler collapses those 16 tiny single-partition parts while the harness is timing. The data is inserted in ascending order and the table is ORDER BY (), so each part covers a contiguous value range, and filterPartsByStatistics keeps only the parts whose range holds one of the three sought values: 3 of the 16 parts the fill writes, but both of 2 merged parts. Since total_marks_pk is summed over the survivors only, the granules the skip index has to evaluate are a step function of how far merging got before timing started, 39246 marks at 16 parts and up to 200003 at 2. The two sides of a comparison run set up concurrently on two servers, reach different points of that collapse, and the harness reports the difference as a slowdown of the binary under test. Over 10 days on Performance Comparison (arm_release, master_head, N/6), query #0 measures at two separated modes with an empty 16..24 ms bucket in 2493 samples per side, and the two sides' distributions match to within 2 samples. A mode flip reads as up to +291%, the job's own report calls the query slower, and the dashboard rates it confirmed_regression, which reds the shard on PRs whose diff cannot reach the query, and on master. SelectedMarks, SelectedRanges and SelectedRows are identical in both modes on both architectures, so no engine path misbehaves: the read is 3 granules either way and only the amount of index analysis moves. The fix therefore belongs in the fixture, which manufactures the non-determinism in its own fill. Stopping merges per table mirrors set_index_analysis.xml, the sibling fixture for this same feature; the per-table form, as in adaptive_codec_merge.xml, cannot reach another test's tables, and teardown restores merges and drops both tables, where the old file left test_minmax_index behind. Validated with an exact count oracle instead of timings, which makes it arch- and build-independent: with the pin, query #0 reports SelectedPartsTotal = 16 and SelectedMarksTotal = 39246, and query ClickHouse#1 reports 200003, on all 315 probes including after repeated sleeps. Unpinned, the same probe sees 11 parts / 91574 marks and then 6 / 156984 within half a second, and 6 / 156984 in the settled state. Removing only the two SYSTEM STOP MERGES lines brings the drift back. A co-tenant table filled while the pin is active still merges 16 parts down to 6, and after the drop_query block a fresh table of the same name merges again. Determinizing necessarily picks one mode, so the series steps once: amd from ~31 ms to ~14 ms, while the arm median stays at 8 ms. Related: ClickHouse#100759 Co-Authored-By: Claude Opus 5 <[email protected]>
Holding merges keeps the parts the fill writes, but it does not determine how they are cut. min_insert_block_size_rows = 1 disables squashing, so one part is written per source block, and the source block size for numbers(1000000) is max_block_size, which this fixture never set. The existing max_insert_block_size = 65536 does not supply it: use_strict_insert_block_limits defaults to false, and in that state the max_insert_block_size settings are not enforced for an INSERT. So the 16-part layout every figure here depends on was a property of the compiled DEFAULT_BLOCK_SIZE rather than of the fixture, and the arithmetic closes only on that value: 15 x 65409 + 18865 = 16 parts, 3 x 13082 = 39246 selected marks, 15 x 13082 + 3773 = 200003 total. Setting max_block_size to 65409 in both fills makes the cut a property of the settings and keeps those measured values unchanged, which is what join_convert_full_to_left_or_right.xml already does for the same reason. The pin could also fail silently. SYSTEM STOP MERGES <table> does not error when the table is not found: the statement resolves the StorageID without an existence check, and the action lock is added only if the catalog returns a table. A rename or a typo would therefore turn the pin back into a no-op, and because the fixture asserted nothing about its own layout the only symptom would have been confirmed_regression reds reappearing weeks later on unrelated pull requests, which is the failure this fixture change exists to end. One throwIf over system.parts per table, in the shape group_by_low_cardinality_array_join.xml uses, turns that into an immediate job failure: a setup query that raises is fatal, since perf.py re-raises it out of the worker thread. Validated with the same exact count oracle: query #0 reports SelectedPartsTotal = 16 and SelectedMarksTotal = 39246, and query ClickHouse#1 reports 200003, on all 574 tight probes and every settled iteration. The assertion was proven live in both directions it has to catch. With only the two SYSTEM STOP MERGES lines removed, test_set_index is down to 11 active parts by the time the fills finish and the assertion fires on every run; with merges still held but max_block_size set to 70000, both tables land at 15 parts and it fires again. SelectedMarks, SelectedRanges and SelectedRows are unchanged throughout, so the fixture still analyses the same 3 granules it always read. Corrects the previous commit message's disclosure of the one-time step in the amd series: measured at the pinned layout it is ~20 ms, the median over 174 job-sides in 30 days, not ~14 ms, which rested on 4 samples. The arm median is unchanged at ~8 ms. Related: ClickHouse#100759 Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 3 findings over 1 full pass and 1
The effectiveness figures in the description (0 of 5537 arm jobs at the check's 15% floor on Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-49:20260921-022000 |
|
Workflow [PR], commit [3d445e1] Summary: ✅
AI ReviewSummaryThis PR makes the Final VerdictStatus: ✅ Approve |
|
@groeneai can you resume to me why do you need this? |
|
Summary: The fill uses The cost: with both sides at 16 parts, 0 of 5537 arm jobs reached the 15% floor a The PR pins the layout the fill already builds and asserts it, so |
|
@groeneai show me a CI failure. You should always show a CI failure whenever you open a PR to fix something on it! |
|
Three failing jobs, quoting each report's own named results. A master run, no pull request under test, The fixture's three queries are the only named results: The failure this PR came from, on #109424, Another contributor's pull request the night before, Breadth from CIDB over 30 days, Point taken on always showing the failure: those three job links are now in the description. |
| <fill_query> | ||
| INSERT INTO test_set_index | ||
| SETTINGS max_insert_threads = 64, max_insert_block_size = 65536, min_insert_block_size_rows = 1, min_insert_block_size_bytes = 1 | ||
| SETTINGS max_insert_threads = 64, max_insert_block_size = 65536, max_block_size = 65409, min_insert_block_size_rows = 1, min_insert_block_size_bytes = 1 |
There was a problem hiding this comment.
The more interesting question is why max block size is not a power of two, and it isn't answered here.
There was a problem hiding this comment.
Sure it makes more sense, but we don't enforce it
There was a problem hiding this comment.
65409 is not a value I chose: it is the current default of max_block_size, DEFAULT_BLOCK_SIZE in src/Core/Defines.h:33, which is itself deliberately not a power of two (65536 - PADDING_FOR_SIMD - (PADDING_FOR_SIMD - 1), leaving room for the padding arrays carry). The setting writes out what the server already does, so that the layout this test asserts cannot follow a later change of that default. Measured both ways just now, same fill: with the setting and with it removed the layout is identical, 16 parts (15 of 65409 rows plus a 18865-row remainder), 200019 marks.
A power of two would deviate from the default rather than restate it: 65536 also gives 16 parts, but it moves #0 from 39246 to 39321 selected marks (the table in the other thread). So I kept the default and answered the question in the file, in 9d0f619. If you would rather have the round number, say so and I will switch it.
| SETTINGS index_granularity = 5; | ||
| </create_query> | ||
|
|
||
| <!-- Each merge widens a part's value range past the sought keys, and with squashing off a part holds exactly one source block, |
There was a problem hiding this comment.
@PedroTadim Some poor future person will stumble upon
Each merge widens a part's value range past the sought keys, and with squashing off a part holds exactly one source block
scratch its head, and wonder what this could possibly mean.
As a reminder, it is our collective responsibility to keep the code, including the tests, in a form that they can be digested easily. Write once, read many times.
There was a problem hiding this comment.
There are more complex comments with many more lines across the codebase.
There was a problem hiding this comment.
Totally not personal of course, but this is not an excuse to add more of these.
There was a problem hiding this comment.
@groeneai can you simplify the comment to just say stopping merges, so none happens while the inserts are being benchmarked?
There was a problem hiding this comment.
Simplified in 9d0f619. The comment is now:
Stop merges, so that none happens while the queries below are benchmarked.
65409 is the default `max_block_size`, written out so that the part layout stays the same
if that default changes.
The first sentence is the one asked for here. The second is only there because of the block size question in the other thread. Everything else the old comment tried to say (why a merged part changes what these queries read, the measurements, the alternatives I rejected) is in the commit message instead.
Review asked for a comment a future reader can digest, and for it to say only that merges are stopped so that none runs while the queries are benchmarked. The second line records where 65409 comes from, since review also asked why the pinned block size is not a power of two. It is not a chosen constant: it is the current default of `max_block_size` (`DEFAULT_BLOCK_SIZE` in src/Core/Defines.h, 65536 minus the SIMD padding that arrays carry). Writing the default out keeps this test's part layout independent of a later change to that default, and it changes nothing measured today: with and without the setting the fill builds the same layout (16 parts, 15 x 65409 rows + 18865, 200019 marks). A power of two would deviate from the default and shift the work instead: 65536 still gives 16 parts, but moves query #0 from 39246 to 39321 selected marks. Comments only; the queries and the assertions are byte-identical.
| <fill_query> | ||
| INSERT INTO test_minmax_index | ||
| SETTINGS max_insert_threads = 64, max_insert_block_size = 65536, min_insert_block_size_rows = 1, min_insert_block_size_bytes = 1 | ||
| SETTINGS max_insert_threads = 64, max_insert_block_size = 65536, max_block_size = 65409, min_insert_block_size_rows = 1, min_insert_block_size_bytes = 1 |
There was a problem hiding this comment.
@groeneai keep the block sizes always a power of two
There was a problem hiding this comment.
Done in 1b779dc: both fills pin max_block_size = 65536, matching the max_insert_block_size next to it and tests/performance/join_convert_full_to_left_or_right.xml, which pins the same pair at that value.
Nothing the test asserts changes. Both tables still write 16 active parts, so the throwIf oracles stand; the cut moves from 15 x 65409 rows + 18865 to 15 x 65536 + 16960. Per EXPLAIN indexes = 1, #0 keeps the same 3 of 16 parts and reads the same 3 granules, with the index range it walks moving 39246 -> 39321 (+0.19%, against the check's 15% floor); #1 and #2 keep their part selection too.
I dropped the comment line that named 65409 as the default, since the swap makes it false, and updated the two figures the description quoted.
Review asked to keep the block sizes always a power of two, so the fill's `max_block_size` moves from 65409 to 65536. It now matches the `max_insert_block_size` beside it and tests/performance/join_convert_full_to_left_or_right.xml, which pins the same pair at 65536. 65409 was the current default of the setting (`DEFAULT_BLOCK_SIZE` in src/Core/Defines.h, 65536 minus the SIMD padding), so the pinned value is now a deliberate round number instead of a restatement of that default. The comment dropped the sentence naming 65409 as the default, which the swap makes false, and states the invariant the pin buys instead. Nothing the test asserts or measures changes. Both tables still write 16 active parts, so the `throwIf` oracles stand; the cut moves from 15 x 65409 rows + 18865 to 15 x 65536 + 16960. Measured with `EXPLAIN indexes = 1` on all three queries, 65409 -> 65536: #0 parts 3/16 unchanged, index range 39246 -> 39321 granules, read 3 -> 3 ClickHouse#1 parts 1/16 unchanged, read 1 -> 1 ClickHouse#2 parts 12/16 unchanged, 156984 -> 157284 granules, read 133114 -> 133110 The +0.19% is the range the skip index walks, not the data read. With both sides at one layout the worst arm spread measured on #0 is +9.6% over 5537 jobs, against the check's 15% floor, so the shift is far below either.
CI finish ledger - 1b779dcEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
#121090 fails a This pull request changes one file, Session id: cron:our-pr-ci-monitor:20260922-143219 |
|
@rschu1ze one more look? |
CI finish ledger - 4f50febEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
#121189 fetches those thresholds with praktika's own 60 s CIDB timeout instead of the hardcoded 10 s, Not reachable from the diff. This pull request changes one file, Session id: cron:our-pr-ci-monitor:20260923-040203 |
|
@groeneai is this PR still needed? |
|
Yes. Master still has the fixture unpinned, and The dashboard gate keeps reading a flip between those two modes as a real regression. Last night, on an unrelated pull request: https://github.com/ClickHouse/ClickHouse/actions/runs/35910186150/job/107422940157 That exact shape, this fixture the only flagged query and the shard failing on a confirmed regression, occurred in 6 jobs on 6 different pull requests in the last 7 days. With the pin, all six of the fixture's query rows are |
|
@rschu1ze one more round of review? |
|
Good to merge |
Related: #100759
CI failures it fixes, with each job's own named results:
680645a5ff6a,amd_release 2/6: the only named results are the fixture's three queries,#0and#1slower (36 ms against 45, 76 against 97) and#2unstable.arm_release 2/6:Fail [index_bulk_filtering #0], the only named result; 8 ms against 31.arm_release 1/6: the same; 7 ms against 28.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Stop merges and pin the source block size while the
index_bulk_filteringperformance test fills its tables, so its queries are measured against the part layout the fills build.Description
The fixture disables squashing (
min_insert_block_size_rows = 1), so every source block becomes its own part, 16 in all, which merges then collapse while the harness is timing. Parts cover contiguous ranges (ascending data,ORDER BY ()), sofilterPartsByStatisticskeeps 3 of the 16 the fill writes but both of 2 merged ones, and the skip index evaluates 39321 marks instead of 199997. The two sides of a run reach different points of that collapse, and the modes are disjoint: the 16..24 ms bucket is empty in 2517 samples per side over 10 days ofarm_release, master_head.The job's own report then calls query
#0slower and the dashboard rates itconfirmed_regression. The read is the same 3 granules either way, so no engine path misbehaves.So I pin the layout the fill already builds:
SYSTEM STOP MERGESper table, which cannot reach another test's tables, andmax_block_size = 65536, so the cut is a property of the settings and not of the setting's default.join_convert_full_to_left_or_right.xmlpins the same pair at the same value. AthrowIfper table fails the job if the layout is not 16 parts, sinceSYSTEM STOP MERGESon a missing table is a silent no-op.With both sides at 16 parts, 0 of 5537 arm jobs reached the check's 15% floor on
#0(worst +9.6%); with the layouts differing, 489 of 3469 did, up to +316%. Removing either pin restores the drift. Determinizing picks one mode, so the series step once, all on amd (30 d medians):#030 -> 16 ms,#167 -> 59,#266 -> 83, arm moving under 5% on all three.#2keeps a residual, layout-independent noise floor (230slowerrows in 30 d against#0's 91).Workflow [PR]
Sync PR [sync-upstream/pr/121260]
Version info
26.10.1.630-master(included in26.10and later)