[pr-performance] Parallel ThinLTO release profile, isolate DARNER_BUILD git rebuilds, and fix Rust 1.98.1 clippy lint #130
Loading…
Reference in a new issue
No description provided.
Delete branch "davetheshrew/Darner:pr/build-optimise"
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?
Contributor role (optional)
What it changes
Cargo.toml,scripts/pgo.ps1)[profile.release]fromlto = "fat"/codegen-units = 1tolto = "thin"/codegen-units = 16(retainingdebug = "line-tables-only") so release builds parallelize across cores instead of bottlenecking on a single-threaded final LTO step.[profile.dist](inherits = "release",lto = "fat",codegen-units = 1) for distribution builds where build time does not matter, and added-Profile release|disttoscripts/pgo.ps1.DARNER_BUILDgit watches to the binary crate (apps/darner/build.rs,crates/darner-gpu/build.rs,crates/darner-gpu/src/start_notice.rs,apps/darner/src/main.rs,apps/darner/src/play.rs,crates/darner-gpu/src/host.rs,crates/darner-gpu/src/host/panel.rs)crates/darner-gpu/build.rscomputedDARNER_BUILDand emittedcargo:rerun-if-changedon.git/HEAD,.git/logs/HEAD,.git/packed-refs, and.git/refs/tags, causing every git commit, branch switch, or reflog update to invalidate and rebuilddarner-gpuand downstreamdarner-hle.DARNER_BUILDcomputation intoapps/darner/build.rs, watching onlybuild.rs,DARNER_BUILD_NAME, existingHEAD/packed-refs/refs/tags, and the activesymbolic-refbranch file (without.git/logs/HEAD).darner_hle::start_notice::BUILDwithOnceLock-backedset_build/build(), initialized at startup inapps/darner/src/main.rs, and readenv!("DARNER_BUILD")directly insideapps/darner/src/play.rs.crates/darner-core/build.rs)cargo:rerun-if-changed=build.rsand per-filecargo:rerun-if-changeddirectives for../../locales/*.json.crates/darner-gpu/src/host.rs)(n % 2 == 0).then_some(n)inmade_once_testswithn.is_multiple_of(2).then_some(n)forclippy::manual_is_multiple_of.How it was tested
ecfb0ab(rebased ontoupstream/main57dea7f)git diff --stat upstream/main...HEAD: 10 files changed, 96 insertions, 61 deletions (Cargo.toml,apps/darner/build.rs,apps/darner/src/main.rs,apps/darner/src/play.rs,crates/darner-core/build.rs,crates/darner-gpu/build.rs,crates/darner-gpu/src/host.rs,crates/darner-gpu/src/host/panel.rs,crates/darner-gpu/src/start_notice.rs,scripts/pgo.ps1)..rs/.tomlfiles use LF (0CRLF);scripts/pgo.ps1preserves CRLF (84CRLF,0bare LF).TrustNo1/Darnervia the Forgejo API for build-script, profile, or Clippy 1.98.1 overlap.cargo clippy --workspace --all-targets --locked -- -D warnings,cargo clippy --workspace --all-targets --all-features --locked -- -D warnings,cargo test --workspace --locked,cargo xtask policy --staged, and live Windows build-time comparisons still need to be run on Windows before merging.Checklist
main.docs/asset-policy.md.Checked for overlap
DARNER_BUILDrebuild isolation,locales/*.jsonrebuild tracking, or Clippymanual_is_multiple_of(unrelated open PRs also touchhost.rs,panel.rs,main.rs, orplay.rs: #34, #36, #47, #48, #50, #57, #58, #59, #62, #75, #80, #93).Before this can be merged, it needs a runtime measurement. The published exe is built with
cargo build --release, so this PR turns it from one fat-LTO unit into ThinLTO with 16 codegen units. The frame here is limited by the processor, and the old profile comment says the hot paths cross crates. A slower exe would ship without anyone noticing.Please add an A/B in the game: the current
releaseprofile against this PR'srelease. Same save, same spot, pipelines warm, at least two runs each, alternated. Give the per-run fps (median of the 5 s lines) and the CPU and card. If ThinLTO is slower, the release profile should stay fat and the faster build should go in a new profile instead.The other two changes (the
DARNER_BUILDrebuild isolation and the clippy lint) can be merged on their own. Please split them into a separate PR.Jesper-A referenced this pull request2026-12-03 22:55:37 +00:00
Note from me: I did not test this PR but in my use of ThinLTO, the full tree was rebuilt in 77 s versus about 4 minutes for fat LTO on my workstation. So there is a possible gain here for testing builds.
The (default) fast build profile is for this. It does make a noticable speed difference. It should not be the default for release. The release build does a full optimization, and it is needed.
See the "Fast and release builds" section in README.md
darner.exe playto start, scripts as thin wrappers #167I compared CPU texture decoding on the two release profiles. The timing ranges overlapped on every format. The requested in-game FPS comparison remains open.
Main was
57dea7f236(fat LTO, one codegen unit), candidateecfb0ab085(ThinLTO, 16 units). Median [min–max] in ns per block across four scored processes per build:Windows 11, i5-13600KF, Rust 1.98.1 MSVC. Both clean trees used the same lockfile. I built with
cargo test --release --no-run --locked --offline --jobs 1 -p darner-formatsand ranbcpack::tests::bcpack_throughput_builtin --exact --ignored --nocapture --test-threads=1on logical CPU 19. Each sample decoded 16,384 fixed blocks 40 times. One unscored warm-up per arm, then A/B/B/A and B/A/A/B in fresh processes. All four decoder oracle tests passed on each build. Both full release executables also built successfully.Separate finding for the build-label change. With the unchanged PR build script and icon in a small Cargo fixture, I packed the checked-out branch with
git pack-refs --all, rancargo check --locked --offline, made an empty commit, and ran the same check again. HEAD advanced from32388574tod9a5da57, but the script still exported32388574. The loose-branch control updated correctly. The build-label fix watches the nearest existing parent until Git creates the loose ref. I verified the reported revision before and after the next commit on loose, packed, nested packed, reflog-disabled packed, and detached checkouts. The timing runs above used the original PR.Built and tested #130 on Windows (Ryzen 7 9800X3D, RTX 5080, Rust 1.98.1): a clean
cargo build --release --locked -p darnersucceeds in 1m48s with-C lto=thin -C codegen-units=16, a second build is a no-op (0.12s), and after an empty commit onlydarnerrecompiled while DARNER_BUILD went from v2026.12.03.01-23 to -24; DARNER_BUILD_NAME behaves the same and lands in the exe.Gate 1 is red as pushed:
cargo clippy -p darner-gpu -p darner --all-targets -- -D warningsfails with E0689 at crates/darner-gpu/src/host.rs:13171 (test racing_callers_all_get_the_value_published_first):n.is_multiple_of(2)on an ambiguous{integer}. Annotating.map(|n: usize| ...)makes it pass (exit 0), so it's a one-line fix. Lib-only clippy passes either way.The dist profile compiles with
-C codegen-units=1 -C linker-plugin-lto(probe build of darner-core at that profile); I did not run the Fat LTO link itself.In game at Jason's house, standing still for 3 minutes per arm (one run each): ThinLTO median 32.6 fps / 30.9 ms vs main 29.8 fps / 33.6 ms (ranges 28.4-35.8 vs 26.6-34.8; draw counts differed, 6681 vs 7856, so indicative only). No regression seen.
Drafted with AI assistance (OpenCode).
I ran the requested release-profile comparison on an i5-13600KF and RTX 4070 Ti SUPER 16 GB (Windows 11, NVIDIA 617.14). Both runs of the PR had higher median FPS than the preceding baseline, but also fewer draw calls per frame. The GPU was at 99% utilization in all four windows. I can't attribute the difference to ThinLTO from this scene.
A is the direct parent
57dea7f236(fat LTO, 1 codegen unit). B is the PR headecfb0ab085(ThinLTO, 16 units). Both were built with Rust 1.98.1 using the same locked dependencies. Native 2560×1440, Series X profile, upscaling, frame generation and RT off. The title and Darner frame caps were lifted for all four measured windows.I warmed each build once before scoring, kept separate caches, then ran A/B/A/B. Each launch used a fresh copy of the same save files and settings. I checked the view before and after each window. The character stayed beside the same pickup facing the same storefront, with no movement input. Nearby vehicles varied between launches. Each window ran from 60 to 150 seconds after the first world-frame marker. The primary column is the per-run median of Darner's printed FPS lines. The next two columns use complete present intervals within the same window.
The paired differences were +1.8 and +0.4 FPS, with 8.6% and 2.4% fewer draw calls on the PR, respectively. NVIDIA utilization was 99% at the median and peak in each run (45 samples per window). All four warmed runs still created some pipelines (11 / 8 / 5 / 7 in order). The largest accumulated pipeline wait was 1.14 s in B1. These runs give a native-1440p result for this card. A comparison in a CPU-limited scene with a repeatable workload would better isolate the release-profile change.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.