Skip to content

Pin the part layout of the timeseries_to_grid_aggregation_functions performance test - #122319

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:pin-timeseries-grid-perf-fixture
Sep 26, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:pin-timeseries-grid-perf-fixture

Conversation

@groeneai

@groeneai groeneai commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #122136

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

Not required (performance-test fixture only).

Description

Performance Comparison (arm_release, master_head, 4/6) failed on #122136 with
timeseries_to_grid_aggregation_functions #3/#4/#9 reported slower:
job 108017960314.
Master flags the same test (#4 slower, shard 6/6, 2026-09-19):
job 105978021806.
Since #121847 merged (2026-09-23), 15 PRs had a failed Performance Comparison job whose only slower
rows were this test's.

The dense fill inserts 4M rows under max_insert_threads = 8 into four parts. id = number % 400
cycles 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_grid to one part with OPTIMIZE ... FINAL SETTINGS optimize_throw_if_noop = 1,
so the read order follows from the data, and a throwIf on system.parts fails the job unless one
part 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:

dense arm (30 queries) before (4 parts) after (1 part)
cross-server CPU ratio, median / max 1.198 / 1.827 1.038 / 1.174
re-fill spread of median CPU, median / max 1.967x / 3.034x 1.087x / 1.192x
rows at |diff| >= 0.15 9 of 90 0 of 90
shard run stage 115.3 s 77.6 s

Deleting only the OPTIMIZE makes the assertion throw on both servers. ts_grid_ingest stays
multi-part on purpose (the file's parallel-merge arm), and
ts_grid_sparse already fills as one part.


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

Version info

  • Merged into: 26.10.1.719-master (included in 26.10 and later)

…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]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect labels Sep 25, 2026
@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; bounded: 1 full pass + 1 fix round + 1 delta recheck), plus my own cold review of the same head, whose findings are below.

# Sev Finding Verdict Evidence / action
1 ⚠️ The master link in the draft description pointed at a 2026-09-23 shard 4/6 run where all six arm shards were red and this test was only unstable AGREE, fixed before publication now links the 2026-09-19 shard 6/6 run, whose report flags #4 slower
2 ⚠️ The draft's breadth figure (124 PRs) counted every cause of that shard's reds AGREE, fixed before publication replaced by the attributable count: 15 PRs since 2026-09-23 where this test's rows were the only slower ones
3 💡 Commit message says "four parts of near-identical size" (they are 664141 and 3 x 1111953 rows) and "the four cells" without introducing them AGREE, not blocking wording only; the numbers it states are correct

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-8:20260925-181951

@clickhouse-gh

clickhouse-gh Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1a91ba0]

Summary: ✅


AI Review

Summary

This PR pins the dense ts_grid fixture in timeseries_to_grid_aggregation_functions.xml to a single active part before the benchmark queries run, and adds an explicit system.parts assertion so the job fails closed if that layout pin stops taking effect. I did not find a correctness or perf-fixture regression in the current diff: the new setup stays outside the measured query texts, matches existing performance-test patterns (OPTIMIZE plus throwIf/system.parts assertions), and is consistent with how perf.py executes setup and stops background merges.

Final Verdict

Status: ✅ Approve

@alexey-milovidov alexey-milovidov self-assigned this Sep 26, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Sep 26, 2026
Merged via the queue into ClickHouse:master with commit 689cf86 Sep 26, 2026
176 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 26, 2026
@clickhouse-gh clickhouse-gh Bot added comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... 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-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... groeneai-origin-ci-own-pr PR origin: CI on a groeneai PR exposed a separate defect 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