Build: a ship profile with fat LTO and one codegen unit #2426
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2426
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2426"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Halfect on GitHub · 2026-11-25 13:15 UTC · original
Halfect:build/ship-lto-profile→main· +12 −0 · 2 files · 1 commits · openWhat
The build half of #2384: a
[profile.ship]that inheritsreleaseand turns on fat link-time optimisation across the whole crate graph with one codegen unit, so the compiler can inline and specialise across crate boundaries.Why
#2384 reports that two other Rust game ports (OpenInfestation, OpenV2K) measured 5-10% off their CPU frame time from the same setting, with event logs and snapshots byte-identical — Rust does not contract or reassociate floating point unless asked. Where that could help here: shader translation at first use (draws wait on it),
translate --cache, page comparisons, detiling and BCPack. It does not speed up GPU work or the driver's pipeline compiles. As the issue notes, a fat-LTO build compiles several times slower, so it gets its own profile rather than changingrelease; theshipdirectory also keeps it from evicting the plain release build.Deliberately left out
.cargo/config.tomlwithtarget-cpu=x86-64-v3(the issue's other build idea): it would change every build on every host — CI, contributors' machines — and the issue's own data has v3 no better than v2. That is a maintainer's call, not part of this profile.Checks
cargo check --locked --profile ship -p xtask: pass (profile accepted).cargo build --locked --profile ship -p xtask: pass — a real fat-LTO link producingtarget\ship\xtask.exe.cargo xtask policy: 182 files ok.git diff --check: clean.victorybinary was not built under this profile locally (compile time); the profile is additive and changes nothing for the existingdev/release/diagbuilds.No game data, no title executable. AI-assisted (Kimi).
@DrDarkDK on GitHub · 2026-11-25 13:20 UTC · original
I built the full
victory.exeat6b37509with Rust 1.98.1 MSVC on Windows 11 / Ryzen 9 7900X. Bothcargo build --locked --profile <profile> -p victorybuilds succeeded, and both executables returned--help.victory.exereleaseshipI also ran nine interleaved pairs of the existing synthetic BCPack benchmark. Median
release→shiptimes were BC1 86.8 → 85.9, BC4 88.1 → 86.3, and BC7 297.8 → 301.1 ns/block. The ranges overlapped for all three formats, so I wouldn’t infer a BCPack speedup from this run.No game data used. No frame-time measurements.
AI-assisted with Codex.
@Halfect on GitHub · 2026-11-25 13:32 UTC · original
Thanks @DrDarkDK for the independent Ryzen 9 7900X run — the clean
release/shipbuilds, the working--helpon both, and the binary-size drop (7.01 → 6.51 MiB) match what this profile is for.The BCPack result is the expected outcome and worth stating plainly: the synthetic BCPack benchmark spends its time in already-hot inner loops that the
releaseprofile optimizes well, so fat LTO plus one codegen unit has nothing left to win there — overlapping ranges for all three formats is consistent with that. The profile's value is the smaller, whole-program-optimized shipping executable, not a BCPack speedup, and the PR body doesn't claim one.Nothing further from my side; ready for review.
@Marvisak on GitHub · 2026-11-25 15:33 UTC · original · edited 2026-11-26 03:20 UTC
Automated triage for the maintainers.
The head is still
6b19f3a. It adds[profile.ship](inheritsrelease,lto = "fat",codegen-units = 1) to the workspaceCargo.tomland one README sentence. Build-profile changes are the maintainer's call, so the verdict stays. Nothing more is needed from you.Thanks to @futurepro62 for the
ship-profile run. On an RTX 5070 Ti,cargo test --workspace --profile shiphad no failures beyond those already failing onmain. The build took about 2.7x longer andvictory.execame out 7% smaller. That confirms the profile builds and does not change test results. It still says nothing about frame time in the title, so the trade-off is for the maintainer to weigh.Verdict: needs work (needs the maintainer's decision). CI: passing.
Generated by Claude Code
@Halfect on GitHub · 2026-11-25 16:13 UTC · original
Thanks — both README problems fixed in
6b19f3a(also rebased onto current main67e8ae1;Cargo.tomlunchanged).`target\ship\victory.exe`(verified no control characters remain in the file).--profile ship(target\ship\victory.exe)." The other-ports figures are dropped; the measurements that stay with the PR are the ones taken on VIctory itself in this thread — @DrDarkDK's independent Ryzen 9 7900X run above (release28.6 s / 7.01 MiB →ship84.3 s / 6.51 MiB, both binaries answering--help, BCPack ranges overlapping) and this PR's own timings.Validation on
6b19f3a(Windows, CPU-only):cargo build --locked --profile ship -p victorysucceeds (1 m 19 s) and the builttarget\ship\victory.exe --helpruns;cargo xtask policy184 files ok;git diff --checkclean.AI-assisted (Kimi).
@kotekompotek on GitHub · 2026-11-25 16:53 UTC · original
Clean:
[profile.ship]inherits release, addslto = "fat"+codegen-units = 1— the standard max-optimisation build, correctly documented as sharing release's feature set and landing in its owntarget/ship/(won't evict iterate builds). Nothing else changes.@Halfect on GitHub · 2026-11-25 22:08 UTC · original
Thanks @kotekompotek for the read — yes, that is the intent:
shipinheritsreleasewholesale and changes onlylto = "fat"+codegen-units = 1, so the iterate profiles (dev/release/diag) are untouched and the profile lands in its owntarget\ship\directory. Nothing further from my side; the profile decision rests with the maintainer.@futurepro62 on GitHub · 2026-11-26 01:51 UTC · original
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
6b19f3a(on its base67e8ae1).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 773 passed, 0 failed, 9 ignored.#[test]functions in the diff.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
@Halfect on GitHub · 2026-11-26 02:10 UTC · original
Thanks @futurepro62 for the full-suite run on the RTX 5070 Ti — 773 passed / 0 failed on the exact head
6b19f3a, with the skips accounted for by pre-existing main-side issues (#2571, #1835/#2317, #1744), is exactly the confirmation this profile change needed. Nothing further from my side; the profile decision rests with the maintainer.@futurepro62 on GitHub · 2026-11-26 02:21 UTC · original
Follow-up to my report above, which was a debug run, so it didn't touch the new profile. Same head
6b19f3a, same machine (RTX 5070 Ti, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC).shipvsrelease, each a full build of-p victory --locked(all 86 crates compiled):--release--profile shipvictory.exetarget\ship\victory.exe --helpstarts and prints its usage, so the README's path is right.cargo test --workspace --locked --profile ship --no-fail-fast -- --test-threads=4(same skips as my report above, tests that fail onmainon this card): 773 passed, 0 failed, 9 ignored, no crashes, so fat LTO with one codegen unit doesn't change any test result here.Not tested
shipbuild plays.AI use
@Halfect on GitHub · 2026-11-26 02:33 UTC · original
Thanks @futurepro62 for the follow-up on the
shipprofile itself — a fullcargo test --workspace --profile shiprun at 773 passed / 0 failed, plus the 2.7× build time and 7% smallervictory.exematching @DrDarkDK's independent numbers on different hardware, is exactly the confirmation this change needed. Nothing further from my side; the profile decision rests with the maintainer.@catminou4 on GitHub · 2026-11-25 13:19 UTC · original · reviewed
Ship profile with fat LTO and one codegen unit. Trivial build config; note binaries grow and builds get much slower — documented. Fine.
@borosf on GitHub · 2026-11-26 12:54 UTC · original
Measured this on an Intel Arc B580 (Windows 11), release vs the same
[profile]this PR adds — reporting it here rather than opening a competing profile PR, sinceNEW-134/this PR own it.Method.
guard_runsis the only bench in the tree, and it timesstructure::structure(plusir::build) — structurisation, not the code this profile actually helps (emit/lower.rs,bitcode.rs::write). So I measured the whole translate path instead, via the existing opcode census, which drives every opcode of every table throughdecode -> ir -> structure -> resource -> lower -> write:(
perfhere =inherits = "release",lto = "fat",codegen-units = 1— the same settings as this PR'sship.)Result, warmed binaries, wall clock per run:
release(lto off, cgu 16)perf(fat LTO, cgu 1)−8.9 % on the translate path. Consistent with what whole-program codegen does to a tree of small cross-crate helpers (
half_src,as_int,narrow16,unary,k()in a 12k-linelower.rs) and with it doing nothing for the per-frame path, which is D3D12 COM calls plus FFI — so do not bill this as a frame-time change.For completeness on
guard_runs, which is what the PR description cites: it moved17.437 -> 20.339 usunmasked,12.010 -> 11.279 usshort runs,27.946 -> 25.257 uslong runs — i.e. one case worse, two slightly better, on the stage the profile matters least. I would not quote it either way; if you want a bench that reachesemit, the census fixture is the ready-made one.Correctness under the profile:
cargo test --profile perf -p victory-shader --lib --lockedis 300 passed / 2 failed / 3 ignored on this card — the two being the known B580 baseline failures pristine main also fails (emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products). No test changes behaviour under fat LTO.No game data used; synthetic tests only. Happy to run the same measurement on the
shipprofile itself if you want the number attributed to your name for the profile.@Halfect on GitHub · 2026-11-26 13:03 UTC · original
Thanks @borosf for measuring the path the profile actually helps. The census fixture driving every opcode through
decode -> ir -> structure -> resource -> lower -> writeis the right instrument here — it reaches the cross-crate helper trees inlower.rs/bitcode.rsthat fat LTO + one codegen unit can inline, unlikeguard_runs, which times structurisation alone. −8.9 % on that path (281 → 256 ms) with zero test-behaviour changes under the profile is exactly the shape the PR predicts, and it complements @DrDarkDK's and @futurepro62's build-time/size numbers: cheaper first-use shader translation, smaller binary, nothing claimed for the per-frame path.On the offer: yes, a run on the literal
--profile shipwould be welcome — same census command with--profile shipinstead ofperfattributes the number to the profile as merged and removes any doubt that the localperfdefinition drifted from it. Nothing further from my side; the profile decision rests with the maintainer.@borosf on GitHub · 2026-11-26 13:44 UTC · original
Correcting my own measurement above (thank you for the push to run the literal
shipprofile — it changed the answer).What was wrong with my −8.9 %. I timed
cargo test … -- --exact emit::census_tests::every_opcode_translate_or_refuse_never_panicwithdate +%s%Naround it. That clock includes cargo's own start-up and process creation, which on this box is ~247 ms of the ~280 ms — the census itself is ~30 ms of work (finished in 0.03sin its own output, 1,232 opcodes: 546 translated, 686 refused, 0 panicked). So a "281 ms vs 256 ms" difference lives entirely inside overhead I was not measuring deliberately, and I should not have called it −8.9 %.The profile, quoted from the PR, is exactly what was described:
[profile.ship]=inherits = "release",lto = "fat",codegen-units = 1— nothing else (notarget-cpu,panic,debugorstrip), so it inheritsdebug = "line-tables-only"andpanic = "unwind".Measured with launch cost removed (direct binary invocation, 40 iterations per pass, 3 passes, with a null-filter run per binary to price pure launch — 30.2 ms on both, identical):
≈3 % on the translate path, and one of the three passes showed +0.3 % — inside run-to-run variance. For completeness, the plain
cargo testwall clock gave release 277 ms (275/277/283) vs ship 291 ms (270/291/306): overlapping ranges, i.e. noise. So on this machine: no reproducible runtime win for the profile, and the earlier −8.9 % should be disregarded.What the profile does cost, measured:
cargo test --profile X … --no-runfor this one crate's lib + test binary — release 34.1 s, ship 119.4 s. A 3.5× build-time multiplier, so the PR's "compiles several times slower" holds; the fullvictorygraph will be worse.Correctness under the profile is fine: the census passes under
ship(1 passed; 0 failed), 1,232 opcodes through decode → ir → structure → resource → io → emit, no panics — so nothing about fat LTO changes behaviour here.One thing to know about the base:
emit::census_tests::every_opcode_translate_or_refuse_never_panicdoes not exist at this PR's base (67e8ae1) — it landed onmainafter the branch point, andmainis 78 commits ahead. I measured onmainwith this PR's commit cherry-picked on top (Cargo.tomlis byte-identical between the PR base andmain, so the profile under test is the PR's), and a rebase would make the census available at the PR's own head.My read: the honest case for this PR is not a runtime percentage — it is a cheaper-to-ship binary if the build-time cost is acceptable, and that trade is the maintainer's. I would drop any measured-win claim from the description rather than defend 3 % inside noise. Happy to re-run on any other workload you name; this was CPU-only shader translation, so the Arc B580 was never exercised and the result is not GPU- or driver-sensitive.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.