Repository navigation
Commit 7dd5782
build(nix): link a test archive's binaries in a rustc of their own
With links bounded, the memory left at the peak is mostly rustc: a
link waiting for its slot is a rustc process that has finished
compiling and is waiting on its linker, with its whole compilation
session -- a gigabyte or two -- still resident. Cargo's `-j` keeps that
to one per job slot, but the slots are spent holding memory nobody
uses.
rustc can stop after writing its objects (`-Zno-link`, which leaves an
`.rlink` describing the link) and do the link in a separate invocation
(`-Zlink-only`). nix/scripts/rustc-split-link.sh, a `RUSTC_WRAPPER`, does
that for the crates that link (binaries and test harnesses), so the
process waiting on a slot is a small one. Everything else passes
straight through. It is set where links are bounded, the
`-Clinker-plugin-lto` test archives; `RUSTC_WRAPPER` is not part of
cargo's fingerprint, so the dependency artifacts built without it are
reused (the archive compiled the same 69 crates either way).
Building `tests.all` at `profile=release`, two link slots, 8 cores:
peak 13.2-14.1 -> 11.3 GiB, mean 6.5-6.8 -> 4.2 GiB, 611-616 -> 620 s.
The split archive's suite passed (3074 of 3075; the one failure, a
Unix socket path longer than SUN_LEN under a long worktree path, fails
the same way without the split).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>1 parent f127bb3 commit 7dd5782
2 files changed
Lines changed: 78 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
906 | 906 | | |
907 | 907 | | |
908 | 908 | | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
909 | 916 | | |
910 | 917 | | |
911 | 918 | | |
| |||
1419 | 1426 | | |
1420 | 1427 | | |
1421 | 1428 | | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
1422 | 1435 | | |
1423 | 1436 | | |
1424 | 1437 | | |
1425 | 1438 | | |
1426 | 1439 | | |
| 1440 | + | |
1427 | 1441 | | |
1428 | 1442 | | |
1429 | 1443 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
0 commit comments