Repository navigation
fix: make the jemalloc build independent of the build machine's CPU - #12033
Merged
Merged
Conversation
jemalloc's configure takes LG_VADDR (the number of significant virtual address bits) from CPUID leaf 0x80000008 of the machine that runs the build, and LG_PAGE and LG_HUGEPAGE from sysconf(_SC_PAGESIZE) and /proc/meminfo. The values are compiled into libjemalloc.a, which tikv-jemalloc-sys bundles into its rlib, so the replica, the IC-OS images and the publish bundles depend on the build machine's CPU: 48 bits on CPUs without 5-level paging, 57 on CPUs with it. The Namespace RBE workers report 57, the dind runners 48. Pin the three values to the ones the released artifacts were built with. The archive stays byte-identical to the current one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the jemalloc configuration change.
No open issues 🎉
What changed in this PR
This PR removes build-machine-dependent jemalloc configuration, supporting reproducible release artifacts and the move to Namespace remote builds while preserving the configuration used by existing releases.
Changes:
- Pins virtual-address width, page size, and huge-page size to
48,12, and21. - Documents the source of the variability and why these values are appropriate for the x86-64 Linux target.
| File | Description |
|---|---|
third_party/BUILD.jemalloc.bazel |
Pins three jemalloc configure options and documents their reproducibility and safety rationale. |
Review effort: Balanced
basvandijk
marked this pull request as ready for review
November 6, 2026 10:19
basvandijk
added a commit
that referenced
this pull request
Nov 6, 2026
Picks up #12033 (the jemalloc pin), so that the shadow RBE build-determinism job can confirm the fix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
basvandijk
added a commit
that referenced
this pull request
Nov 6, 2026
With #12033 (the jemalloc pin) merged in, the shadow job compares the 34,266 artifacts it shares with build-ic without mismatches. Make it fail on mismatches like ci-main's Build Determinism job instead of only warning, so that a regression shows up as a red run during the soak. A missing execution log is not a mismatch and still passes: the RBE evaluation may fail before its build step uploads one (with a warning), and without build-ic's log ci-main's job doesn't compare either. Co-Authored-By: Claude Opus 5.5 <[email protected]>
basvandijk
added a commit
that referenced
this pull request
Nov 6, 2026
…e evaluation job (#12032) ## Why `bazel-test-all` (ci-main.yml, dind-large) is to be replaced by the implementation of `bazel-test-all-rbe` (ci-rbe-evaluation.yml: Namespace runner + Bazel Remote Execution, `_local` system-tests), as the first step of moving CI off the self-hosted dind runners. Three things the required job does are not yet done by the evaluation job and can only be validated by running them, so this PR makes the still non-blocking evaluation job rehearse them on every master push before the switch: * the `execlogs-bazel-build` execution log that `build-determinism` compares with `build-ic`'s; * the `Upload artifacts` step (`bazel run --check_up_to_date //:upload-artifacts`) on a Namespace runner, under Build-without-the-Bytes and through the Namespace bazel wrapper, including AWS OIDC role assumption from a Namespace container job; * the `_local` variants of the system-tests listed in `PULL_REQUEST_BAZEL_TARGETS`, which the evaluation job silently drops today (it excludes `farm_system_test` *after* the explicit targets are added). The required jobs keep their behaviour; only the mechanics of the artifact upload change (see below). ## What * **`.github/actions/upload-execlogs`** (new): the execlog2csv install/convert/upload steps of `.github/actions/bazel`, as a composite that both bazel actions call, so the execlog2csv pins and the list of known non-reproducible targets live in one place. * **`.github/actions/bazel-namespace`**: new `execlogs-artifact-name` input (the wrapper writes `--execution_log_compact_file` for build and test when it is set); the wrapper no longer writes a BEP file/profile for `bazel run` (a BEP records the client environment, and the artifact upload is a `bazel run`); the OIDC token request variables are unset before `run`, as in the dind action. * **`.github/actions/upload-artifacts`**: runner-agnostic (`bazel-action: bazel | bazel-namespace`) and credentials only where rclone runs. The uploader is built with `bazel run --script_path` (new `build-uploader.sh`; under Build-without-the-Bytes `bazel run --check_up_to_date` downloads the target's outputs and runfiles by the digests the build step recorded, and on Namespace it runs with `--experimental_remote_cache_eviction_retries=0`, so a lost blob fails on that output instead of a retry that re-resolves everything through fresh remote cache lookups) and run by a separate step, the only one whose environment holds the AWS/Cloudflare credentials, now passed as inputs instead of step `env`. Neither the BEP files nor Namespace's Build Event Service (to which `nsc bazel setup` streams every bazel command's events, client environment included) see them anymore. This relies on rules_python 2.4.6 (#12041): with 1.9.0, every `<name>.build_data.txt` had constant metadata, which bazel can only validate on disk, so under Build-without-the-Bytes every later command re-ran those `PyWriteBuildData` actions (21 in a Namespace test step; two are tools in the upload closure, which would have failed `--check_up_to_date`). `ci/src/artifacts/upload.bzl`: the generated run script gets its shebang on the first line, which the `exec` of the `--script_path` script needs (`bazel run` hid this by running it through bash). * **`ci-main.yml`**: the two upload call sites use the new inputs (`bazel-test-all` also passes its build step's options to `bazel run`); `build-determinism` prints how many artifacts the comparison covers and warns outside PRs when the cache side misses more than half of build-ic's artifacts (a build that bazel retried after a remote-cache eviction has a partial execution log). * **`ci-rbe-evaluation.yml`**: uploads `execlogs-bazel-build-rbe`; on release builds (master pushes) runs `Configure AWS credentials` (role assumption only: `output-credentials: false`, the session never leaves that step) and a `DRY_RUN=1` artifact upload with placeholder credentials and `--check_up_to_date` through the Namespace wrapper (`environment: upload-artifacts`, `id-token: write`; both steps `continue-on-error`). * **`ci-kickoff.yml`**: the evaluation also runs on dfinity/ic-private PRs, since the Namespace GitHub App was given access to that repository today (so that `bazel-test-all` needs no repository gate after the switch; note that ic-private PR code, undisclosed hotfixes included, then builds on Namespace and shares the workspace's RBE cache with public builds, like it shares DFINITY's cache today); temporary `rbe-build-determinism` shadow job comparing `execlogs-bazel-build-rbe` with `execlogs-build-ic` (fails on mismatches like ci-main's job; not a required check, so it doesn't block merging; a missing execution log is not a mismatch). * **`PULL_REQUEST_BAZEL_TARGETS`**: lists the `_local` variant next to every `_farm`/`_farm_colocate` entry (24 lines; the dind job drops the former, the evaluation job the latter, so this changes nothing for CI Main and makes the evaluation job run on PRs exactly the tests that become blocking). The two nested `*_upgrade_from_latest_release_to_current_local` entries are runnable since #12029. * **`ci/scripts/targets.py`**: `check` honours `--exclude_tags` like `test` does (CI doesn't pass it yet; the switch will pass `--exclude_tags=farm_system_test`, which then rejects `_farm*` entries) and its hint no longer suggests `_colocate`. ## Not in this PR The switch itself (rewriting `bazel-test-all`, deleting the evaluation workflow and the shadow job, `_local`-only `PULL_REQUEST_BAZEL_TARGETS`, githubstats job names) follows after a soak of the rehearsal: shadow determinism `No mismatches` with ~34k joined rows, green dry-run uploads with `--check_up_to_date`, green OIDC step, `_local` flakiness not worse than dind. ## Testing * `build-uploader.sh` + the generated script, locally with `--config=local` and `//:artifact-uploader`: `--check_up_to_date` after a build reports `0 total actions`, the dry run prints `VERSION: 0000…` and one well-formed `<sha256> ic/<version>/…` manifest line per file. This dry run is what found the shebang problem in `upload.bzl` (the uploader died under `/bin/sh` with `set: Illegal option -o pipefail`). * `ci/scripts/targets.py check` passes with the dual listing (all 48 system-test labels are non-manual); `check --exclude_tags=farm_system_test` fails on exactly the 24 `_farm*` lines with the new hint. * `bazel run //pre-commit:ruff-check`, `//pre-commit:shfmt-check`, `//:buildifier`; all changed YAML parses. * The Namespace upload path (`bazel run --check_up_to_date` without eviction retries) follows from reading the Bazel 9.2.0 sources and the profiles of a Namespace job, reviewed adversarially; `build-uploader.sh` was exercised with a stub bazel for every exit code. It first runs for real in the rehearsal on the first master push after merge. * This PR touches `.github/*`, so its own CI builds and tests `//...` on both jobs; the evaluation job shows the `execlogs-bazel-build-rbe` artifact and the shadow job's comparison. The upload/OIDC rehearsal and the dind upload mechanics only run on release builds: first master push after merge. ## First rehearsal result (this PR's run 42102800890) Both `bazel-test-all` jobs of this run built `//...` for the same commit, so their execution logs can be compared directly: **396 of 62,164 shared artifacts differ between dind and RBE** (the RBE log is complete: 62,169 rows, all with digests). Against build-ic, the shadow job finds 76 mismatches in 34,266 artifacts, all downstream of jemalloc, while the dind `Build Determinism` is clean. **Root cause of the release-relevant part: jemalloc's configure reads the CPU's virtual-address width.** `@@+http_archive+jemalloc` (`third_party/BUILD.jemalloc.bazel`) runs jemalloc 5.3.0's configure on the machine that executes the action. On x86-64 it takes `LG_VADDR` from CPUID leaf 0x80000008, which sizes jemalloc's radix tree, so the compiled code of `libjemalloc.a` changes with it. Reproduced locally: the unmodified build gives the dind digest (`3c2559eb…`), the same build with `--with-lg-vaddr=57` gives the RBE digest (`b8f113b5…`) exactly, so the Namespace workers report 57 bits where the dind machines report 48. The `tikv-jemalloc-sys` rlib only bundles that archive (`JEMALLOC_OVERRIDE`; its `build.rs` returns before it reads `JEMALLOC_SYS_WITH_LG_*`), and the replica, `pocket-ic-server`, `ic-boundary`, `ic-gateway`, the GuestOS/SetupOS images and the publish bundles inherit it. Fixed by #12033, which pins `--with-lg-vaddr=48 --with-lg-page=12 --with-lg-hugepage=21`. That build gives the dind digest again, so the shipped binaries did not change. The other leaves are outside build-ic's closure (no shipped artifact contains them) and do not block the switch: OpenSSL's `libcrypto.a` (build date and sandbox path), the `libsqlite3-sys` build-script environment (absolute path compiled into the build script) and the Go SDK `builder` (records `CGO_ENABLED`). With #12033 merged into this branch, the shadow job compares the same 34,266 artifacts with **no mismatches** (run of 27fb17f), so it now fails on mismatches like ci-main's `Build Determinism`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
dfinityianblenke
added a commit
that referenced
this pull request
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
jemalloc's
configurereads three values from the machine that runs the build and compiles them intolibjemalloc.a(@jemalloc//:jemalloc_privateinthird_party/BUILD.jemalloc.bazel):LG_VADDR, the number of significant virtual address bits, from CPUID leaf 0x80000008: 48 on CPUs without5-level paging, 57 on CPUs with it (e.g. AMD EPYC Genoa, Intel Xeon since Ice Lake-SP). It sizes jemalloc's
radix tree (
include/jemalloc/internal/rtree.h: height 2 for 48 bits, 3 for 57), so the compiled code differs.LG_PAGEfromsysconf(_SC_PAGESIZE)andLG_HUGEPAGEfromHugepagesizein/proc/meminfo.tikv-jemalloc-sys bundles this archive into its rlib (
JEMALLOC_OVERRIDEinbazel/rust.MODULE.bazel), sothe replica,
ic-boundary,pocket-ic-server,ic-gateway, the GuestOS/SetupOS images and the publishbundles depend on the CPU of the machine that ran jemalloc's configure.
This PR pins the three values to the ones the released artifacts were built with:
--with-lg-vaddr=48 --with-lg-page=12 --with-lg-hugepage=21. After it, every machine builds the same archive.How it was found and verified
The Namespace RBE rehearsal in #12032 builds the same commit as the dind runners. Its shadow
build-determinism job finds 76 differing artifacts among the 34,266 that build-ic builds, all downstream of
libjemalloc.a. Rebuilding the archive in the dev container (--config=local) with different configureoptions reproduces both sides byte for byte:
configure_optionslibjemalloc.alibjemalloc_pic.a3c2559eb…d9e57b63…--with-lg-vaddr=57b8f113b5…8590f912…3c2559eb…d9e57b63…So the Namespace workers' CPUs report 57 bits where the dind machines report 48, and nothing else differs.
With this PR the archive is byte-identical to today's, so the released binaries do not change. (The
huntscript of the fix-build-determinism skill cannot show this kind of bug: both of its builds run on the same
CPU.)
Why it matters
bazel-test-allbuilds and uploads the release artifacts. On Namespace RBE itwould change the replica and the IC-OS images, turn
build-determinismred, and make a hotfix re-upload(
rclone --immutable) fail. This PR removes that blocker.ci/scripts/repro-checkrebuilds the IC-OS images with./ci/container/build-ic.sh,i.e.
--config=local. A verifier whose CPU reports 57 virtual address bits therefore builds a differentreplica than the one on the CDN and cannot reproduce the release. With the pins it builds the CDN's bytes.
Safety
LG_VADDR=48is what production runs today. It stays correct on machines with 5-level paging: Linux mapsuser memory above 47 bits only when
mmapgets a hint address above them(kernel docs), and jemalloc's hints only
extend its own mappings. 4 KiB pages and 2 MiB (transparent) huge pages are the x86-64 sizes, and this archive
is only used for
x86_64-unknown-linux-gnu. jemalloc documents all three options inINSTALL.md, so no patch is needed.
Setting
JEMALLOC_SYS_WITH_LG_*on the tikv-jemalloc-sys crate would not help: withJEMALLOC_OVERRIDEset,its
build.rsreturns before it reads them.🤖 Generated with Claude Code