Repository navigation
perf(vk): cap the system-heap budget for idle live imports on Linux - #2839
Merged
Merged
Conversation
Contributor
Author
|
Thanks for the thorough review! I pushed
Regarding #2759 and hardware coverage:
|
elkarbeenus
pushed a commit
to elkarbeenus/LakuenRecompBuilder
that referenced
this pull request
Nov 12, 2026
….3.0 Fewer idle threads spinning (NotRexed#2709), bounded waits for shaders still translating (NotRexed#2586), the first start after a preparation warms the pipeline cache (NotRexed#2865, NotRexed#2869), native float atomics (NotRexed#2306), the 97% squeeze past the allowance (NotRexed#2585), output choices from the screen's modes (NotRexed#2566), FSR 4 twice as fast on RDNA 2 (NotRexed#2798), the import cap (NotRexed#2839) and the final NotRexed#2825 (mirror trims settle). Kept: the fork's play() returning the game for Steam's wait (now through start_scoped's process), the handheld texture caps, the RDNA2 detection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C7fdTPXbwDRohew9qanvbp
dazemc
added a commit
to dazemc/Hookshot-rs
that referenced
this pull request
Nov 12, 2026
Port four upstream fixes that the GCN/RADV notes did not cover: - NotRexed#2685: import game memory in 4 MB chunks where a pool has a VRAM mirror (16 MB without one, as before). A mirror is its import's whole range, so the old 16 MB chunks left 28-39% of the mirrors outside every game pool; 4 MB cuts them by roughly a quarter at the same frame rate. RX_VK_IMPORT_CHUNK_MB still chooses. - NotRexed#2795: a retired pool whose mirror was refused gives its import back too, as a MIRROR_NONE pool does. Left out, every such pool kept its pinned userptr import (shared GPU memory) for the session. - NotRexed#2825: an import mostly outside every game pool, while VRAM is over 80% of its allowance, is trimmed to its live parts; the new mirrors inherit what the GPU wrote and the old one goes once every part has its own. RX_VK_MIRROR_TRIM=0 turns it off. - NotRexed#2839: on Linux at a 12 GB+ system heap budget, idle live imports are capped at 4500 MB (RX_VK_IMPORT_CAP_MB). On RADV/amdgpu 200+ idle unmirrored pools doubled queue submit time over a two-hour session; the measured run went from 44-48 to 63-68 fps (RX 9070 XT). Game-free fixtures: tests/import_chunk_test.cpp, tests/test_mirror_trim.cpp and the extended tests/retired_give_back_test.cpp run from builder/rust/tests/amd_vram.rs, which also source-checks the wiring, the refused-mirror condition and RADV's Linux AMD mesh default (issue 2245). The Vulkan backend builds with RX_VK_ONLY. No AMD hardware here: the RX 9070 XT and RX 580 measurements are upstream's.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Linux PCs with 32 GB+ RAM (
budget >= 12 GB),imports_give_backwas off by default, letting 200+ idle unmirrored pools from earlier areas stay inimportedover a two-hour session (7.4 GB live): on RADV (amdgpu), that doubledqueue submittime (0.55 → 1.14 ms), tripled GPU write-back waits (2.19 → 6.29–7.03 ms), grew the submit-time capture scan from 2.4 GB to 7.2 GB, and faded the frame rate from 60+ fps down to 44–48 fps. This keeps 16 GB PCs and the Steam Deck (budget < 12 GB) unchanged, turnsimports_give_backon forbudget >= 12 GBLinux PCs with a default 4,500 MB cap (~3,825 MB high / ~3,375 MB low), and addsRX_VK_IMPORT_CAP_MB(0= off) so the cap can be tuned or disabled without rebuilding.Part of #993
Part of #1000
What changed
retired_give_back::live_budget(gpu/vk/retired_give_back.h,gpu/vk/vk_memory.cpp).live_budgetreturnsbudget, so 85% / 75% applies to the full ~7.5 GB budget as in vk: imports given back under system-heap pressure on 16 GB PCs #479, unlessRX_VK_IMPORT_CAP_MB > 0is explicitly set).imports_give_backwas off):live_budgetcaps the effective budget at4,500 MBby default (~3,825 MB high / ~3,375 MB low) so unmirrored live pools whose VRAM mirrors were already freed bymirrors_give_back(mstate == MIRROR_NONE,was_mirrored == true) do not stay in RADV's per-submit BO list andcap_rangesfor the whole session.RX_VK_IMPORT_CAP_MB:RX_VK_IMPORT_CAP_MB=<MB>(> 0) sets the cap in MB on any budget so testers can try other values without rebuilding;RX_VK_IMPORT_CAP_MB=0turns the>= 12 GBcap off (restoringmain's behavior on 32 GB+ PCs while keeping< 12 GBPCs unchanged).RX_VK_IMPORT_HIGH/RX_VK_IMPORT_LOW: setting either watermark switch withoutRX_VK_IMPORT_CAP_MBlifts the default 4,500 MB cap and uses the full system-heapbudget(RX_VK_IMPORT_HIGH=0still turns the valve off everywhere). Windows remains off by default (high = 0unlessRX_VK_IMPORT_HIGHis set).imports_give_backreads its switches viaenv_intand sharesretired_give_back::want, covered bytests/test_retired_give_back.py.Tested
Arch Linux (KDE Plasma Wayland, 2560x1440 window,
/dev/udmabufactive), AMD Radeon RX 9070 XT 16 GB (Mesa RADV 26.2.6), Intel Core i5-13600KF, 32 GB DDR4 (15,434 MBsystem heap budget),v2.1.0 (source e561602e), multi-area play across Hyrule:hookshot_log.txt)40,920presents, defaulthookshot_env.txt)684,120presents, defaulthookshot_env.txt,imports_give_backoff)176,640presents,RX_VK_IMPORT_HIGH=25,RX_VK_IMPORT_LOW=20→ ~3,858 / ~3,086 MB;RX_VK_MIRROR_MB=4096,RX_VK_RECORDER=thread,RX_VK_BATCH=0)vk: imports: ... live55 live (2000 MB)221 live (7392 MB)(67 retired given back, 2992 MB)50–64 live (2256–2720 MB)off (budget >= 12 GB)off257 (7872 MB) in all(system heap 3878 of 15434 MB)capture: a submit0.27 ms(scan 0.05 over 734 ranges, 2417 MB)0.50 ms(scan 0.09 over 334 ranges, 7218 MB)0.18–0.43 ms(scan 0.08 over 3923–4251 MB)queue submit0.55 ms1.11–1.14 ms0.32–0.73 msreadbacks of GPU resultswait2.19 ms each(270 of 3000)6.29–7.03 ms each(312–340 of 3000)0.64–1.14 ms each15351 MB (peak 16107)/1511 MBswapratio 1.352, game's frame rate 44)gpu/vk/vk_memory.cppandretired_give_backchecks pass (tests/test_retired_give_back.py,tests/test_texel_buffer_ownership.py,tests/test_import_buffer_binding.py,tests/test_mem_trim.py,tests/test_vram_budget_row.py, etc.).docs/tested-configurations.md.Cost where not measured / caveats:
budget < 12 GB) are unchanged by default (live_budgetreturns the fullbudgetbelow 12 GB).