Skip to content

Report and gate the relocation headroom of Build (amd_msan) - #126736

Merged
Algunenano merged 4 commits into
ClickHouse:masterfrom
groeneai:amd-msan-relocation-headroom-check
Oct 20, 2026
Merged

Algunenano merged 4 commits into
ClickHouse:masterfrom
groeneai:amd-msan-relocation-headroom-check

Conversation

@groeneai

@groeneai groeneai commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #126314

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

...

Description

Build (amd_msan) links x86-64 small-code-model binaries close to the 2 GiB reach of 32-bit PC-relative references, and lld adds no range thunks on x86-64, so a size regression shows up only when the link fails with relocation R_X86_64_PC32 out of range and all MSan tests are lost (#126314). As asked in #126314 (comment), this adds a Relocation headroom row to Build (amd_msan).

After the link, it reads the section headers of programs/clickhouse and src/unit_tests_dbms and reports the MiB left of 2 GiB for three spans, with the change vs the nearest master commit that reported them:

  • start of image to end of code (code references the ELF header as __ehdr_start, so this span starts at address 0, not at .rodata);
  • start of code to end of data;
  • unwind tables to end of .data (personality and type-info slots).

On master 74d99c6: 181.93 / 281.69 / 309.70 MiB for clickhouse, 187.33 / 273.78 / 301.48 for unit_tests_dbms.

A pull request fails the row when a span decreased by more than 5 MiB, unless it has the ci-relocation-headroom-ok label (read when the workflow starts: push or "Re-run all jobs"), and errors on a failed master lookup. The job is then red but non-blocking, so the MSan tests still run. Below 64 MiB (about 12 days of master growth; it would have fired on 10-16) every run adds a workflow warning, shown in the CI Infrastructure Messages status. The numbers are in the row's info, so CIDB keeps the history. Other x86-64 sanitizer builds have 2-4x the headroom and are not checked.

Validated locally on master artifacts: the parser matches llvm-readelf -SW; this PR's build on bdca15a reports exactly the bytes of that master build (delta 0); the gate, the label, the warning and the baseline round trip behave as described.


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

Version info

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

groeneai and others added 2 commits October 19, 2026 13:45
The amd_msan binaries are x86-64 small-code-model images close to the 2 GiB
reach of 32-bit PC-relative references, and lld adds no range thunks on
x86-64, so today the first sign of a size regression is a failed link
(`relocation R_X86_64_PC32 out of range`), which drops every MSan test.

Add a `Relocation headroom` sub-result to `Build (amd_msan)`, computed after
the link from the section header table of `programs/clickhouse` and
`src/unit_tests_dbms` (pure Python, no tool needed in the image): the bytes
left of 2 GiB for `.rodata` to the end of code, code to the end of data,
`.eh_frame_hdr` to code, and the code span itself, plus the change vs the
nearest master commit of the run's master chain that reported them (read
from its public job result JSON). The row fails below 64 MiB, about two
weeks of master growth at the measured 5.24 MiB/day; when it is the only
failing row the job completes as non-blocking, so artifacts are uploaded and
the MSan tests still run. A decrease of 10 MiB or more adds a workflow
warning. The numbers are in the row's `info` (CI DB history) and `ext`.

Related: ClickHouse#126314

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code references the ELF header (`__ehdr_start`, address 0, from
`StackTrace::tryResolveAddress`). In `unit_tests_dbms` that reference
already spans 1794.76 MiB, only 37.66 MiB less than the span from `.rodata`
to the end of code, and where it lands depends on link order, so the first
span now starts at the image start instead of `.rodata`. The code span and
the `.eh_frame_hdr` span are covered by it and can never be the smallest, so
they are removed. The unwind tables' pointers to the personality and
type-info slots in `.data` get their own span.

Values on master 74d99c6 (MiB left of 2 GiB, `programs/clickhouse` /
`src/unit_tests_dbms`): start of image to end of code 181.93 / 187.33,
start of code to end of data 281.69 / 273.78, unwind tables to end of
`.data` 309.70 / 301.48.

Related: ClickHouse#126314

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; 3 findings; 1 full pass).

# Sev Finding Verdict Evidence / action
1 ⚠️ The non-blocking flag survives a later artifact-upload failure, so MSan jobs could run without their artifacts (build_clickhouse.py headroom_only) DISAGREE A dependent's pre-run fails on any missing required S3 artifact before its command runs (ci/praktika/runner.py:441-463, :1523-1534), so no test runs without its binary; the only change is ERROR instead of DROPPED on an already red run.
2 ⚠️ Trying only 10 master commits can miss the nearest baseline and hide the 10 MiB warning (relocation_headroom.py master_baseline) DISAGREE CIDB, last 4 days: 179 master commits, the longest run without a fresh Build (amd_msan) result is 3. A miss prints no master baseline; the numbers and the 64 MiB gate are unaffected.
3 💡 Dates in the description lack the year DISAGREE All dates fall in the three weeks of #126314; no other reading is possible.

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

Session id: cron:clickhouse-review-slot-8:20261019-152000

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @maxknv, could you review this and add the can be tested label so CI runs? After the link, Build (amd_msan) reads the section headers of clickhouse and unit_tests_dbms, reports the MiB left of the 2 GiB PC32 reach for three spans with the delta vs master, and fails below 64 MiB; when that row is the only failure the job completes with do_not_block_pipeline_on_failure, so the MSan tests still run.

