perf(builder): the shipped longshot-builder links with thin LTO, so a release builds it 2.5 times faster #2552

Merged
HumanBean merged 1 commit from HumanBean/Longshot:push-qmxpqzpkryuo into main 2026-11-25 18:06:49 +00:00
Owner

Summary

The longshot-builder a release ships was linked with fat LTO and one codegen unit. That final step runs on one core: 155 s on this PC (Ryzen 9 7900X), and about 20 minutes on the server's release runner (2 shared cores), which builds every release since #2538. With thin LTO and 16 codegen units, the builder compiles in 63 s here. A player's game build takes the same time with either binary.

Changed: Cargo.toml's dist profile (lto = "thin", codegen-units = 16), and the two places that described it (scripts/longshot_builder.py's docstring, a row of docs/dev/reference/build.md).

Testing

Tested: Linux (CachyOS, Ryzen 9 7900X, RTX 3090), one build-mode queue job per step: the builder compiled with each profile, then a fully cold game build with each binary (a fresh LONGSHOT_CACHE, work folder and store, from the .nup, --no-prepare-shaders). Both game builds finished.

Still to test:

  • The next release: the Linux and Windows dist builds finish faster on the server's runner.

Measurements

Verdict: the release builds the builder 2.5 times faster; players' game builds are unchanged; the download grows by 8.8 MB.

Setup: Linux, Ryzen 9 7900X; one run each.

Before: main @ 8f730075 (fat LTO) After: this PR @ 82f893a6 (thin LTO)
The builder's compile (cargo build --profile dist, cold target) 155 s 63 s
The program 25.9 MB 34.7 MB
A cold game build with it 2:15 (lift 0:05, compile 2:08) 2:14 (lift 0:05, compile 2:07)

Risks

The players' download is 8.8 MB bigger. Code across crates is inlined a little less, which could make the lift slower. The lift took 5 s either way here, so a few percent of it doesn't show. Revert to go back to fat LTO.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says. (the game was built with it twice, not played: the profile changes the builder, not the game)
  • mise run test passes (any failure that also fails on main is named). (not run on this PC; this PR's CI runs it)
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary The longshot-builder a release ships was linked with fat LTO and one codegen unit. That final step runs on one core: 155 s on this PC (Ryzen 9 7900X), and about 20 minutes on the server's release runner (2 shared cores), which builds every release since #2538. With thin LTO and 16 codegen units, the builder compiles in 63 s here. A player's game build takes the same time with either binary. Changed: `Cargo.toml`'s `dist` profile (`lto = "thin"`, `codegen-units = 16`), and the two places that described it (`scripts/longshot_builder.py`'s docstring, a row of `docs/dev/reference/build.md`). ## Testing **Tested:** Linux (CachyOS, Ryzen 9 7900X, RTX 3090), one build-mode queue job per step: the builder compiled with each profile, then a fully cold game build with each binary (a fresh `LONGSHOT_CACHE`, work folder and store, from the `.nup`, `--no-prepare-shaders`). Both game builds finished. **Still to test:** - The next release: the Linux and Windows `dist` builds finish faster on the server's runner. ## Measurements **Verdict:** the release builds the builder 2.5 times faster; players' game builds are unchanged; the download grows by 8.8 MB. Setup: Linux, Ryzen 9 7900X; one run each. | | Before: main @ 8f730075 (fat LTO) | After: this PR @ 82f893a6 (thin LTO) | |---|---|---| | The builder's compile (`cargo build --profile dist`, cold target) | 155 s | 63 s | | The program | 25.9 MB | 34.7 MB | | A cold game build with it | 2:15 (lift 0:05, compile 2:08) | 2:14 (lift 0:05, compile 2:07) | ## Risks The players' download is 8.8 MB bigger. Code across crates is inlined a little less, which could make the lift slower. The lift took 5 s either way here, so a few percent of it doesn't show. Revert to go back to fat LTO. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. (the game was built with it twice, not played: the profile changes the builder, not the game) - [ ] `mise run test` passes (any failure that also fails on `main` is named). (not run on this PC; this PR's CI runs it) - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
perf(builder): the shipped longshot-builder links with thin LTO, so a release builds it 2.5 times faster
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
Website / Website preview, build (pull_request_target) Has been skipped
Website / Website preview, upload (pull_request_target) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 13s
CI / What the change needs (pull_request) Successful in 15s
CI / Workflow lint (actionlint) (pull_request) Successful in 29s
Guide screenshots / Guide images and local UI source review (pull_request) Successful in 29s
Third-party parts / As their notes say (pull_request) Successful in 34s
CI / Lint (pre-commit, ShellCheck) (pull_request) Failing after 36s
CI / Game-free checks (run_all.py, part 2/4) (pull_request) Failing after 4m0s
PR description / Description follows the template (pull_request_target) Failing after 29s
CI / Game-free checks (run_all.py, part 3/4) (pull_request) Failing after 6m50s
CI / Game-free checks (run_all.py, part 1/4) (pull_request) Failing after 7m5s
CI / Rust (rustfmt, clippy, cargo test) (pull_request) Successful in 1m20s
CI / Game-free checks (run_all.py, part 4/4) (pull_request) Failing after 4m38s
CI / longshot-builder end to end (synthetic game) (pull_request) Successful in 1m54s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Successful in 1m1s
CI / Website build and checks (pull_request) Failing after 3m1s
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Successful in 7m34s
82f893a6a3
The dist profile's fat LTO with one codegen unit ran on one core: 155 s on a 7900X, about 20 min on the server's
release runner, which now builds every release. Thin LTO with 16 units: 63 s here. A cold game build takes the same
time with either (2:14 against 2:15, the lift 5 s on both). The program grows from 25.9 to 34.7 MB.

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

Possibly related, for context:

  • PR #2550 WIP: fix(release): the release builds get 3 hours, so the server's runner finishes them — Related release-runner timeout; explicitly identifies thin LTO as an alternative to keep builds under an hour.
Possibly related, for context: - PR #2550 WIP: fix(release): the release builds get 3 hours, so the server's runner finishes them — Related release-runner timeout; explicitly identifies thin LTO as an alternative to keep builds under an hour.
HumanBean changed title from WIP: perf(builder): the shipped longshot-builder links with thin LTO, so a release builds it 2.5 times faster to perf(builder): the shipped longshot-builder links with thin LTO, so a release builds it 2.5 times faster 2026-11-25 18:06:28 +00:00
HumanBean deleted branch push-qmxpqzpkryuo 2026-11-25 18:06:53 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2552
No description provided.