WIP: perf(lift): the lifted code built with a play profile, every chunk (assets/profiles/longshot_game.profdata.xz) #2308

Draft
dyst wants to merge 4 commits from dyst/Longshot:perf/lifted-pgo into main
Member

Summary

Stacked on #2235 (RX_FP_NATIVE): the profile was recorded from its float headers, so merge #2235 first. This PR's own
commit is 38a23405; the diff against main shows #2235's three commits as well.

The build can compile the hot pieces with a play profile (RX_PGO, a checkout's work/longshot_pieces.prof), but none
ships (#1635: "no play profile of the pieces ships"), and the other lifted chunks never get one. This PR:

  • commits a profile of the lifted code, assets/profiles/longshot_game.profdata.xz (975 KB; 18.9 MB unpacked), recorded
    over six scenes (Market, Lake Hylia, Kakariko Village, Hyrule Field, Kokiri Forest, the Fire Temple), 30 s each;
  • unpacks it and builds every lifted chunk with it by default (nx2/make_game.py game_profile_for, as
    vk_profile_for does the renderer's): the hot pieces at -O2 as before, the other chunks at -O1 with it too. On the
    Market the chunks' share doubled the gain against the hot pieces alone (game loop -9% against -5%);
  • keys the chunks' objects by the profile's contents (-DLONGSHOT_PROFILE_SHA1), as the hot pieces' already were (#660);
  • has RX_PGO=gen count every chunk, so one run records the whole profile.

Switches (build time, rows in docs/dev/reference/build.md): LONGSHOT_GAME_PROFILE=0 builds without it;
LONGSHOT_PGO_CHUNKS=0 keeps RX_PGO to the hot pieces alone. RX_PGO set by hand or a checkout's
work/longshot_pieces.prof still goes first; RX_FP_NATIVE=0 builds without it (the shapes differ).

What the profile holds: lifted function names (f_<guest address>, s_<address>_<n>), a hash of each one's shape and its
branch counts; no game code or data, like hot_funcs.txt beside it. How it was recorded is in assets/profiles/README.md.
It ages rather than breaks: a function whose shape changes (a new translator, a patch) compiles as if there were no
profile.

Read first: game_profile_for in nx2/make_game.py, the RX_PGO block in nx2/build.py, assets/profiles/README.md.

Related: #1976 (the build saying how well the profile fits) would show this profile's fit; #1986 (a profile for the
runtime's own files) is separate.

Testing

Tested: Windows 11, Ryzen 9 3900X, RTX 3080 (NVIDIA 621.14), 3440x1440 window at 67%, V-Sync off, uncapped. The head
38a23405 packed over the v3.1.1 base with no switch set (its log: "the lifted code's play profile: ...
longshot_game.shipped.profdata"), A/B against #2235 at 388fa3cb in Hyrule Field and the Market, 2 runs a side each:
every run reached its scene and played its 60 s, nothing wrong seen. tests/test_game_pgo.py passes ("game pgo: pass")
and fails on #2235's branch (no game_profile_for).

Still to test:

  • Linux (the AppImage compiles the game: the committed profile must be read by its clang), RADV and NVIDIA: @Beanstalk
    the Market and Hyrule Field against #2235, expecting a gain of the same order.
  • The Steam Deck (CPU-bound): @Beanstalk the same, expecting more of the game loop's cut to show as fps.
  • An Intel CPU: @Beanstalk.
  • 3 or more runs a side and Lake Hylia (render-bound here: the game loop's cut shows as GPU wait), by hand.
  • mise run test, by hand.

Measurements

Verdict: faster: Hyrule Field +8.8% fps, the Market +2.4%, every run of this PR above every run of #2235 in both; the
game loop 9% and 5% shorter.

Setup: Windows 11, Ryzen 9 3900X, RTX 3080 (NVIDIA 621.14), 3440x1440 window, render resolution 67%, V-Sync off,
uncapped (HOS_FPS_MAX=1000), dev.py ab's runs (60 s after the warm-up, A1 B1 A2 B2). game_ms is the frame trace's
game loop.

Before: #2235 @ 388fa3cb After: this PR @ 38a23405
Hyrule Field fps (2 runs) 76.8, 77.2 84.4, 83.1
Hyrule Field median / p99 frame 12.85 / 18.26, 12.77 / 18.85 ms 11.72 / 16.99, 11.75 / 19.68 ms
Hyrule Field game_ms (median) 12.44, 12.37 11.20, 11.18
Market fps (2 runs) 59.2, 58.1 60.6, 59.5
Market median / p99 frame 16.54 / 25.14, 16.90 / 23.76 ms 16.09 / 23.89, 16.38 / 24.45 ms
Market game_ms (median) 15.87, 16.30 15.09, 15.25
longshot.exe 522,566,144 bytes 528,400,896 bytes
Compile (the whole game code, a pack) 11:28 12:01

Earlier runs of the same change (local measurement branches, the profile's first recordings): the Market-only profile
gave Lake Hylia's game loop -18% (fps +1.5%: the render chain holds the frame there); a three-scene profile Hyrule Field
+7.6% and the Market +4.2% with Hyrule Field in none of its scenes; the six-scene profile measured the same as the
three-scene one. Building the whole game at -O2 on top added nothing (-1.0%, -0.6%) for 2.5x the compile time.

Risks

  • A profile that fits badly costs nothing but its gain: mismatched functions compile without it.
  • It must be recorded again when the translator, the float headers or the game's version change much
    (assets/profiles/README.md says how); until then the gain shrinks.
  • A compiler that can't read it builds without it (profile_readable), as with the renderer's.
  • Off: LONGSHOT_GAME_PROFILE=0 (or LONGSHOT_PGO_CHUNKS=0 for the hot pieces alone). A player notices the speed; the
    game is built again once.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit. Stacked on #2235 (WIP).
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named). Not run yet; tests/test_game_pgo.py passes.
  • Measured against main, or Measurements says why there is nothing to measure. (Against #2235, which it builds on.)
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
    Build switches (LONGSHOT_GAME_PROFILE, LONGSHOT_PGO_CHUNKS): rows in docs/dev/reference/build.md, on by default.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Windows built; Linux not yet.
  • 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.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • 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 **Stacked on #2235** (RX_FP_NATIVE): the profile was recorded from its float headers, so merge #2235 first. This PR's own commit is `38a23405`; the diff against `main` shows #2235's three commits as well. The build can compile the hot pieces with a play profile (`RX_PGO`, a checkout's `work/longshot_pieces.prof`), but none ships (#1635: "no play profile of the pieces ships"), and the other lifted chunks never get one. This PR: - commits a profile of the lifted code, `assets/profiles/longshot_game.profdata.xz` (975 KB; 18.9 MB unpacked), recorded over six scenes (Market, Lake Hylia, Kakariko Village, Hyrule Field, Kokiri Forest, the Fire Temple), 30 s each; - unpacks it and builds **every** lifted chunk with it by default (`nx2/make_game.py` `game_profile_for`, as `vk_profile_for` does the renderer's): the hot pieces at `-O2` as before, the other chunks at `-O1` with it too. On the Market the chunks' share doubled the gain against the hot pieces alone (game loop -9% against -5%); - keys the chunks' objects by the profile's contents (`-DLONGSHOT_PROFILE_SHA1`), as the hot pieces' already were (#660); - has `RX_PGO=gen` count every chunk, so one run records the whole profile. Switches (build time, rows in `docs/dev/reference/build.md`): `LONGSHOT_GAME_PROFILE=0` builds without it; `LONGSHOT_PGO_CHUNKS=0` keeps `RX_PGO` to the hot pieces alone. `RX_PGO` set by hand or a checkout's `work/longshot_pieces.prof` still goes first; `RX_FP_NATIVE=0` builds without it (the shapes differ). What the profile holds: lifted function names (`f_<guest address>`, `s_<address>_<n>`), a hash of each one's shape and its branch counts; no game code or data, like `hot_funcs.txt` beside it. How it was recorded is in `assets/profiles/README.md`. It ages rather than breaks: a function whose shape changes (a new translator, a patch) compiles as if there were no profile. Read first: `game_profile_for` in `nx2/make_game.py`, the `RX_PGO` block in `nx2/build.py`, `assets/profiles/README.md`. Related: #1976 (the build saying how well the profile fits) would show this profile's fit; #1986 (a profile for the runtime's own files) is separate. ## Testing **Tested:** Windows 11, Ryzen 9 3900X, RTX 3080 (NVIDIA 621.14), 3440x1440 window at 67%, V-Sync off, uncapped. The head `38a23405` packed over the v3.1.1 base with no switch set (its log: "the lifted code's play profile: ... longshot_game.shipped.profdata"), A/B against #2235 at `388fa3cb` in Hyrule Field and the Market, 2 runs a side each: every run reached its scene and played its 60 s, nothing wrong seen. `tests/test_game_pgo.py` passes ("game pgo: pass") and fails on #2235's branch (no `game_profile_for`). **Still to test:** - Linux (the AppImage compiles the game: the committed profile must be read by its clang), RADV and NVIDIA: `@Beanstalk` the Market and Hyrule Field against #2235, expecting a gain of the same order. - The Steam Deck (CPU-bound): `@Beanstalk` the same, expecting more of the game loop's cut to show as fps. - An Intel CPU: `@Beanstalk`. - 3 or more runs a side and Lake Hylia (render-bound here: the game loop's cut shows as GPU wait), by hand. - `mise run test`, by hand. ## Measurements **Verdict:** faster: Hyrule Field +8.8% fps, the Market +2.4%, every run of this PR above every run of #2235 in both; the game loop 9% and 5% shorter. Setup: Windows 11, Ryzen 9 3900X, RTX 3080 (NVIDIA 621.14), 3440x1440 window, render resolution 67%, V-Sync off, uncapped (`HOS_FPS_MAX=1000`), `dev.py ab`'s runs (60 s after the warm-up, A1 B1 A2 B2). `game_ms` is the frame trace's game loop. | | Before: #2235 @ 388fa3cb | After: this PR @ 38a23405 | |---|---|---| | Hyrule Field fps (2 runs) | 76.8, 77.2 | 84.4, 83.1 | | Hyrule Field median / p99 frame | 12.85 / 18.26, 12.77 / 18.85 ms | 11.72 / 16.99, 11.75 / 19.68 ms | | Hyrule Field `game_ms` (median) | 12.44, 12.37 | 11.20, 11.18 | | Market fps (2 runs) | 59.2, 58.1 | 60.6, 59.5 | | Market median / p99 frame | 16.54 / 25.14, 16.90 / 23.76 ms | 16.09 / 23.89, 16.38 / 24.45 ms | | Market `game_ms` (median) | 15.87, 16.30 | 15.09, 15.25 | | `longshot.exe` | 522,566,144 bytes | 528,400,896 bytes | | Compile (the whole game code, a pack) | 11:28 | 12:01 | Earlier runs of the same change (local measurement branches, the profile's first recordings): the Market-only profile gave Lake Hylia's game loop -18% (fps +1.5%: the render chain holds the frame there); a three-scene profile Hyrule Field +7.6% and the Market +4.2% with Hyrule Field in none of its scenes; the six-scene profile measured the same as the three-scene one. Building the whole game at `-O2` on top added nothing (-1.0%, -0.6%) for 2.5x the compile time. ## Risks - A profile that fits badly costs nothing but its gain: mismatched functions compile without it. - It must be recorded again when the translator, the float headers or the game's version change much (`assets/profiles/README.md` says how); until then the gain shrinks. - A compiler that can't read it builds without it (`profile_readable`), as with the renderer's. - Off: `LONGSHOT_GAME_PROFILE=0` (or `LONGSHOT_PGO_CHUNKS=0` for the hot pieces alone). A player notices the speed; the game is built again once. ## Checklist ### Ready for review - [ ] One topic, on current `main`; the title is a Conventional Commit. Stacked on #2235 (WIP). - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). Not run yet; `tests/test_game_pgo.py` passes. - [x] Measured against `main`, or Measurements says why there is nothing to measure. (Against #2235, which it builds on.) - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [ ] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. Build switches (`LONGSHOT_GAME_PROFILE`, `LONGSHOT_PGO_CHUNKS`): rows in `docs/dev/reference/build.md`, on by default. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. Windows built; Linux not yet. - [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. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] 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)
The game reads FPSR in no function play runs and FPCR stays 0, so the FPX1 guards, the fast
float regions' MXCSR windows and exact copies, and the vector keep tests only keep flags nobody
reads. This builds native copies of the lift's two float headers ahead of the lift's own, to
measure what that layer costs. Not a product: NaN encodings and FPSR are no longer Arm's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The game sets FZ itself (f_8169d350, a setFlushToZero that play runs), so native float ops need
FTZ and DAZ where Arm flushes. Each lifted MSR FPCR now syncs MXCSR after the write, through the
RECOMP_FPX_INHIBIT token every such write ends with: no new lift.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
exp(lift): RX_FP_NATIVE sets a new fiber's MXCSR from the FPCR it inherits; its row in build.md
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
PR description / Description follows the template (pull_request_target) Successful in 9s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
CI / Workflow lint (actionlint) (pull_request) Successful in 11s
Third-party parts / As their notes say (pull_request) Successful in 13s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Website build and checks (pull_request) Failing after 1m32s
388fa3cb02
A fiber takes its creator's FPCR (fiber_switch) but a float state of its own (FIBER_FLAG_FLOAT_SWITCH):
fiber_main now syncs MXCSR from FZ before the fiber's first instruction. The host files see the native
headers too, so the sync compiles only where RX_FP_NATIVE is on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
perf(lift): the lifted code built with a play profile, every chunk (assets/profiles/longshot_game.profdata.xz)
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
PR description / Description follows the template (pull_request_target) Successful in 11s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 13s
CI / Workflow lint (actionlint) (pull_request) Successful in 14s
Third-party parts / As their notes say (pull_request) Successful in 16s
CI / Website build and checks (pull_request) Failing after 38s
38a234052a
The build could take a profile of the hot pieces (RX_PGO, work/longshot_pieces.prof) but none ships.
This commits one, recorded over six scenes on RX_FP_NATIVE's float headers, and builds every lifted
chunk with it by default (LONGSHOT_PGO_CHUNKS=0: the hot pieces alone; LONGSHOT_GAME_PROFILE=0: none).
RX_PGO=gen now counts every chunk too, so one run records the whole profile. The chunks' flags carry
the profile's hash, as the hot pieces' do, so a new profile at the same path is compiled again.

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

Tested in game: Windows 11, Ryzen 9 3900X, RTX 3080 (NVIDIA 621.14), 3440x1440 window at 67%, V-Sync off, uncapped. The head 38a23405 packed over the v3.1.1 base with no switch set (the log names the committed profile), A/B against #2235 at 388fa3cb, 2 runs a side: Hyrule Field 76.8/77.2 -> 84.4/83.1 fps, the Market 59.2/58.1 -> 60.6/59.5 fps. Every run reached its scene and played through; nothing wrong seen.

Tested in game: Windows 11, Ryzen 9 3900X, RTX 3080 (NVIDIA 621.14), 3440x1440 window at 67%, V-Sync off, uncapped. The head 38a23405 packed over the v3.1.1 base with no switch set (the log names the committed profile), A/B against #2235 at 388fa3cb, 2 runs a side: Hyrule Field 76.8/77.2 -> 84.4/83.1 fps, the Market 59.2/58.1 -> 60.6/59.5 fps. Every run reached its scene and played through; nothing wrong seen.
Member

Possibly related, for context:

  • issue #505 Idea: ship play profiles (the hot list and the renderer's profile) with releases — Open proposal to ship game play profiles; this implements lifted-code profile coverage.
Possibly related, for context: - issue #505 Idea: ship play profiles (the hot list and the renderer's profile) with releases — Open proposal to ship game play profiles; this implements lifted-code profile coverage.
Member

🤖 A suggestion for the play profile's scenes: Lost Woods.

We surveyed every Debug-tab destination for CPU load on a 5700X3D + RX 9070 XT, at base dd5ffe6a, with the camera turning and the frame rate uncapped. Lost Woods (child or adult) came out the heaviest: about 57-59 CPU ms a frame, against about 45 at Hyrule Field's usual spot. It is CPU-bound, with GPU time around 4 ms of a 12 ms frame.

Most of that time is the job workers in the Havok cloth, a path the current profile scenes may barely exercise. We now run our standard test there (teleport 5 from a child save).

🤖 Generated with Claude Code

🤖 A suggestion for the play profile's scenes: Lost Woods. We surveyed every Debug-tab destination for CPU load on a 5700X3D + RX 9070 XT, at base dd5ffe6a, with the camera turning and the frame rate uncapped. Lost Woods (child or adult) came out the heaviest: about 57-59 CPU ms a frame, against about 45 at Hyrule Field's usual spot. It is CPU-bound, with GPU time around 4 ms of a 12 ms frame. Most of that time is the job workers in the Havok cloth, a path the current profile scenes may barely exercise. We now run our standard test there (teleport 5 from a child save). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Contributor

Steam Deck and Linux data for the "Still to test" list, from a player. These are local test builds, not the PR head packed by CI.

Build: a2dc5385 + #2235 + this PR (head 38a23405), built from source on Linux for RX_MARCH=znver2. Three variants come from the same tree:

variant build env what it is
pgo defaults #2235 + #2308
fpn LONGSHOT_GAME_PROFILE=0 #2235 alone
base RX_FP_NATIVE=0 behaves as a2dc5385

The variants differ only in bin/longshot, bin/longshot_vk.so and build-stamped files. The pipeline caches were shared between them.

Linux question (does the AppImage-style clang read the profile?): yes. clang 23.1.5 from tools.lock read the committed profile:

  • llvm-profdata show reads it as Front-end instrumentation with 18723 functions.
  • The profile_readable() probe returns rc 0.
  • The build log says the lifted code's play profile: .../longshot_game.shipped.profdata.

One caveat: the lifted chunks compile with -Wno-everything (nx2/build.py), so clang's profile-mismatch warnings are suppressed and I could not measure the fit.

Linux desktop, i7-8700K masked to 4C/8T (taskset), RTX 3060 Ti, Market entrance, standing still, Deck-like render mode (RX_VK_ASYNC=0 RX_VK_RECORDER=off), 3 interleaved runs a side, pgo vs fpn (x86-64-v3 builds):

  • game_ms (median): 5.78 → 5.10 ms (-11.9 %). Every pgo run beat every fpn run (5.05-5.29 vs 5.76-5.91).
  • CPU time of the whole process per frame: -2.4 ms. The range excludes 0.
  • The frame itself did not change: 23.71 → 23.72 ms, 42.2 fps. The game loop is not the limit there.
  • Pause-menu screenshots: no difference between pgo and fpn beyond what two runs of the same build differ by.

Steam Deck LCD (SteamOS 3.9.5, RADV), headless bench, 3 interleaved rounds of pgo / fpn / base, Market entrance, 90 s warm-up then a 60 s window, standing still:

run avg fps median frame ms game_ms proc CPU ms/frame
pgo-1 18.73 52.79 12.51 145.0
fpn-1 20.53 47.51 14.19 144.0
base-1 20.91 47.17 14.84 150.7
pgo-2 21.97 45.00 10.90 120.0
fpn-2 21.45 46.09 12.52 131.2
base-2 19.88 49.78 15.37 170.4
pgo-3 21.12 46.85 12.47 126.4
fpn-3 21.20 46.32 12.53 132.4
base-3 20.94 47.19 14.92 155.4
  • #2235 (fpn vs base):
    • game_ms 14.92 → 12.53 (-2.4 ms, -16 %), run-to-run range [-2.85, -0.65].
    • Process CPU per frame -23 ms [-39, -7].
    • The game threads drop too: ModuleSystemWorker -5.1 ms, BaseProcExecutor -12.1 ms per frame. Every range excludes 0.
  • #2308 on top (pgo vs fpn): game_ms -0.07 ms [-3.3, -0.01]. Noise-sized on the Deck, unlike the -12 % on the desktop above. CPU time trends down (-6 ms/frame) but the range holds 0.
  • fps: no change in this bench, for a reason in the bench, not the PR.
    • The run was headless (HOS_HEADLESS) at an output resolution of 2560x1440 (see the correction below), and render_ms was ~30-34 ms, about twice what the Deck shows at its own 1280x800 in Game Mode. The frame was render-bound, so the game-loop savings could not reach it.
    • Desktop Mode also capped the APU at ~11.6 W, and CPU clocks moved between 1.8 and 2.1 GHz from run to run (pgo-1 was the low-clock outlier).
    • In normal Game Mode play on this Deck, the game's job graph is ~18.5 ms of a ~37.7 ms frame, so the #2235 saving should be visible there. I'm re-running at 1280x800 to check.

Bench summary (per-run table + both A/B tables): deck-bench-745-pgo-fpn-base-summary.txt

Correction: the bench did not render at 1920x1080. That is only the size of its offscreen present image. With no screen, the game's output resolution falls back to 2560x1440 (oe: output resolution 2560x1440 (none chosen: the game's) in every run's log), 3.6x the pixels of the Deck's own 1280x800. The bench now sets HOS_OUTPUT_RES=1280x800; the re-run follows.

Assisted-by: Claude

Steam Deck and Linux data for the "Still to test" list, from a player. These are local test builds, not the PR head packed by CI. **Build:** a2dc5385 + #2235 + this PR (head `38a23405`), built from source on Linux for `RX_MARCH=znver2`. Three variants come from the same tree: | variant | build env | what it is | |---|---|---| | `pgo` | defaults | #2235 + #2308 | | `fpn` | `LONGSHOT_GAME_PROFILE=0` | #2235 alone | | `base` | `RX_FP_NATIVE=0` | behaves as a2dc5385 | The variants differ only in `bin/longshot`, `bin/longshot_vk.so` and build-stamped files. The pipeline caches were shared between them. **Linux question (does the AppImage-style clang read the profile?): yes.** clang 23.1.5 from `tools.lock` read the committed profile: - `llvm-profdata show` reads it as `Front-end` instrumentation with 18723 functions. - The `profile_readable()` probe returns rc 0. - The build log says `the lifted code's play profile: .../longshot_game.shipped.profdata`. One caveat: the lifted chunks compile with `-Wno-everything` (`nx2/build.py`), so clang's profile-mismatch warnings are suppressed and I could not measure the fit. **Linux desktop, i7-8700K masked to 4C/8T (`taskset`), RTX 3060 Ti, Market entrance, standing still, Deck-like render mode (`RX_VK_ASYNC=0 RX_VK_RECORDER=off`), 3 interleaved runs a side, `pgo` vs `fpn` (x86-64-v3 builds):** - `game_ms` (median): 5.78 → 5.10 ms (**-11.9 %**). Every `pgo` run beat every `fpn` run (5.05-5.29 vs 5.76-5.91). - CPU time of the whole process per frame: -2.4 ms. The range excludes 0. - The frame itself did not change: 23.71 → 23.72 ms, 42.2 fps. The game loop is not the limit there. - Pause-menu screenshots: no difference between `pgo` and `fpn` beyond what two runs of the same build differ by. **Steam Deck LCD (SteamOS 3.9.5, RADV), headless bench, 3 interleaved rounds of pgo / fpn / base, Market entrance, 90 s warm-up then a 60 s window, standing still:** | run | avg fps | median frame ms | game_ms | proc CPU ms/frame | |---|---|---|---|---| | pgo-1 | 18.73 | 52.79 | 12.51 | 145.0 | | fpn-1 | 20.53 | 47.51 | 14.19 | 144.0 | | base-1 | 20.91 | 47.17 | 14.84 | 150.7 | | pgo-2 | 21.97 | 45.00 | 10.90 | 120.0 | | fpn-2 | 21.45 | 46.09 | 12.52 | 131.2 | | base-2 | 19.88 | 49.78 | 15.37 | 170.4 | | pgo-3 | 21.12 | 46.85 | 12.47 | 126.4 | | fpn-3 | 21.20 | 46.32 | 12.53 | 132.4 | | base-3 | 20.94 | 47.19 | 14.92 | 155.4 | - **#2235 (`fpn` vs `base`):** - `game_ms` 14.92 → 12.53 (**-2.4 ms, -16 %**), run-to-run range [-2.85, -0.65]. - Process CPU per frame -23 ms [-39, -7]. - The game threads drop too: ModuleSystemWorker -5.1 ms, BaseProcExecutor -12.1 ms per frame. Every range excludes 0. - **#2308 on top (`pgo` vs `fpn`):** `game_ms` -0.07 ms [-3.3, -0.01]. Noise-sized on the Deck, unlike the -12 % on the desktop above. CPU time trends down (-6 ms/frame) but the range holds 0. - **fps: no change in this bench, for a reason in the bench, not the PR.** - The run was headless (`HOS_HEADLESS`) at an output resolution of 2560x1440 (see the correction below), and render_ms was ~30-34 ms, about twice what the Deck shows at its own 1280x800 in Game Mode. The frame was render-bound, so the game-loop savings could not reach it. - Desktop Mode also capped the APU at ~11.6 W, and CPU clocks moved between 1.8 and 2.1 GHz from run to run (pgo-1 was the low-clock outlier). - In normal Game Mode play on this Deck, the game's job graph is ~18.5 ms of a ~37.7 ms frame, so the #2235 saving should be visible there. I'm re-running at 1280x800 to check. Bench summary (per-run table + both A/B tables): [deck-bench-745-pgo-fpn-base-summary.txt](https://git.magicbean.dev/attachments/af22e08f-fd02-4432-b992-f84ecccf8541) **Correction:** the bench did not render at 1920x1080. That is only the size of its offscreen present image. With no screen, the game's output resolution falls back to 2560x1440 (`oe: output resolution 2560x1440 (none chosen: the game's)` in every run's log), 3.6x the pixels of the Deck's own 1280x800. The bench now sets `HOS_OUTPUT_RES=1280x800`; the re-run follows. Assisted-by: Claude
Contributor

Follow-up Steam Deck run, now on v3.2.0 and at the Deck's own 1280x800. Every run's log says oe: output resolution 1280x800, set with HOS_OUTPUT_RES.

Build: a local merge of v3.2.0 (79d192c6) with this PR (38a23405, which includes #2235), built for RX_MARCH=znver2. Three variants come from the same tree:

  • pgo: defaults.
  • fpn: LONGSHOT_GAME_PROFILE=0.
  • base: RX_FP_NATIVE=0, which behaves as stock v3.2.0.

Run: Steam Deck LCD, headless, Market entrance, standing still, 90 s warm-up, 60 s window, 3 interleaved rounds. CPU was at 2.3-2.5 GHz and the APU at 12 W in every run.

CPU ms per frame (whole process) median B-A range of runs
base (stock v3.2.0) 129.4
fpn (#2235) vs base 113.8 -15.6 (-12 %) [-20.0, -12.1]
pgo (#2235 + #2308) vs fpn 104.4 -9.4 (-8 %) [-12.6, -5.2]

Per thread group, pgo vs fpn:

  • ModuleSystemWorker: -2.6 ms/frame [-2.9, -1.8]
  • BaseProcExecutor: -4.5 ms/frame [-5.6, -2.8]
  • sead::MainThread: -0.9 ms/frame [-1.2, -0.3]

So on the Deck the play profile does pay on top of #2235 at this size. My earlier 2560x1440 run had not shown it.

fps did not move: pgo 29.0, fpn 28.5, base 28.4 average. Median frame 33.8-34.3 ms in all three; every range holds 0.

On v3.2.0 at 1280x800 the Deck's frame is bound by the replay thread. Per-run medians over the window, all nine runs:

part of the frame ms
frame 33.5-36.9
render_ms 26.4-28.9 (draw_ms 14.2-15.9, cmds_ms 6.4-7.1)
main_blocked_ms 26-28
game_ms 3.3-3.6
gpu_wait_ms 0.2-0.3

So the CPU the two PRs save on the job workers does not reach the frame there. Next I'll try the recorder thread alone (RX_VK_RECORDER=thread, Auto keeps it off at 4 cores) on the pgo build, since the workers now leave more room on the 4 cores.

Bench summary (per-run table, both A/B tables, clocks per run): deck-bench-v320-1280x800-pgo-fpn-base-summary.txt

Assisted-by: Claude

Follow-up Steam Deck run, now on **v3.2.0** and at the Deck's own **1280x800**. Every run's log says `oe: output resolution 1280x800`, set with `HOS_OUTPUT_RES`. **Build:** a local merge of v3.2.0 (`79d192c6`) with this PR (`38a23405`, which includes #2235), built for `RX_MARCH=znver2`. Three variants come from the same tree: - `pgo`: defaults. - `fpn`: `LONGSHOT_GAME_PROFILE=0`. - `base`: `RX_FP_NATIVE=0`, which behaves as stock v3.2.0. **Run:** Steam Deck LCD, headless, Market entrance, standing still, 90 s warm-up, 60 s window, 3 interleaved rounds. CPU was at 2.3-2.5 GHz and the APU at 12 W in every run. | CPU ms per frame (whole process) | median | B-A | range of runs | |---|---|---|---| | base (stock v3.2.0) | 129.4 | | | | fpn (#2235) vs base | 113.8 | **-15.6 (-12 %)** | [-20.0, -12.1] | | pgo (#2235 + #2308) vs fpn | 104.4 | **-9.4 (-8 %)** | [-12.6, -5.2] | Per thread group, pgo vs fpn: - ModuleSystemWorker: -2.6 ms/frame [-2.9, -1.8] - BaseProcExecutor: -4.5 ms/frame [-5.6, -2.8] - sead::MainThread: -0.9 ms/frame [-1.2, -0.3] So on the Deck the play profile does pay on top of #2235 at this size. My earlier 2560x1440 run had not shown it. **fps did not move:** pgo 29.0, fpn 28.5, base 28.4 average. Median frame 33.8-34.3 ms in all three; every range holds 0. On v3.2.0 at 1280x800 the Deck's frame is bound by the replay thread. Per-run medians over the window, all nine runs: | part of the frame | ms | |---|---| | frame | 33.5-36.9 | | `render_ms` | 26.4-28.9 (`draw_ms` 14.2-15.9, `cmds_ms` 6.4-7.1) | | `main_blocked_ms` | 26-28 | | `game_ms` | 3.3-3.6 | | `gpu_wait_ms` | 0.2-0.3 | So the CPU the two PRs save on the job workers does not reach the frame there. Next I'll try the recorder thread alone (`RX_VK_RECORDER=thread`, Auto keeps it off at 4 cores) on the `pgo` build, since the workers now leave more room on the 4 cores. Bench summary (per-run table, both A/B tables, clocks per run): [deck-bench-v320-1280x800-pgo-fpn-base-summary.txt](https://git.magicbean.dev/attachments/1a1374e5-8192-4218-8bb1-f57bda78e8ef) Assisted-by: Claude
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
Website / Website on Cloudflare (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 7s
PR description / Description follows the template (pull_request_target) Successful in 11s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 13s
CI / Workflow lint (actionlint) (pull_request) Successful in 14s
Third-party parts / As their notes say (pull_request) Successful in 16s
CI / Website build and checks (pull_request) Failing after 38s
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/lifted-pgo:dyst-perf/lifted-pgo'
git switch 'dyst-perf/lifted-pgo'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!2308
No description provided.