@clickhouse-gh

clickhouse-gh Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d914869]

Summary: ✅


AI Review

Summary

The PR reports relocation headroom for both amd_msan binaries, fails PR comparisons that consume more than 5 MiB without an override, and warns below 64 MiB while preserving downstream tests. Request changes: the label-dependent cache case is fixed, but a cached success obtained without a baseline can still bypass a later failing comparison.

Findings

⚠️ Majors

  • [P2] Re-evaluate baseline-free successes before reusing the verdict. ci/jobs/scripts/relocation_headroom.py:142, propagated at ci/jobs/build_clickhouse.py:726. [dismissed by author -- https://github.com/Report and gate the relocation headroom of Build (amd_msan) #126736#discussion_r4317246076]

    A PR targeting master can finish while its master baseline is still building: check returns OK with no baseline and leaves the result cacheable. After the baseline appears, a documentation-only push retains the build digest, so CacheRunnerHooks.configure reuses that success without running the comparison. A focused probe reproduced an initial cached OK, a current FAIL for a 6 MiB decrease, and reuse of the old success without the override label.

    The author deliberately retains baseline-free caching to avoid rebuilding release-branch PRs; that does not justify skipping a newly available comparison for PRs targeting master. At minimum, prevent baseline-free successes on mainline PRs from satisfying later runs. Alternatively, cache the binary measurements and evaluate the gate separately for each workflow.

Final Verdict

Status: ⚠️ Request changes. Close the remaining baseline-availability cache bypass. Keep the release-branch exception explicit if needed.

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-ci-infrastructure CI/CD pipelines (GitHub Actions, CI scripts, runners). labels Oct 19, 2026
@Algunenano Algunenano self-assigned this Oct 19, 2026

@Algunenano Algunenano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai I feel this is correct but the direction of the 2 checks are wrong:

  • We should fail a PR check (unless manually overwritten) when the headroom was reduced by over 5MB.
  • We should warn visibly in PRs when we are under 64MB.

@Algunenano Algunenano added the can be tested Allows running workflows for external contributors label Oct 19, 2026
As asked in review: a pull request now fails the `Relocation headroom`
row when any span decreased by more than 5 MiB vs the master baseline,
unless it has the `ci-relocation-headroom-ok` label; the labels are read
by `Config Workflow`, so a push or "Re-run all jobs" applies it. Master
runs only report the decrease.

Below 64 MiB every run adds a workflow warning, shown in the
`CI Infrastructure Messages` status and on the report page, instead of
failing.

The baseline line says how many commits it is older than the run's master
parent, since master changes in between count as the pull request's.
A PR build and the master build of its parent have identical spans
(measured on bdca15a: 0 bytes difference in all six), so an
unchanged binary has a delta of 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done in b9a8012:

  • In a PR, the row fails when a span of clickhouse or unit_tests_dbms decreased by more than 5 MiB vs master, unless the PR has the ci-relocation-headroom-ok label (labels are read when the workflow starts, so it applies on a push or "Re-run all jobs"). The label does not exist yet and I can't create labels: could you create it, or tell me which name you prefer? Master runs only report the decrease.
  • Below 64 MiB, every run adds a workflow warning instead of failing: it shows as the CI Infrastructure Messages status in the PR checks and at the top of the report.

The delta of an unchanged binary is exactly 0: on this PR, Build (amd_msan) on master bdca15a reported the same bytes in all six spans as the master build of bdca15a. If the nearest master commit with a result is older than the PR's master parent, the row says by how many commits (master grew 0.1 MiB in the 7 hours from 74d99c6 to bdca15a). With no master result at all (until this is merged), the row passes and says so.

@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Oct 19, 2026
Comment thread ci/jobs/build_clickhouse.py Resolved
Comment thread ci/jobs/scripts/relocation_headroom.py Resolved
…r reuse a label-allowed success

Two ways a pull request could pass the 5 MiB decrease gate without a real verdict:

- Every master lookup error was taken as "no report", so an S3 5xx, a timeout or an
  undecodable result JSON left the run without a baseline and the row passed. Only a
  missing report (403 from the report bucket, which is not listable, or 404) now means
  "no baseline"; when no candidate has a report and a lookup failed, a PR run reports
  ERROR and asks for a re-run. The job still completes with
  do_not_block_pipeline_on_failure, so artifacts are uploaded and the MSan tests run.
  Master runs only report, as before.
- A success that the `ci-relocation-headroom-ok` label allowed was cached under the
  build digest, which does not include labels: after removing the label, a later
  commit with the same digest reused the success. Such a row now sets do_not_cache,
  the flag praktika already offers for verdicts that depend on state the digest
  does not capture. A success without a master baseline stays cacheable: for a PR
  into a release branch the baseline is never available, so not caching it would
  only rebuild the binary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done in d914869: a failed master lookup now makes a pull request's row an error instead of a pass, and a success allowed by the label is not cached.

@clickhouse-gh

clickhouse-gh Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing d91486933 with master 8c0552d4c (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of a43327cde; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

6 translation units recompiled, 4 s compile time in total, 6 of them have a recent master baseline.

Job report

@Algunenano
Algunenano added this pull request to the merge queue Oct 20, 2026
Merged via the queue into ClickHouse:master with commit 0512a60 Oct 20, 2026
178 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 Oct 20, 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). manual approve Manual approve required to run CI 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