perf(vk): the restored speed-ups not yet in main, refreshed on current main #2096
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2096
Loading…
Reference in a new issue
No description provided.
Delete branch "avidela/Longshot:perf/radv-cohort"
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?
Type: perf · Risk: low · Tested on: Linux, RX 5700 XT (RADV) · Needs: Windows, any GPU; a faster CPU than a Ryzen 5 3600 to show sub-milliamp savings
Summary
Upstream's closed #288 (the restored speed-ups) still had commits main never took, and its blocker was that nobody had measured it. This PR audits its 14 perf commits against current main (8 are already absorbed in evolved form; 2 collide with siantm's open #2054 and #2029 and are deliberately not re-ported), ports the four genuinely missing renderer/memory ones onto current main, and measures the result: parity, which the audit predicts, because the headline win of that set (excess eviction) is already in main. The FlatMap test-harness fix and the switches.def rows stand on their own.
A reviewer reads first:
gpu/vk/vk_draw.cpp(ViewFast, the direct-mapped front cache overhandle_hits),gpu/vk/vk_texture.cpp(staging tail suballocation),gpu/vk/vk_memory.cpp(memory_guest_contained, the one-unswizzle import skip),gpu/vk/eden/shader_recompiler(direct 8/16-bit global stores),gpu/vk/switches.def(the three new rows). See #288, whose description is this PR's starting point.Testing
Tested: on my own PC (Fedora 45, RX 5700 XT, RADV Mesa 26.2.6, Ryzen 5 3600, 15 GB): both arms of the A/B below were played through the standard Hyrule Field run-and-spin route (repo save, teleport destination 1, control-bridge sessions) and by hand; no artifacts, no crashes, no device lost. The full suite (
python -I -B tests/run_all.py) fails exactly the environment-dependent set current main fails (main's owntest_switch_tablesorting break included);test_flat_map.pyandtest_direct_buffer_writes.py, which break on a naive port, pass here. The Windows Vulkan back end cross-compiles clean with llvm-mingw (longshot_vk.dll, 0 failed); the Linux game build is the A/B's own binary.Still to test:
Measurements
Verdict: parity — no measurable gain or regression on this box, on current main. The audit predicts it: the restored set's headline win (excess eviction) is already in main in evolved form.
Setup: Fedora 45 (Linux 7.3.3), GNOME Wayland; RX 5700 XT (RADV NAVI10), Mesa 26.2.6 radv; Ryzen 5 3600, 15 GB. Hyrule Field (child), repo save, teleport destination 1, stick-held run + full-speed camera spin; 1280x720 windowed, Auto preset, the game's own upscaler, cap off (HOS_FPS_MAX=1000); 2 interleaved control-bridge sessions per arm, 30 s windows, phase-matched by draws (light phase ~1090).
a2dc53858d8de778RX_VK_VIEW_FAST=0,RX_VK_NATIVE_NARROW=0,RX_VK_UNSWIZZLE_IMPORT=1each restore the old behaviourAn earlier A/B of the same changes on the pre-rebase base (measured at
b398975eagainst main @d6cbc5d4) measured the same parity, including both of the field's spawn phases (heavy ~1400 draws: 40.2-40.8 both arms); its runs aredocs/tested/2026-11-22-restored-speedups-avidela-run01.mdand-run02.md, today's fresh current-main A/B is-run03.md. Current main itself measured ~35 % faster than the v3.0.0 release on this box in the same phase (68 vs 50 fps medians) — that gain is main's, not this PR's.Risks
Compatibility: nothing a player notices — saves,
longshot_options.ini, the shader and pipeline caches and the vk ABI are unchanged (the pipeline cache recompiles stamp-changed programs on first run, as any renderer change does).What could break, where, and how to turn it off:
gpu/vk/vk_draw.cpp'sViewFast; the map stays the authority and every miss falls back to it. Off withRX_VK_VIEW_FAST=0; reverting is enough.gpu/vk/eden's codegen, part of the program cache stamp. Off withRX_VK_NATIVE_NARROW=0; reverting is enough.gpu/vk/vk_memory.cpp'smemory_guest_contained. Off withRX_VK_UNSWIZZLE_IMPORT=1; reverting is enough.gpu/vk/vk_texture.cpp's arenas; no switch, so reverting the commit is the way back.All four were played through the Hyrule Field route above with no artifacts, no crashes and no device lost, with parity measurements on both arms.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named): run directly aspython -I -B tests/run_all.pyhere; the failure set is identical to current main's, including main's owntest_switch_tablesorting break (RX_VK_GRASS_DISTANCEafterRX_VK_SIM_TURF_ADAPTIVE, current main), andtest_flat_map.pyandtest_direct_buffer_writes.pypass here where a naive port breaks them.main, or Measurements says why there is nothing to measure.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(three rows; the development guide's table carries their descriptions too).A check under
tests/that reads changed source is updated, not weakened (the FlatMap harness rewrites every TLS_OBJECT in its cut ofvk_draw.cpp— its old rewrite dropped everything afterhandle_hits' line; the ViewFast stand-ins in the recording-fragment checks are carried).Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (The Windows Vulkan back end cross-compiles clean,
longshot_vk.dll0 failed — not run there, see Still to test; the Linux game build is the A/B's own binary.)Docs updated.
(development.md's switch table gains the three rows; the runs are in
docs/tested/, run01-run03.)AI assistance recorded with
Assisted-by:/Co-Authored-By:trailers (the ported commits carry their original authors' trailers and sources; the repair, test and docs commits carryAssisted-by: Claude).Two costs found by profiling a 4-core handheld (Steam Deck, RADV Van Gogh, 15 W), both generic — no Deck-specific defaults, both behind an env switch that keeps the old behaviour available. Making a staging arena while ~2.5 GB of pools and textures are held took **12–25 ms** — and an 8 MB one could take **116 ms**, so it is the allocator, not the size. The arena the last burst used goes stale after `RX_VK_STAGING_IDLE_S` (30 s) and is given back, so the first upload of the next burst makes another. A camera turn brings new textures in, so it paid for one every time: **28 slow creations in one session**, each a stall of the replay thread. Four are now made at replay start, on an empty device, where they are cheap (`RX_VK_STAGING_PREWARM`, default 4; 0 restores the old behaviour). Measured over a 240 s run, same save and settings: **28 slow creations before, 1 after.** This is the same failure the comment above the idle free already describes on other hardware ("a scene change made several right after the idle ones were freed"), so it should help anywhere memory pressure makes a 64 MB host-visible buffer expensive. `texture_view_of` was **0.99 ms a frame** for ~10,600 lookups, each a hash-map find, and the same slots come round again and again (14.9 descriptors a draw, 725 draws). A 1024-entry direct-mapped cache now answers the repeats. It holds the key, the slot's version, the destroy generation and the texture epoch, and does the epoch's touch itself — so a slot re-registered or a texture destroyed misses it at once and takes the map's path. **The map stays the authority**; the cache only answers a lookup whose every input is the one it was filled with. `RX_VK_VIEW_FAST=0` restores the old path. Measured back to back, same session, same scene, 75 % internal resolution: | | fps | p50 | p99 | 1 % low | |---|---|---|---|---| | without | 24.8 | 40.32 ms | 42.37 ms | 23.6 | | **with** | **24.9** | 40.16 ms | **41.32 ms** | **24.2** | The average is within noise; the tail is a real millisecond. - `RX_VK_PROF_FINE` now splits the texture path (storage-pointer test, handle, view, fingerprint), and the frame statistics say which binding moved `bind_gen` — counted: ubo 2159, tex 1794, ssbo 601, program 431, img 84 a frame. That last one is worth knowing: the game genuinely rebinds ~7 things per draw, which is why 0.9 of draws rebuild their descriptor set and why the reuse check cannot be relaxed. - `scripts/chain.py` no longer fails on a thread line without a name. Based on current `main` (e0e60920); both commits cherry-picked cleanly. I have not been able to build this branch locally (my build machine is on the 127 commits behind base), so CI is the first build — say the word if you would rather I build it first and reopen. Co-authored-by: RufflezAU <[email protected]> Ported to Longshot: the texture-view front cache and the statistics only. The staging prewarm (four 64 MB arenas made in replay_start, RX_VK_STAGING_PREWARM) is left out: the arenas it made went through texture_frame's keep and idle rules like any other, so on a card with 6.5 GB or less three of the four were freed at the first frame, and all of them 30 s after they were made. Keeping them needs an exemption of its own and a check; until then it cost 256 MB of host-visible memory at start for little (review of #209). Restored-from: https://github.com/NotRexed/Hookshot/pull/2960 (cherry picked from commitb3e807332b)Tested in game: Fedora 45, RX 5700 XT (RADV NAVI10, Mesa 26.2.6), Ryzen 5 3600/15 GB: the branch's build played the same Hyrule Field run+spin route as main (3 sessions + a 10-minute soak, repo save, fps unlocked); parity in both spawn phases, FSR 3.1 and the game's upscaler exercised, no artifacts or crashes.
Possibly related, for context:
WIP: perf(vk): the restored speed-ups not yet in main, refreshed on current mainto perf(vk): the restored speed-ups not yet in main, refreshed on current main9c76f35f00201a650fcaView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.