Repository navigation
Commit f127bb3
build(nix): bound how many ThinLTO links a test archive runs at once
Under cross-language ThinLTO each test binary's link optimizes the
whole program, Rust and DPDK together, and holds gigabytes while it
does. Cargo cannot see that: `-j` caps rustc processes, any of which
may be linking, so how many links overlap is left to chance -- and an
unlucky overlap is what keeps running `check/release` out of its
20 GiB. Building `tests.all` at `profile=release` with unbounded links
on 10 cores peaked at 36.2 GiB with nine ld.lld processes resident at
once. Turning down `--thinlto-jobs` only shrinks every link to make
that overlap survivable, and the links keep growing with the code.
Bound the overlap instead. rustc now links through
nix/scripts/link-slots.sh, which, when `LINK_SLOTS` is set, takes one
of that many flock slots before running the real linker and holds it
until the linker exits; `LINK_THINLTO_JOBS` gives each bounded link
more backend threads. Unset, it is transparent, and only test archives
whose profile uses `-Clinker-plugin-lto` (`release`) set them: two
slots, four threads each. They are environment rather than flags, so
they stay out of cargo's fingerprint.
Measured with line-table debug info on 8 cores, three runs each:
2 slots x 4 threads 611-616 s peak 13.2-14.1 GiB
1 slot x 8 threads 913-935 s peak 10.4-12.1 GiB
One slot puts the links on the critical path for little memory.
A link waiting for a slot still has its rustc parent resident, with
its whole compilation session; the next commit releases that.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Daniel Noland <daniel@githedgehog.com>1 parent 6c5e379 commit f127bb3
3 files changed
Lines changed: 81 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
889 | 889 | | |
890 | 890 | | |
891 | 891 | | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
892 | 909 | | |
893 | 910 | | |
894 | 911 | | |
| |||
1021 | 1038 | | |
1022 | 1039 | | |
1023 | 1040 | | |
1024 | | - | |
| 1041 | + | |
1025 | 1042 | | |
1026 | 1043 | | |
1027 | 1044 | | |
| |||
1391 | 1408 | | |
1392 | 1409 | | |
1393 | 1410 | | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
1394 | 1428 | | |
1395 | 1429 | | |
1396 | 1430 | | |
| |||
1401 | 1435 | | |
1402 | 1436 | | |
1403 | 1437 | | |
| 1438 | + | |
1404 | 1439 | | |
1405 | 1440 | | |
1406 | 1441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
| 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 | + | |
0 commit comments