[pr-performance] Profile-guided release build: scripts\pgo.ps1, and the instrumented build writes its profile at the bench exit #65
Loading…
Reference in a new issue
No description provided.
Delete branch "iridiumlotus/Darner:pgo-build"
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
Makes a profile-guided build of the release exe possible, and adds a script for it. Profile-guided optimisation tells the compiler which code ran, and how often, in a run of the game; it lays out and inlines the program by that. No source differs between the plain and the guided exe, and nothing changes in a build that does not ask for it. (This was pull request 344 on CodeFloe, open when that host went away: the same commit, rebased on main
295621e.)What was in the way: an instrumented build (
-Cprofile-generate) writes its profile from an atexit handler, and no way this program ends runs one. Closing the window and the settings menu end withTerminateProcess, andDARNER_EXIT_AFTER_WORLD_Sends withstd::process::exit, which isExitProcesson Windows. An instrumented run left no profile of the game at all.crates/darner-gpu/src/host.rs,exit_after_world: under#[cfg(darner_pgo_gen)]the bench exit calls the profile runtime's writer (__llvm_profile_write_file) before it ends the process, and logs whether it wrote. The cfg is declared for check-cfg incrates/darner-gpu/build.rs.scripts\pgo.ps1 instrumentbuilds with-Cprofile-generate --cfg darner_pgo_gen; then the game is run withDARNER_EXIT_AFTER_WORLD_S=<seconds>(every run adds to the same profile; withscripts\play-nvidia.ps1that is-Build release, as it starts the fast build of #21 otherwise);scripts\pgo.ps1 usemerges the profile with llvm-profdata and builds with-Cprofile-use.-TargetDirkeepstarget\release\darner.exeas it is. The header has the steps.docs/README-nvidia.md: two lines under Build.Why a cfg in RUSTFLAGS and not a cargo feature: a feature changes the crates' symbol names, the profile is matched by them, and the profile of a build with the feature did not apply to the build without it (that exe built in six minutes and ran like the plain one). RUSTFLAGS do not change the names.
How it was tested
295621e) for the checks below. The game was run with the same hook and the same script on a tree at main28ef3ddplus local launcher commits, and before that at58a9c07; not on this branch's base.cargo clippy -p darner-gpu --all-targets --all-features --locked -- -D warningsreports nothing;cargo xtask policypasses;cargo check -p darner-gpu --lockedwithRUSTFLAGS=--cfg darner_pgo_gencompiles the hook.cargo testnot run: without the cfg no code differs.28ef3dd, standing 140 s + walk 330 s28ef3dd, same profile58a9c07, one standing run of 140 s58a9c07, same profileFrame rates of the three standing pairs at
28ef3dd: guided 31.0 / 31.3 / 30.5 fps, plain 27.9 / 29.6 / 29.5 fps (7,200 to 9,200 draws a frame).-Ctarget-cpu=nativewith the profile (two pairs: -0.42 ms +- 0.21 a frame).rustup component add llvm-tools(not installed here; the one in Program Files\LLVM was used); Linux (the script is PowerShell; where exit runs atexit handlers the hook is not needed).Checklist
main.docs/asset-policy.md.Checked for overlap
-Build releasestarts) and #28 (the log flushed before the title's own exit; another exit path, notexit_after_world).🤖 Generated with Claude Code