Repository navigation
Pin the part layout of the timeseries_to_grid_aggregation_functions performance test - #122319
Conversation
…erformance test
The 30 measured queries that read the dense `ts_grid` table are not measurable:
the two servers of one Performance Comparison job burn 1.2-1.8x different CPU on
byte-identical input, so the test is the 3rd noisiest of the whole perf corpus
(mean |diff| 0.0951 / p90 0.228 over 30 days of master arm runs, against 0.0136 /
0.030 for the corpus) and its learned thresholds have widened to 0.27-1.26. It
therefore cannot see a regression in `timeSeries*ToGrid` below 27-126%, and
whenever a file edit renumbers the queries the thresholds snap back to the 0.15
floor and the noise reds the shard for unrelated PRs.
The cause is the fill, not the engine. It inserts 4M rows under
`max_insert_threads = 8`, and the squashing defaults land them in four parts of
near-identical size. Because `id = number % 400` cycles every 400 rows, every
part spans all 400 ids, so the four parts mutually overlap in the sorting key
`(id, timestamp)` and which timestamp window lands in which part is an
insert-scheduling draw that differs per server and per fill. Measured on two
byte-identical servers, same fill, same row counts per part (664141 + 1111953 x3):
server A all_1_1_0 19:04:30-03:46:30 server B all_1_1_0 17:15:30-03:46:30
all_2_2_0 00:00:00-09:05:00 all_2_2_0 04:59:40-18:37:20
all_3_3_0 10:26:50-00:58:50 all_3_3_0 04:05:10-00:58:50
all_4_4_0 03:10:40-19:04:30 all_4_4_0 00:00:00-10:26:50
That draw decides how far each id's buckets are spread across the aggregation
threads and therefore how much partial-state merging the query does, while
`SelectedParts` = 4, `SelectedMarks` = 489 and `SelectedRows` = 4000000 stay
identical on both sides, which is why the counters look deterministic and the
CPU is not.
Merging to one part makes the read order a function of the data. Measured
locally, A/A on one binary copied to two paths, both servers bound to one NUMA
node, quiet-gated before and after each run, 3 independent re-fills per variant
(dense arm, 30 queries):
4 parts (before) 1 part (after)
cross-server CPU ratio, median 1.198 1.038
cross-server CPU ratio, max 1.827 1.174
re-fill spread of median CPU, median 1.967x 1.087x
rows at |diff| >= 0.15 9/90 0/90
run stage of the shard 115.3 s 77.6 s
An earlier attempt pinned `max_threads = 1` on the 10 dense query templates
instead. That is the worst of the four cells (re-fill spread 6.58x, cross-server
3.28) because one thread absorbs the whole layout penalty that twelve threads
were averaging out; it also cost +73 s of shard time and, by editing 30 query
texts, would have reset their learned-threshold identities. This change leaves
all 35 query texts byte-identical (`--print-queries` md5 unchanged), so no
threshold resets.
`optimize_throw_if_noop = 1` and the `throwIf` part-count assertion are two
oracles on purpose: the first names why a pin failed, the second names the
outcome. Neither can pass silently, which matters because a pin that quietly
stops taking effect is how this fixture became unmeasurable. `ts_grid_ingest`
(the file's declared multi-part arm) and `ts_grid_sparse` are deliberately left
alone: both measure symmetric here (CPU ratio 1.024 and 1.069 median), and
`ts_grid_ingest` drew 20 parts against 19 on the other server while staying at
1.024, so its layout term is negligible.
Closes nothing; this is a CI fixture fix.
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; 0 findings; bounded: 1 full pass + 1 fix round + 1 delta recheck), plus my own cold review of the same head, whose findings are below.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20260925-181951 |
|
Workflow [PR], commit [1a91ba0] Summary: ✅
AI ReviewSummaryThis PR pins the dense Final VerdictStatus: ✅ Approve |
Related: #122136
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not required (performance-test fixture only).
Description
Performance Comparison (arm_release, master_head, 4/6)failed on #122136 withtimeseries_to_grid_aggregation_functions #3/#4/#9reportedslower:job 108017960314.
Master flags the same test (
#4slower, shard 6/6, 2026-09-19):job 105978021806.
Since #121847 merged (2026-09-23), 15 PRs had a failed Performance Comparison job whose only
slowerrows were this test's.
The dense fill inserts 4M rows under
max_insert_threads = 8into four parts.id = number % 400cycles every 400 rows, so every part spans all 400 ids and the parts overlap in
(id, timestamp).Which timestamps land in which part is an insert-scheduling draw that differs per server and per
fill, so the two servers read the same 4 parts, 489 marks and 4M rows in a different order, at a
different CPU cost.
The fix merges
ts_gridto one part withOPTIMIZE ... FINAL SETTINGS optimize_throw_if_noop = 1,so the read order follows from the data, and a
throwIfonsystem.partsfails the job unless onepart is left. The 35 query texts are unchanged, so no learned threshold resets.
Validated A/A on x86-64 (on master the test is as noisy on amd as on arm), one binary on two servers
bound to one NUMA node, 3 re-fills each:
|diff| >= 0.15runstageDeleting only the
OPTIMIZEmakes the assertion throw on both servers.ts_grid_ingeststaysmulti-part on purpose (the file's parallel-merge arm), and
ts_grid_sparsealready fills as one part.Workflow [PR]
Sync PR [sync-upstream/pr/122319]
Version info
26.10.1.719-master(included in26.10and later)