Skip to content

Perf CI: start both servers with ASLR disabled and fail when their executable base differs - #126977

Merged
Algunenano merged 2 commits into
ClickHouse:masterfrom
groeneai:perf-ci-no-aslr-same-executable-base
Oct 21, 2026
Merged

Algunenano merged 2 commits into
ClickHouse:masterfrom
groeneai:perf-ci-no-aslr-same-executable-base

Conversation

@groeneai

@groeneai groeneai commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #125949

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

The two servers of the Performance Comparison job are PIE executables started with ASLR on, so every start loads the executable at a new random address, and the position of the code modulo 2 MiB differs between the reference and the patched server and between restarts. As suggested in #125949 (comment), this disables ASLR for these two servers only (the release binaries and ASLR everywhere else are unchanged) and fails the run when their executable base differs.

Both launchers, CHServer in performance_tests.py and restart in compare.sh, start the server through setarch <arch> -R (Linux only; the jobs already run with seccomp=unconfined, which personality(2) needs in docker). The new check_executable_base.py takes each server's PID from the status file in its data path and compares the start of the offset-0 mapping of /proc/<pid>/exe. It runs at the end of the Start stage, which fails on a mismatch, and in compare.sh after every restart that brought up both servers, where a mismatch exits; the get_profiles fallback now calls restart outside its subshell, so that exit is not swallowed. A restart that fails to start a server keeps its existing handling.

Validation, in the x86-64 clickhouse/performance-comparison image with seccomp=unconfined: with two different master release builds, both servers load at 0x555555554000 in the Start stage and in the compare.sh restart, confirmation and profile-fallback paths; one server started without setarch fails the Start stage and ends compare.sh, printing both addresses; a server that fails to start gives the same restart status and caller behaviour as before. On CI, this PR's arm perf jobs run the check; the amd ones run only with the pr-performance label.

🤖 Generated with Claude Code


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

Version info

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

groeneai and others added 2 commits October 20, 2026 14:47
…ecutable base differs

Both measured servers are PIE executables started with ASLR on, so every
start loads the executable at a new random address, and the position of
the code modulo 2 MiB differs between the reference and the patched server
and between restarts. Start them through `setarch <arch> -R` in both
launchers (`CHServer.start_cmd` in performance_tests.py and `restart` in
compare.sh), so that both load the executable at the fixed base, and fail
the run when the two running servers do not have the same executable base,
so that a divergence of the launchers is noticed and fixed in the scripts.

The check is one script, `check_executable_base.py`, used by both: it takes
the PID from the `status` file in the server's data path (the started
process is `/bin/sh`, `taskset` or `setarch`, and the server forks under its
watchdog) and reads the start of the offset-0 mapping of `/proc/<pid>/exe`
(on x86-64 `remap_executable` replaces only the R+X mapping).

In compare.sh the check exits instead of returning, because
`confirm_changes` only skips its rerun on a failed restart; the
`get_profiles` fallback now runs `restart` outside the subshell, so that this
exit is not swallowed there.

The jobs already run with `seccomp=unconfined`, which `personality(2)` with
ADDR_NO_RANDOMIZE needs inside docker. Linux only, like the CPU pinning.

Requested in ClickHouse#125949 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A server that fails to start keeps the callers' existing handling:
`confirm_changes` and the `get_profiles` fallback are fail-open, and
`restart` returns the same status as before, because the two final
`kill -0` checks stay its last commands. The base check now runs before
them and only when both started servers are alive, so a restart that
fails for another reason no longer ends compare.sh through the
checker's missing `status` file.

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; 2 findings) plus my own review (2 nits).

