perf(vk): memory priorities: when VRAM is overcommitted, what is drawn every frame stays in VRAM first #1159
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
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1159
Loading…
Reference in a new issue
No description provided.
Delete branch "GummiNaomi/Longshot:perf/memory-priority"
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 card that runs out of VRAM (4-8 GB) on Windows; AMD; Linux; a Steam Deck
Why
When a 4-8 GB card's VRAM is overcommitted, Windows' memory manager (or the driver) moves some of the process's memory to system memory, and the GPU then reads it over PCIe. Without priorities it chooses alone: a render target or DLSS's history moved out is read and written every frame.
VK_EXT_memory_prioritylets the renderer say what should stay. NVIDIA's own guidance is to give critical resources a high priority for this (Vulkan dos and don'ts), and DXVK gives render targets and descriptor heaps 1.0, other memory 0.5, host-visible VRAM 0.1 (dxvk_memory.cpp).What changed
Every VRAM allocation gets a priority, so a card that runs out moves textures and upload buffers to system memory before the frame being drawn; where VRAM isn't short, nothing changes.
VK_EXT_memory_priorityasked for where the device has it, its feature on, and VMA told (VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT) (gpu/vk/vk_main.cpp,gpu/vk/vk_vma.cpp).RX_VK_MEMORY_PRIORITY=0: not asked for.tests/test_memory_priority.py(asked for, and every pool and allocation given a priority).RX_VK_MEMORY_PRIORITYindocs/development.md.Measurements
Verdict: nothing to measure on this PC: priorities only matter when VRAM is really overcommitted, and
RX_VK_TEST_ALLOWED_MBlowers the renderer's view of the allowance without filling the card, so no paging happens here. The log says the extension is on; the frame rate on a small card is for testers.Flags and settings
One new switch, on by default.
RX_VK_MEMORY_PRIORITYTesting
Tested: Windows 11, RTX 4070 SUPER, NVIDIA 617.42: the gate route (no device loss; the log's
vk: memory priorities (VK_EXT_memory_priority): on);tests/test_memory_priority.pypasses (4 tests);python -I -B tests/run_all.py: 227 passed, 64 failed, 387 skipped, and main71b1edd8on the same PC has the same 64 failing tests (this PC's toolchain: Windows line endings, fixtures needing gcc or clang++).Not tested: a card that runs out of VRAM, AMD, Intel, Linux, the Steam Deck.
Must be tested:
RX_VK_MEMORY_PRIORITY=0, expecting fewer and shorter dips with it on (by hand)Risks
What could break: a driver that mishandles the extension; it is only asked for where the device lists it, and
RX_VK_MEMORY_PRIORITY=0turns it off. Where VRAM is short, textures may now go to system memory before render targets did, which is the intent.Turning it off:
RX_VK_MEMORY_PRIORITY=0.Compatibility: Nothing changes.
Issues
None found.
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.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
Possibly related, for context:
Reviewed exact head
f0ec466210da0d120f8ea9e4bc1026c7938ec50c, code and evidence only. No code from the PR, tests, builds or gameplay run here. This remains WIP; this review is not merge approval.No blocking implementation defect found in the extension setup: both extension presence and the queried memoryPriority feature gate the VMA allocator flag, and the switch leaves that allocator feature off. The custom-pool priorities are explicitly supplied, and allocation infos are initialized throughout the wrappers, including fallback paths. No renderer API version change or vendored edit is involved. Note that VMA custom-pool priority is per memory block; per-allocation priorities do not independently control pooled suballocations.
Merge concerns to settle:
1,0.5experiment deteriorated over time, so its successful lower-texture-priority numbers must not be attributed to this different policy. That experiment also differs in host-visible priority and build, so it is not proof this PR regresses either.Ready for limited farm validation of default-on versus off on Windows NVIDIA and Linux AMD where the farm permits this switch and workers support it. A high-VRAM smoke run is useful for compatibility but does not satisfy the 4-8 GB/paging requirement. Plans/reports should explicitly distinguish extension unsupported, insufficient VRAM pressure and unsupported metrics from a passing efficacy test. Do not introduce an external VRAM-filling tool through a test plan. I will authorize this exact head for farm testing separately; the duplicate/policy decision and real-pressure evidence remain open.
@Beanstalk Test reviewed head
f0ec466210on Windows NVIDIA and Linux AMD. Compare the default with RX_VK_MEMORY_PRIORITY=0 if allowed by the farm switch policy, frame generation off, using the same Market/Hyrule Field route and settings. Record extension support, crashes, frame times and VRAM. Prefer 4-8 GB hardware where available. Only claim a pressure benefit if real paging/overcommit is actually established; a software allowance limit or high-VRAM smoke pass does not establish that. Do not use external memory-filling programs; report unsupported switch comparisons or pressure measurements as untested. This is WIP validation, not merge approval.Beanstalk test farm
Commit
f0ec466· tier reviewed · approved by futondestroyer · dashboardWhat will be tested · AI plan (
gpt-6.1-terra)This WIP validation runs the reviewed head against main on Windows NVIDIA and Linux AMD, preferably with 4–8 GB VRAM. Each run follows the same Market and Hyrule Field route with frame generation off; the switch matrix compares priorities enabled and disabled on the PR. The plan records extension status in logs, crashes, frame times and VRAM, and checks for visual and performance regressions over roughly 25 minutes per tester. Real paging is not measured, so a pressure benefit remains untested; this is not merge approval.
1or0(PR only).Done. Comment
@Beanstalkto run it again.NVIDIA GeForce RTX 3070 Laptop GPU, 621.24.0AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7RX_VK_MEMORY_PRIORITY=1 (PR only)RX_VK_MEMORY_PRIORITY=1 (PR only)RX_VK_MEMORY_PRIORITY=0 (PR only)RX_VK_MEMORY_PRIORITY=0 (PR only)Measurements · windows+nvidia
Verdict: could not be judged on windows+nvidia (1/1 report).
Hardware: 1: windows+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 3070 Laptop GPU, 621.24.0AMD Ryzen 9 5900HX with Radeon Graphics, 32 GB RAMScene: market-field-route, from a new save (frame_generation=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-field-route: 1 game start a side, market 30 s after 10 s warm-up, field 30 s after 10 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)71b1eddf0ec466RX_VK_MEMORY_PRIORITY=1 (PR only)· forbidden log linesRX_VK_MEMORY_PRIORITY=0 (PR only)· field · peak VRAM (MB)RX_VK_MEMORY_PRIORITY=0 (PR only)· market · peak VRAM (MB)RX_VK_MEMORY_PRIORITY=0 (PR only)· field · frame time (p99) (ms)RX_VK_MEMORY_PRIORITY=0 (PR only)· market · frame time (p99) (ms)RX_VK_MEMORY_PRIORITY=0 (PR only)· forbidden log linesFlags and settings
RX_VK_MEMORY_PRIORITY1,0Markdown for the PR description
Measurements · linux+amd
Verdict: pass on linux+amd (1/1 report): no rule failed and no PR run crashed.
Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 7900 XTX (RADV NAVI31), 26.2.7AMD Ryzen 7 5800X3D 8-Core Processor, 64 GB RAMScene: market-field-route, from a new save (frame_generation=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); market-field-route: 1 game start a side, market 30 s after 10 s warm-up, field 30 s after 10 s warm-up; each number the median of the runs, then of 1 report
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)71b1eddf0ec466RX_VK_MEMORY_PRIORITY=1 (PR only)· field · peak VRAM (MB)RX_VK_MEMORY_PRIORITY=1 (PR only)· market · peak VRAM (MB)RX_VK_MEMORY_PRIORITY=1 (PR only)· field · frame time (p99) (ms)RX_VK_MEMORY_PRIORITY=1 (PR only)· market · frame time (p99) (ms)RX_VK_MEMORY_PRIORITY=1 (PR only)· forbidden log linesRX_VK_MEMORY_PRIORITY=0 (PR only)· field · peak VRAM (MB)RX_VK_MEMORY_PRIORITY=0 (PR only)· market · peak VRAM (MB)RX_VK_MEMORY_PRIORITY=0 (PR only)· field · frame time (p99) (ms)RX_VK_MEMORY_PRIORITY=0 (PR only)· market · frame time (p99) (ms)RX_VK_MEMORY_PRIORITY=0 (PR only)· forbidden log linesFlags and settings
RX_VK_MEMORY_PRIORITY1,0Markdown for the PR description
Thanks for the review. Agreed on not landing two: I've suggested on #560 that it goes forward (it has the real paging measurements and a tested parser), carrying over the host-visible 0.1 tier and the farm's RADV result from here, and that I close this one once that's settled. Keeping it open until then so the Windows NVIDIA farm report can finish.
🤖 Generated with Claude Code
WIP: perf(vk): memory priorities: when VRAM is overcommitted, what is drawn every frame stays in VRAM firstto perf(vk): memory priorities: when VRAM is overcommitted, what is drawn every frame stays in VRAM firstNeeds proper testing, use the VRAM limiting flag
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.