Skip to content

Perf CI: confirm a flagged change only if it reproduces at two of three stack placements - #128022

Merged
egor-click merged 1 commit into
ClickHouse:masterfrom
groeneai:perf-ci-confirm-three-stack-placements
Oct 28, 2026
Merged

egor-click merged 1 commit into
ClickHouse:masterfrom
groeneai:perf-ci-confirm-three-stack-placements

Conversation

@groeneai

@groeneai groeneai commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #112928

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: CI-only change.

Description

On #112928, arm 1/6 is red: set_in_clustered_keys #2 0.0627 -> 0.0806 s, #3 0.1132 -> 0.1492 s, and its rerun after a restart reproduced both (+27.1%, +29.8%). The hot keys256 probe is instruction-identical on both sides and their static TLS sizes are equal (so not #122550). The PR makes both ThreadFromThreadPool::worker() frames 32 bytes larger; a 64-byte stack realignment between them absorbs one, so the probe's frame lands 32 bytes deeper in its stack page, and on arm these queries have a slow mode that follows that position (47 builds in September). Thread stacks start at the same page offset on every start, so the rerun measured the same placement.

confirm_changes now reruns the flagged queries at three placements: the main run's, and with GLIBC_TUNABLES=glibc.rtld.optional_static_tls=1856 / 3264 for both servers, which moves every pool thread stack 1344 / 2752 bytes lower. eqmed.sql and step 5's rule run per placement, and a change is confirmed only if it reproduces at two of the three: query-metric-stats.tsv gets an actual placement row with the majority verdict, leaving step 5 and the dashboard check unchanged. With fewer than three placements, placement 0's row is used, as today. The main run is unchanged. Cost: two more restarts and reruns of the flagged queries, only when something is flagged (15-21 s per confirmation in this job).

Validation, local on x86: a harness with fake servers and the real clickhouse-local, eqmed.sql and dashboard reader demotes a slowdown present at one placement only (current code keeps it blocking) and keeps one present at two or three; a master server started with each surplus moved every thread stack but the main one by exactly 1344 / 2752 bytes. The arm timing at the new placements is inferred, not measured (no arm host).

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.11.1.849-master (included in 26.11 and later)

…ee stack placements

Since ClickHouse#126977 both perf servers start with ASLR disabled, so every start of a
binary puts its thread stacks at the same place. A change that only moves the
query threads' frames within their stack pages (on ClickHouse#112928, `ThreadPool` worker
frames 32 bytes larger) then reproduces at every restart: `set_in_clustered_keys`
ClickHouse#2/ClickHouse#3 were 28-32% slower on arm with an instruction-identical `keys256` probe
and equal static TLS, and the confirmation rerun reproduced them (+27.1%,
+29.8%), so the shard stayed red.

`confirm_changes` now reruns the flagged queries at three placements: the main
run's own, and with `glibc.rtld.optional_static_tls` = 512 + 21*64 and
512 + 43*64 for both servers (glibc puts the static TLS block at the top of
every thread stack, so all thread stacks move 1344 and 2752 bytes lower).
`restart` takes the surplus as an optional argument; without it nothing changes.
`eqmed.sql` runs separately per placement, step 5's rule is evaluated per
placement, and `query-metric-stats.tsv` gets, per query, an actual placement
row on the side of the two-of-three majority (the one farthest from the
thresholds), so step 5 and the dashboard check in `performance_tests.py`, which
are unchanged, reach the majority verdict. With fewer than three placements
measured (a failed restart or rerun, the time budget), the placement 0 row is
used, which is the previous behaviour; without it the original verdict stands.
The per-placement verdicts go to `placement-verdicts.tsv` and the job log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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) plus my own cold review (5 nits, no blocker or major).

# Sev Finding Verdict Evidence / action
1 💡 The description's frame arithmetic, ASLR wording and cost were imprecise AGREE, fixed in the description realignment absorbing one frame, page offset wording, 15-21 s per confirmation measured in the linked job
2 💡 The dashboard text still says "after server restart" and shows the selected placement's diff only AGREE, not blocking both consumers are unchanged by design; every placement's diff and verdict is printed in the job log
3 💡 #122550 edits the same two launch lines AGREE, not blocking whichever lands second combines the surpluses per side

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-8:20261028-032800

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, of the CI behaviour: with the current compare.sh, a slowdown present only at the main run's stack placement is "Reproduced after server restart" on every rerun, as in the linked arm 1/6 job and in a local harness (fake servers, real clickhouse-local + eqmed.sql + dashboard reader). The arm timing itself comes from CI (no arm host here).
b Root cause explained? #112928 makes both ThreadFromThreadPool::worker() frames 32 bytes larger, so the keys256 probe's frame lands 32 bytes deeper in its stack page (instruction-identical code, equal static TLS). On arm these two queries have a slow mode tied to that position, and every restart has the same layout, so the confirmation rerun cannot tell it from a change in the code.
c Fix matches root cause? Yes: the confirmation, whose job is separating real changes from environment effects, now varies the one remaining confound (stack placement) and needs two of three placements to reproduce. Thresholds, the reproduction rule and both consumers are unchanged.
d Test intent preserved / new tests added? CI-infrastructure change, so no self-test (per the earlier "no tests for the test infrastructure" decision); local validation instead.
e Both directions demonstrated? Yes: harness case "slow at placement 0 only" stays blocking with the current script and is demoted with this one; "slow at all three" and "slow at two of three" stay blocking with this one.
f Fix is general across code paths? Both confirmation entry points (shard report and dashboard) go through confirm_changes. All other restart callers pass no argument and are unchanged (launch lines verified identical).
g Fix generalizes across inputs (params/datatypes/wrappers)? Both flagged-file formats, slower and faster changes, several queries per test, a failed restart or rerun at any placement, an exhausted time budget, empty statistics, values exactly at the thresholds, a pre-set GLIBC_TUNABLES, non-Linux hosts.
h Backward compatible? (maintainer-approved exception only) CI only, no settings. With fewer than three placements measured the output is the current single-rerun row.
i Invariants and contracts preserved? Both servers always run at the same placement; each placement's statistics use only its own samples; query-metric-stats.tsv keeps one row per query in the existing format; every error path is fail-open in the strict direction (no row -> original verdict).

Session id: cron:clickhouse-impl-slot-5:20261028-030000

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @egor-click, could you review this and add the can be tested label so CI runs? The perf confirmation rerun now measures flagged queries at three thread-stack placements (both servers with GLIBC_TUNABLES=glibc.rtld.optional_static_tls surpluses) and confirms a change only if it reproduces at two of them, so a slowdown caused only by where a hot frame lands in its stack page (the set_in_clustered_keys #2/#3 red on #112928) no longer blocks.

@clickhouse-gh

clickhouse-gh Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b72e1f1]

Summary: ✅


AI Review

Summary

The PR reruns flagged performance queries at three thread-stack placements and selects measurements matching the two-of-three verdict, retaining placement 0 when evidence is incomplete. No actionable correctness or reliability findings were identified in commit b72e1f17d6dbc628e5f311c6ca5353044b26e866.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Oct 28, 2026
@egor-click egor-click added the can be tested Allows running workflows for external contributors label Oct 28, 2026
@egor-click
egor-click added this pull request to the merge queue Oct 28, 2026
Merged via the queue into ClickHouse:master with commit 637cc25 Oct 28, 2026
529 of 531 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 28, 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-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). 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