Repository navigation
Description
Summary
Add a frozen Bevy link corpus to the benchmark harness: compile Bevy once per platform, freeze the resulting linker inputs (object files + .rlibs + native libs) and the captured final link command, then replay only the link on every benchmark iteration. This removes compilation from the measurement loop — each iteration times objects → linker → executable, nothing else — and gives a large, realistic Rust workload (link.exe vs lld-link vs rust-lld vs mold vs reld) without waiting on cargo build each run.
Bevy is a good corpus: big dependency graph, lots of crates/codegen units, heavy debug info — a painful, representative Rust dev link.
Motivation
Today reld-bench (in reld-testkit) drives synthetic scenarios. A frozen Bevy corpus gives a real-world heavy link that is:
- Stable — same inputs every run, so linker-vs-linker deltas aren't polluted by recompilation variance.
- Fast to iterate — no compile per iteration; only the link is replayed (50–100×).
- Representative — matches the "200th rebuild of the day" dev-loop link reld exists to optimize.
How to build the corpus (compiler settings)
Build Bevy once with a profile tuned to produce a realistic, link-heavy workload — not an optimized/LTO build (we want to time linking, not whole-program optimization):
[profile.linkbench]
inherits = "dev"
opt-level = 0 # dev-style codegen, don't spend time optimizing
debug = 2 # full debug info -> much heavier, representative link
incremental = false # frozen inputs; no incremental artifacts changing the experiment
lto = false # time object-files -> linker, NOT bitcode -> WPO -> codegen -> link
codegen-units = 256 # high fragmentation -> more independent objects -> more linker work
# split-debuginfo = "off" # (where applicable) keep debuginfo in the objectsThen capture the actual final link invocation (not a hand-rolled --emit=obj, because the real link feeds main-crate objects + .rlibs + native/system libs + build-script flags):
cargo build --profile linkbench # build once
cargo rustc --profile linkbench -- --print link-args # capture the exact linker command
rustc --print link-args emits the full linker executable + argument list. Freeze all referenced inputs (the main.*.o objects, lib*-*.rlib archives, and native libs) and the command, then replay it per iteration with the linker binary swapped:
hyperfine --prepare 'rm -f bevy_app' './link-command.sh' # per linker: link.exe / lld-link / rust-lld / mold / reld
Notes:
- mold consumes
.rlibfine — an.rlibis an archive of native objects (+ Rust metadata the linker ignores); by final-link time rustc has already selected the participating.rlibs. Cleanest on Linux/ELF. - Windows/MSVC
.rlib/link.exehandling is a different ecosystem — scope the mold leg to Linux; uselink.exe/lld-linkon MSVC. - Freeze per platform (
x86_64-linux,x86_64-pc-windows-msvc,aarch64-apple-darwin), since objects and the link command are platform-specific.
Proposal
- A prep step that builds Bevy (pinned version) once per platform with the
linkbenchprofile and captures--print link-args. - Freeze the linker inputs + normalized link command as a versioned corpus (checked-in manifest + cached/published blobs, keyed on the pinned Bevy version + platform — a natural fit for the setup-soldr side-cache in feat: cache arbitrary extra folders via glob-filtered, zstd side cache (auto-inflate) setup-soldr#463).
reld-benchgains a "replay a frozen link N times, swapping the linker" mode that runs the corpus and reports per-linker medians alongside the existing scenarios.- Corpus refresh is explicit (bump the pinned Bevy version), not silent.
Open questions
- Pin a specific Bevy version (frozen) — which release? Pin it and its
Cargo.lockso the corpus is reproducible. - Where to store the frozen blobs — Git LFS, a release asset, or a cache channel (ties into setup-soldr#463 / soldr toolchain publishing)? Objects + rlibs for a Bevy build are large.
- Link-command normalization across machines — the captured command has absolute paths and hashed filenames; needs rewriting to the frozen corpus dir at replay time.
- Cross-platform capture —
--print link-argsmust be captured on each target's native runner (or via the soldr cross toolchain once feat: 'soldr cc --target x86_64-linux-gnu.2.17' zig-style cross compiler + published soldr-toolchain (build tools ourselves, no CC hacks) soldr#2335 lands).
Acceptance criteria
- Bevy (pinned version) is built once per platform with a documented link-heavy, non-LTO profile; the final link command is captured via
rustc --print link-args. - The linker inputs + command are frozen into a versioned, reproducible corpus (keyed on Bevy version + platform).
-
reld-benchcan replay the frozen link N times per linker (link.exe/lld-link/rust-lld/mold/reld as available) with no recompilation between iterations, reporting per-linker medians. - Corpus refresh is explicit (version bump), and the mold leg is scoped to Linux.
- RED -> GREEN: a benchmark run that currently recompiles (or lacks a Bevy corpus), then one that links the frozen corpus repeatedly with zero compile time in the measured loop.
Decisions
- Priority: P2. Directly improves benchmark realism and iteration speed for the core linker-vs-linker comparison.
- No LTO, full debuginfo, high codegen-units — deliberately maximizes the linking workload rather than optimization/codegen, so the measurement isolates the linker.
- Replay the captured real link, not a synthetic
--emit=obj, so the corpus reflects an actual Rust final link (objects + rlibs + native/system libs).
Activity
zackees commentedon Aug 7, 2026
Tracked under meta #57 (frozen linker-object benchmark assets — storage/publishing/consumption + manifest.json).
feat(bench): frozen linker-object asset pipeline (manifest + replay) (#…
zackees commentedon Aug 24, 2026
Superseded by #70 and delivered in #71. We intentionally adopted one small idiomatic Rust workspace instead of a Bevy-scale frozen corpus: inputs are compiled once per platform/configuration, the target-correct final link is captured and replayed, and only linking is timed. The merged implementation and published evidence satisfy the useful compile-once/link-only objective without the storage and maintenance burden proposed here.