# Sev Finding Verdict Evidence / action
1 ⚠️ restart: a live watchdog does not prove the server wrote status, so the check could exit 1 in a fail-open caller (compare.sh restart) DISAGREE The server writes status at Server.cpp:1840; nothing before it on the startup path sleeps, retries or waits on the network, so a server still alive after wait_for_server's 60 tries has a fresh status. Locally, a server that fails to start gives the same restart status and caller behaviour as before.
2 ⚠️ README docker run flow lacks seccomp=unconfined (tests/performance/scripts/README.md) DISAGREE The image has no ENTRYPOINT/CMD, so that command never starts a server, with or without this PR. A manual stage=restart without the flag fails with setarch: failed to set personality ... Operation not permitted in the server log.
3 💡 The mismatch message names ASLR as the cause; builds with a different segment alignment also load at different bases with ASLR off (check_executable_base.py) noted, not blocking Both bases are printed on the line before. Current builds all use the same alignment.
4 💡 PR description implied all perf jobs run the check on this PR AGREE, fixed in the description Only the arm perf jobs run on a PR by default; amd needs pr-performance.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-8:20261020-151600

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. Without setarch -R every server start draws a new executable base (three runs of the right server: 5dc78ec43000, 6158d6a39000, 59547f203000); with it both servers are at 0x555555554000 on every start. Measured in the clickhouse/performance-comparison image with seccomp=unconfined.
b Root cause explained? Both servers are PIE executables; Linux adds a random offset to the load address of an ET_DYN executable unless the process has the ADDR_NO_RANDOMIZE personality flag, so the two servers and every restart get unrelated bases.
c Fix matches root cause? Yes. The flag is set at the two launchers of the measured servers only, as requested; release binaries and ASLR elsewhere are unchanged. The check enforces the property instead of assuming it.
d Test intent preserved / new tests added? Test-infrastructure change: no self-test, per the rule for CI scripts. Validated locally (rows a, e); this PR's own perf jobs run the check on CI.
e Both directions demonstrated? Yes. One server started without the prefix: Start stage fails, compare.sh exits 1 in the confirmation and profile-fallback paths, both addresses printed. With the change: equal bases, pass. The previous fallback line swallowed that exit; the new one does not.
f Fix is general across code paths? Both launchers (CHServer, compare.sh restart) and every restart caller (stage cascade, dead-server restart in run_tests, confirm_changes, get_profiles fallback); the nightly job runs performance_tests.py. The setup server in configure is not measured and is unchanged.
g Fix generalizes across inputs (params/datatypes/wrappers)? Architecture from uname -m; two different release builds give the same base; non-Linux: no prefix, no check. Missing status, dead PID or unparsable status fail the check. A server that does not start skips the check.
h Backward compatible? (maintainer-approved exception only) CI scripts only, no settings. A restart that fails to start a server returns the same status and gets the same caller handling as before (left or right server broken, every caller, old vs new script).
i Invariants and contracts preserved? restart still returns the status of its final kill -0 (left dead 0, right dead 1); a mismatch on two live servers exits. The checker reads the real server PID from status, through the shell, taskset, setarch and the watchdog fork. get_profiles keeps its own subshell so its wait does not wait for the watchdog.

Session id: cron:clickhouse-impl-slot-5:20261020-150400

@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [73da163]

Summary: ✅


AI Review

Summary

The PR disables ASLR for both measured performance-comparison servers and rejects unequal executable bases after startup and restart. Reviewed commit 73da1631b64e7753cf77b65ff977c0cd21cbc271; no actionable findings.

Missing context / blind spots
  • ⚠️ Full ClickHouse performance jobs were not reproduced locally, and completed performance-job artifacts were unavailable at review time. Eight focused checks passed for live-process mapping inspection, missing-status handling, mismatch propagation through all four shell caller paths, and shell syntax. End-to-end server evidence comes from the x86-64 validation reported in the PR; completed performance CI on both architectures would close the remaining validation gap.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 20, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @egor-click, could you review this and add the can be tested and pr-performance labels so CI runs, including the amd perf jobs? Both measured servers now start under setarch <arch> -R, and a new check fails the run when their executable bases differ, as @ Algunenano asked on #125949.

@egor-click egor-click added can be tested Allows running workflows for external contributors pr-performance Pull request with some performance improvements labels Oct 20, 2026
@Algunenano Algunenano self-assigned this Oct 20, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). label Oct 20, 2026
@Algunenano
Algunenano added this pull request to the merge queue Oct 21, 2026
Merged via the queue into ClickHouse:master with commit 1b29cde Oct 21, 2026
353 of 354 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 21, 2026
thevar1able added a commit that referenced this pull request Oct 25, 2026
…on master

The reference build from master is a dynamic PIE, which the kernel loads at
`ELF_ET_DYN_BASE` with ASLR disabled, while the static-PIE binary of this
branch has no interpreter and is mapped at the mmap base below the stack, so
`check_executable_base.py` failed the `Start` stage on every shard. Print a
warning instead of failing; make it fatal again after this is merged.

Related: #126977

Co-Authored-By: Claude Opus 5.5 <[email protected]>
GSokol pushed a commit to GSokol/ClickHouse that referenced this pull request Oct 28, 2026
…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]>
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-performance Pull request with some performance improvements 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.

4 participants