perf(vk): VRAM held for nothing given back: frame generation's images when off, the recording streams and descriptor pools #1158
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1158
Loading…
Reference in a new issue
No description provided.
Delete branch "GummiNaomi/Longshot:perf/vram-held-idle"
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: Windows 11, RTX 4070 SUPER (NVIDIA 617.42) · Needs: a Steam Deck; AMD on Linux; an 8 GB card; frame generation turned off in play
Why
On 4-8 GB cards and the Steam Deck the textures get what the rest leaves, and every MB the rest holds for nothing is a texture evicted and made again. In a 6 GB simulation of Castle Town's gate route (
RX_VK_TEST_ALLOWED_MB=5600, a 6 GB card's mirror and texture budgets, 1080p) the textures used in the last 8 presents were 1,860 MB against a budget squeezed to 1,851 MB: 12,640 textures evicted in 140 s. Three things held VRAM they never used. (A fourth, the BC3 scratch's 140 MB, is #384's.)What changed
Three places stop holding VRAM they don't use: 48 MB of streams on every card with resizable BAR, ~100 MB of descriptor pools on RADV (estimate), and up to ~800 MB where frame generation was tried and turned off; none of it changes the picture.
framegen_idle,gpu/vk/vk_framegen.cpp;fsr3fi::release,gpu/vk/vk_fsr3fi.cpp). The check runs after the present'sframegen_queue, and a present that recorded made frames counts as on whatever the row says by then (gpu/vk/framegen_idle.h), so a drain never waits for a set not handed to the display thread yet. ~150 MB at 2560x1440 2x, ~800 MB at 4K 8x.RX_VK_STREAM_MB; host-visible VRAM where the card has resizable BAR): 48 MB. A recording that needs more still gets a bigger stream.RX_VK_DESC_POOL_GROW=0: whole from the start). RADV keeps a pool's descriptors in GPU memory (~4 MB a whole pool, 48 slots: an estimate from RADV's descriptor sizes, not measured); NVIDIA does not hold a pool to its per-type sizes, so nothing changes there (gpu/vk/vk_draw.cpp).tests/test_framegen_idle.pycompiles the idle rule and runs present sequences (among them: off for 119, then a present that records with the row on and reads Off at the check);tests/test_vram_held_idle.py(the order in the present's path, the streams and pools).RX_VK_STREAM_MB,RX_VK_DESC_POOL_GROWindocs/development.md.Measurements
Verdict: the memory each change gives back, read from the logs; no frame-rate claim. Single runs of the 6 GB simulation vary by 20-30 % in slow frames between identical builds, more than ~190 MB moves them, so the frame rate is left to testers on small cards.
Hardware: Windows 11 Pro 26200, RTX 4070 SUPER 12 GB (NVIDIA 617.42), Ryzen 9 9950X3D (16 cores, SMT off), 32 GB
Scene: save set "First Step into Hyrule Town", Castle Town's gate into Hyrule Field and back (gate-bridge-wall.txt, wall clock), 2560x1440, DLAA, uncapped,
RX_VK_TEST_ALLOWED_MB=10200Method: headless runs; the figures are the log's own lines (the recording streams', the write-back diff's) and the sizes of what is made
Baseline: main's sizes are fixed (2 MB streams, whole pools), so the before column is what main allocates, not a run
How to reproduce: the route above; read the log's "recording streams" and "write-back diff" lines;
RX_VK_STREAM_MB=2 RX_VK_DESC_POOL_GROW=0gives main's sizes71b1edd84e889b09Flags and settings
One default changes and one switch is new (
RX_VK_DESC_POOL_GROW).RX_VK_STREAM_MBRX_VK_DESC_POOL_GROWTesting
Tested: Windows 11, RTX 4070 SUPER, NVIDIA 617.42: the gate route several times on this change (no device loss);
tests/test_vram_held_idle.pypasses;tests/test_framegen_idle.pypasses with emsdk's clang++ (--cxx);python -I -B tests/run_all.py: the same 64 failing tests as main71b1edd8on this PC (its toolchain: Windows line endings, fixtures needing gcc or clang++), plustests/test_longshot_ctl.py's relaunch case in two of the full runs (a stand-in process stopped by exit not quit, a file still open at cleanup; it passes alone here and on main, and touches nothing this PR changes).tests/test_parallel_init_order.pyandtests/test_fsr_uniform_ownership.pydo not build their fixtures on main (FpsRtWait,fps_statsmissing from their stand-ins since #928).Not tested: frame generation turned off in play (headless runs cannot change the row), AMD and RADV (the descriptor pools' saving and their growth), the Steam Deck, a real 6-8 GB card.
Must be tested:
frame interpolation off: its images ... let goline about 2 s after turning it off, nothing wrong on screen, and frame generation working again when turned back on (by hand)textures retired ... budgetlines in the log than main gives (by hand)Risks
What could break: a descriptor pool too small for a scene on a driver that holds the sizes costs one whole pool made for that recording, then the slot's pool is whole. Frame generation turned on again after being let go makes its images again (one device wait, as a resize does).
Turning it off:
RX_VK_STREAM_MB=2 RX_VK_DESC_POOL_GROW=0; frame generation's release has no switch.Compatibility: Nothing changes.
Issues
Related: #939 (6 GB cards over the driver's allowance). The BC3 scratch: #384.
Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.docs/tested/for each new measured run (format indocs/tested-configurations.md).tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
Possibly related, for context:
Reviewed exact head
141d45bbb72e75d6c9fdce6b3e721438538a5d54, code and existing evidence only. No builds, tests or gameplay run here. This remains WIP.[P1] Do not drain a recorded frame-generation set before it has been queued. In
gpu/vk/vk_replay.cpp, the newframegen_idle()call is beforeframegen_queue(value).framegen_record()has already marked its selected set busy and saved it infg.recorded, while only the later queue call gives the display thread the job that eventually clears busy. The new idle function rereadsopts.framegen(the menu runs on the display thread), rather than using whether this present actually recorded interpolation. After at least 119 off presents, consider a present that records a set while enabled, then observes Off inframegen_idle(): its off counter reaches the threshold and waits for every set to become non-busy, including the current set whose queue call this same replay thread has not reached. Neither thread can clear that set, so the wait hangs. Merely reaching a device idle cannot fix the unqueued display job. Enqueue any recorded job before a possible drain, or explicitly suppress/reset idle retirement for a present that recorded a set; handle current-frame ownership independently of a second menu read. Add a behavioral regression covering a pending recorded/busy set and an on/off change between recording and idle. The current test checks only that wait/drop strings occur in the function and cannot catch this ordering bug.Split out the already-developed BC3 scratch work. #384 is open with approvals and substantially stronger Deck/desktop and batch-bound coverage for the same scratch-sizing change. Prefer landing/rebasing over that PR, then keep this PR focused on the remaining stream/pool/FG work; don't land duplicate implementations or discard the existing tests/evidence.
Other readiness gaps: descriptor-pool growth and FG off/on behavior have not been exercised on the target drivers; tests here mostly assert source spelling rather than execute lifecycle/batching/growth. Changing three defaults calls for real target-hardware evidence. The single-run measurements and analytical allocation sizes establish requested storage reductions, not actual low-VRAM frame-rate or eviction improvements. The source checks were heavily skipped on the author's toolchain. The current forge guide-image/source-review status fails and must be resolved or explained before merge.
Verdict: request changes for the cleanup ordering; keep WIP. Holding farm authorization until that potential hang is addressed. Afterward the useful runs are FG on/off/on in a window and RADV/Deck descriptor-growth and BC3 coverage, with actual low-VRAM results distinguished from a lowered software allowance.
WIP: perf(vk): VRAM held for nothing given back: the BC3 scratch, frame generation's images when off, the recording streams and descriptor poolsto WIP: perf(vk): VRAM held for nothing given back: frame generation's images when off, the recording streams and descriptor poolsThanks, both points taken, pushed as
4e889b09(a new commit, nothing rewritten):framegen_idlenow runs afterframegen_queue(value), and a present that recorded made frames counts as on whatever the row says by the check, so a drain can't wait for a set the display thread hasn't been handed. The counting is a small rule with no Vulkan in it (gpu/vk/framegen_idle.h);tests/test_framegen_idle.pycompiles it and runs present sequences, including the one you found (off for 119, then a present that records with the row on and reads Off at the check), plus the order of the two calls in the present's path.vk_texture.cpp, its test stand-in, the docs row and the checks are back as on main.The rest stands as you say: the descriptor pools' growth and frame generation off/on still need the target drivers (RADV/Deck, a windowed FG off/on/off), and the measurements are allocation sizes, not low-VRAM frame-rate results; the description says so. The
@Beanstalkruns you listed would be the useful ones once you're happy with the ordering fix.Also from my side: in full
run_allruns on Windows,tests/test_longshot_ctl.py's relaunch case failed twice on my branches (stopped byexitnotquit, a file still open at cleanup) and passes alone here and on main: a timing flake, unrelated. Andtests/test_parallel_init_order.py/tests/test_fsr_uniform_ownership.pydon't build their fixtures on main since #928 (FpsRtWait,fps_statslack stand-ins); I can send a small fix for those separately.🤖 Generated with Claude Code
WIP: perf(vk): VRAM held for nothing given back: frame generation's images when off, the recording streams and descriptor poolsto perf(vk): VRAM held for nothing given back: frame generation's images when off, the recording streams and descriptor poolsView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.