perf(vk): capture buffers ready before their copy, in an arena of mapped blocks (RX_VK_CAP_READY, RX_VK_CAP_ARENA_MB) #3156
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3156
Loading…
Reference in a new issue
No description provided.
Delete branch "decohered/Longshot:perf/capture-ready"
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?
Summary
The worst problems I ran into on my Steam Machine were due to the capture threads faulting in new buffers one page at a time, and each fault waiting on the same VM lock that submissions and binds wait on.
Now the buffers are ready before the copy operation even begins.
RX_VK_CAP_PREFAULT)RX_VK_CAP_READY, off on Windows)RX_VK_CAP_ARENA_MB, 0 for none)vk: capture buffers (600 presents)line counts what was made, taken and let go, the arena's use, and what it gave backvmaDestroyPooldrains the recorder first, asvmaFreeMemorydoesStart with
cap_buf_getandcap_buf_freeingpu/vk/vk_memory.cppand the arena ingpu/vk/vk_vma.cpp, thentests/test_capture_buffers_ready.py.Testing
Tested: These have been in every build I've played on my Steam Machine since, and the captures come almost entirely from the arena now: in a 132-minute session, 2,574,612 capture buffers came from it and only 9 were made on their own.
Steam Machine: Navi 33 8 GB, 16 GB of RAM, SteamOS 3.10.1, kernel 7.3.1-valve3, RADV steamos-26.05.20
A 54-minute session: 1,070,623 capture buffers from the arena, 1 made on its own
tests/test_capture_buffers_ready.py,tests/test_capture_spare_admission.py,tests/test_capture_spare_reuse.py,tests/test_cap_free_async.py,tests/test_recorder_sync.pyandtests/test_memory_priority.pypass with clang++ and g++ 16.2.0After review (
a5a08d0f8),tests/test_capture_buffers_ready.pyalso checks that an arena buffer retired under memory pressure has the arena give back its empty blocks, and one retired without pressure doesn'tThe game builds whole at
a5a08d0f8on Linux.mise run teston Linux at742b45e8f: 863 pass, 13 skip (Windows only or a device it needs), 19 fail. The same 19 fail on main @299ed5b70with the same tools (the toolchain from nixpkgs; mise's pinned one isn't set up here), so none come from this change.The 19
byte_compile_tracked, f2i_immediate, global_load_16, native_suatom, test_check_cache, test_checks_container, test_cloth_kernels, test_dav1d_av1, test_fsr_uniform_ownership, test_game_module_imports, test_lifter, test_lifter_semantics, test_linux_pressure, test_loaded_modules_drop, test_native_zstd, test_program_cache_cleanup, test_program_cache_one_variant, test_thinlto_tls, test_ui_renderer
Still to test:
vk: capture buffersline (@Beanstalk play through a few zone changes on a Steam Deck and report the vk: capture buffers lines)Measurements
Verdict: In the sessions that pushed under 1 GB to swap, the game's major faults fell from 581-624 a second on builds without these to 0-14 with them (median 2), and in a 132-minute session the arena served 2,574,612 capture buffers with only 9 made on their own.
Baseline: before is a build of my branch on nightly-805 (
6b928cb4) without the ready buffers and the arena, perf-recorded over 15 minutes of play; after is my branch @ 6cb6989ef with them, counted from the game's log over a 132-minute session. Both on the Steam Machine. The fault rates come from a watcher that read the game process's major-fault count every 10 s through every session there: before, the sessions on builds without the ready buffers and the arena; after, those on builds with them; sessions that pushed 1 GB or more to swap are left out on both sides.6b928cb4Risks
Yeah, it's up to 768MB on Linux. The spares could already be that big though, and now the empty blocks get reclaimed when memory is low.
RX_VK_CAP_ARENA_MB=0: no arena; the captures use the spares and buffers of their ownRX_VK_CAP_READY=0: a buffer made at a capture isn't touched where it's made, the spares' places and the larger-spare rule are main's, and the arena is off unlessRX_VK_CAP_ARENA_MBasks for itRX_VK_CAP_PREFAULT=0: a spare made ahead isn't touchedChecklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
Possibly related, for context:
@Beanstalk
@review
Beanstalk test farm · an earlier run: commit
742b45e(the newer results are in a comment below)Commit
742b45e· approved by HumanBean (reviewed) · dashboard⚠️ Note: The farm does not measure capture-thread page faults, so it cannot directly verify the claimed fault reduction.
⚠️ Note: Arena and inline capture counts are reported when the 600-present log line appears; the plan cannot automatically judge their ratio or reproduce the author’s long-session totals.
Started at 06:50 UTC.
Estimate: done in about 22 h, from the queue and the testers online now.
nvidiaamdintellinux+radvwindowsigpusteamdeckCouldn't be judged: the tester's PC could not finish the test. The farm tries another PC, or the same one after a fix; it says nothing about the PR on its own.
nvidia, report 1:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'snvidia, report 2:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'samd, report 1:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'samd, report 2:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'sintel, report 1:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'sintel, report 2:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'slinux+radv, report 1:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'slinux+radv, report 2:main's tools.lock: tools.lock line 32 (sdl): its first URLs are not Longshot's store'sWhat was tested
What will be tested · AI plan (
gpt-6.1-terra)The plan compares capture-buffer performance and scene loads against main across NVIDIA, AMD, Intel, RADV, integrated GPUs and Windows, with an additional Steam Deck target that will wait for an online tester. Three starts per side visit Hyrule Field, Market and Kakariko Village, measuring uncapped frame times, load times and process memory while recording capture-buffer arena counts and still-scene pictures. Each tester’s game runs take approximately 40 minutes. A crash, a material frame-time or load-time regression, or a substantial picture difference fails the pull request. No tester online now matches steamdeck: that target waits for one.
kokiri-start(settings vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0; switchesHOS_OUTPUT_RES=1280x720,RX_VK_AUTO_TUNE=0), then teleport to Hyrule Field, take the picture field to compare with main, measure field for 20 s (after 10 s warm-up), teleport to Market, take the picture market to compare with main, measure market for 20 s (after 10 s warm-up), teleport to Kakariko Village, take the picture kakariko to compare with main, measure kakariko for 20 s (after 10 s warm-up); 3 runs on each side.Measurements on `nvidia`, for the PR description
Verdict: could not be judged on nvidia (2 reports).
Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu+dlss
NVIDIA GeForce RTX 5070 Laptop GPU, 620.85.2AMD Ryzen AI 9 365 w/ Radeon 880M, 32 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpu+window+dlss+xessNVIDIA GeForce RTX 3070, 621.35.0AMD Ryzen 5 5600X3D 6-Core Processor, 32 GB RAMScene: scene-changes, from the repository's save kokiri-start (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=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); scene-changes: 3 game starts a side, field 20 s after 10 s warm-up, market 20 s after 10 s warm-up, kakariko 20 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `amd`, for the PR description
Verdict: could not be judged on amd (2 reports).
Hardware: 1: windows+amd+amd-proprietary+dgpu+window
AMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAM; 2: linux+amd+radv+dgpuAMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAMScene: scene-changes, from the repository's save kokiri-start (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=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); scene-changes: 3 game starts a side, field 20 s after 10 s warm-up, market 20 s after 10 s warm-up, kakariko 20 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `intel`, for the PR description
Verdict: could not be judged on intel (2 reports).
Hardware: 1: linux+intel+anv+igpu
Intel(R) Graphics (RKL GT1), 26.2.411th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz, 128 GB RAM; 2: windows+intel+intel-proprietary+igpu+windowIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMScene: scene-changes, from the repository's save kokiri-start (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=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); scene-changes: 3 game starts a side, field 20 s after 10 s warm-up, market 20 s after 10 s warm-up, kakariko 20 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `linux+radv`, for the PR description
Verdict: could not be judged on linux+radv (2 reports).
Hardware: 1: linux+amd+radv+dgpu
AMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM; 2: linux+amd+radv+igpuAMD Radeon 8060S Graphics (RADV STRIX_HALO), 26.99.99AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, 64 GB RAMScene: scene-changes, from the repository's save kokiri-start (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=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); scene-changes: 3 game starts a side, field 20 s after 10 s warm-up, market 20 s after 10 s warm-up, kakariko 20 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `windows`, for the PR description
Verdict: could not be judged on windows (2 reports).
Hardware: 1: windows+amd+amd-proprietary+dgpu+window
AMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAM; 2: windows+nvidia+nvidia-proprietary+dgpu+window+dlss+xessNVIDIA GeForce RTX 3070, 621.35.0AMD Ryzen 5 5600X3D 6-Core Processor, 32 GB RAMScene: scene-changes, from the repository's save kokiri-start (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=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); scene-changes: 3 game starts a side, field 20 s after 10 s warm-up, market 20 s after 10 s warm-up, kakariko 20 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `igpu`, for the PR description
Verdict: could not be judged on igpu (2 reports).
Hardware: 1: linux+amd+radv+igpu
AMD Radeon 8060S Graphics (RADV STRIX_HALO), 26.99.99AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, 64 GB RAM; 2: linux+intel+anv+igpuIntel(R) Graphics (RKL GT1), 26.2.411th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz, 128 GB RAMScene: scene-changes, from the repository's save kokiri-start (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=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); scene-changes: 3 game starts a side, field 20 s after 10 s warm-up, market 20 s after 10 s warm-up, kakariko 20 s after 10 s warm-up; each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)Nothing was measured: no metric came back.
Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
Measurements on `steamdeck`, for the PR description
Verdict: queued on steamdeck (1 report).
Hardware: 1: linux+amd+radv+igpu+handheld
AMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAMScene: scene-changes, from the repository's save kokiri-start (vsync=2, resolution=1, frame_rate_cap=6, quality_preset=0, HOS_OUTPUT_RES=1280x720, RX_VK_AUTO_TUNE=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); scene-changes: 3 game starts a side, field 20 s after 10 s warm-up, market 20 s after 10 s warm-up, kakariko 20 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)Nothing was measured: no metric came back.
Flags and settings
None: the plan varied no setting, switch or build option.
As Markdown for the PR description:
The testers' hardware
nvidiaNVIDIA GeForce RTX 5070 Laptop GPU, 620.85.2AMD Ryzen AI 9 365 w/ Radeon 880M, 32 GB RAMnvidiaNVIDIA GeForce RTX 3070, 621.35.0AMD Ryzen 5 5600X3D 6-Core Processor, 32 GB RAMamdAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMamdAMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAMintelIntel(R) Graphics (RKL GT1), 26.2.411th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz, 128 GB RAMintelIntel(R) UHD Graphics 630, 0.404.2115Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz, 8 GB RAMlinux+radvAMD Radeon RX 9070 XT (RADV GFX1201), 26.3.1AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAMlinux+radvAMD Radeon 8060S Graphics (RADV STRIX_HALO), 26.99.99AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, 64 GB RAMwindowsAMD Radeon RX 9070 XT, 2.0.416AMD Ryzen 7 5800X3D 8-Core Processor, 32 GB RAMwindowsNVIDIA GeForce RTX 3070, 621.35.0AMD Ryzen 5 5600X3D 6-Core Processor, 32 GB RAMigpuAMD Radeon 8060S Graphics (RADV STRIX_HALO), 26.99.99AMD RYZEN AI MAX+ 395 w/ Radeon 8060S, 64 GB RAMigpuIntel(R) Graphics (RKL GT1), 26.2.411th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz, 128 GB RAMsteamdeckAMD Custom GPU 0405 (RADV VANGOGH), 26.1.99AMD Custom APU 0405, 16 GB RAMCan you add VRAM and FPS numbers?
Recommendation: Request changes. The arena retains up to 768 MiB even when Linux reports memory pressure, bypassing the existing capture-spare reclamation path. Its effect on frame times and total memory use against main is also unmeasured.
The change prepares capture buffers before copying and normally suballocates them from mapped blocks, aiming to reduce allocation and page-fault stalls. It adds persistent memory use and changes capture allocation and retirement on both platforms.
Blocking (1): must change before merging.
gpu/vk/vk_vma.cpp:767: Arena blocks remain allocated and mapped for the whole process, including under memory pressure. (more on the line) Do: Make unused arena blocks reclaimable under the existing memory-pressure policy, with safe lifetime handling for active allocations, or choose a pressure-aware bounded design that does not retain those blocks.Nits (1): optional.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_memory.cpp:1724: The reported arena hit count does not establish that the change reduces player-visible stalls or what it costs in memory. (more on the line) Do: Run interleaved base-versus-head comparisons in the same scene and settings, reporting average and 1% low FPS, median and tail frame times, capture faults, RAM and VRAM, including scene loads and the target Steam Machine. (@fixdoes its part first: Make the arena reclaimable under pressure to reduce the persistent memory cost.)gpu/vk/vk_memory.cpp:1630: The changed allocation and prefault paths still need coverage on the other supported systems they affect. (more on the line) Do: Complete the requested Steam Deck and Windows scene-load comparisons, and test the affected Tier 1 GPU and driver configurations with frame-time and memory observations. (@fixdoes its part first: Keep unmeasured platform-specific behavior disabled by default until its cost is known.)@fixcan do L1, L2, L3 and L4.Questions (1) (not confirmed from the code; they don't hold the recommendation)
tests/test_capture_buffers_ready.py:78: Is there a concrete failure in the production arena logic that this test misses?Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven. The PR reports 2,574,612 arena allocations and 9 standalone allocations in 132 minutes, but provides no comparable frame-time, page-fault, RAM, or VRAM measurements against base
299ed5b704. The reported 731,837 faults are from a different branch and session, with no after figure.Other systems: Linux memory-pressure handling cannot reclaim unused arena blocks. Windows also gets prefaulted spares and new prewarming behavior, despite the arena and ready switch defaulting off there. Vulkan drivers and GPUs can differ in memory allocation and mapping costs; Steam Deck and Windows runs are still outstanding.
Switches: RX_VK_CAP_READY defaults on on Linux and off on Windows; RX_VK_CAP_ARENA_MB defaults to 768 on Linux when ready is enabled and the spare allowance is at least 768 MiB, otherwise 0; RX_VK_CAP_PREFAULT defaults on on both platforms. All have switch-table rows. The defaults are not supported by comparative performance and memory measurements, and the arena default does not respond to memory pressure.
Reviewed:
742b45e8f1against299ed5b704: Read the repository rules, PR template, standards, diff, commits, capture-buffer allocation and retirement paths, arena implementation, recorder boundary, memory-pressure and accounting paths, and the new test. Skimmed the remaining changed tests and surrounding renderer code. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. The larger changed code files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands from the project, builds, or tests were run, as requested. The author reports a Linux game build and the listed tests passing; CI is still running.
Overlaps and merge order: Unknown; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -1582,1 +1721,4 @@}});}bool cap_buf_get(uint64_t need, VkBuffer& buffer, VmaAllocation& alloc, void*& map, uint64_t& size) {L3 (should fix): The reported arena hit count does not establish that the change reduces player-visible stalls or what it costs in memory.
When: The before and after observations cover different revisions and durations, and the after run has no page-fault or frame-time measurement. The arena also touches and retains memory that the old path may not need.
Do: Run interleaved base-versus-head comparisons in the same scene and settings, reporting average and 1% low FPS, median and tail frame times, capture faults, RAM and VRAM, including scene loads and the target Steam Machine.
@ -1536,2 +1627,4 @@int cap_prewarm_index(uint64_t size) { return size <= (32ull << 20) ? 0 : size <= (64ull << 20) ? 1 : size <= (128ull << 20) ? 2 : size <= (192ull << 20) ? 3 : size <= (256ull << 20) ? 4 : -1; }void cap_spare_make(uint64_t size, int index) {SetThreadDescription(GetCurrentThread(), L"mkw_vk capture spare"); // (not the game's main thread's name, which it inherits)VkBuffer b = VK_NULL_HANDLE;L4 (should fix): The changed allocation and prefault paths still need coverage on the other supported systems they affect.
When: Windows defaults to prefaulting newly prewarmed buffers and can create a 256 MiB spare; Linux drivers and Steam Deck may have different mapping, memory-pressure and timing behavior from the tested RADV machine.
Do: Complete the requested Steam Deck and Windows scene-load comparisons, and test the affected Tier 1 GPU and driver configurations with frame-time and memory observations.
@ -715,0 +764,4 @@a.memory = info.deviceMemory;const auto t0 = std::chrono::steady_clock::now();const volatile uint8_t* base = static_cast<const volatile uint8_t*>(info.pMappedData) - info.offset;for (uint64_t off = 0; off < block && !stop->load(); off += 4096) (void)base[off]; // (its pages mapped, once)L1 (blocking): Arena blocks remain allocated and mapped for the whole process, including under memory pressure.
When: On a Linux system eligible for the default arena, the first capture commits and touches up to 768 MiB. Later, linux_pressure_shortfall() trims cap_free, but retired arena allocations return to their pools instead, so even completely unused arena blocks cannot be reclaimed and compete with the game and other applications for RAM.
Do: Make unused arena blocks reclaimable under the existing memory-pressure policy, with safe lifetime handling for active allocations, or choose a pressure-aware bounded design that does not retain those blocks.
AMD Lab Market A/B:
mainee9e1ed76(A) against PR head742b45e8f167merged onto it (B), two builds.Within the run-to-run spread. Median average FPS changed by -0.44%.
main)Market (child), headless Linux 7.3.3-1-cachyos, Core i7-9700K, Radeon RX 580 with Mesa RADV 3:26.2.6-1, 1280x720 output at 33% render scale, uncapped with V-Sync and frame generation off. Three alternating pairs, 60 seconds per capture after warm-up, each a timing job of the queue.
Each run's last
vk: capture bufferslog line:The arena works on this PC (RX 580, 8 GB): every buffer in these lines came from it and none was made at a capture, with about 41 to 43 of its 768 MB in use.
mainhas no such line to compare. The renderer's CPU thread was slightly higher with the PR (median 9.59 against 9.47 ms, ranges overlapping), too small to read much into. This is a standing scene after one teleport, not the repeated zone changes where the PR expects its gain.Local (RTX 3090) Market A/B:
mainee9e1ed76(A) against PR head742b45e8f167merged onto it (B), two builds.Within the run-to-run spread. Median average FPS changed by -0.4% (125.3 to 124.8).
main) fpsBoth sides of pair 1 ran about 10 fps under the others (this PC was busy with other work), and its B capture was the worse one; pairs 2 and 3 agree within 0.5 fps.
The arena is in use with the PR: in each B run's last
vk: capture buffersline every buffer came from it and 0 were made at a capture (26 to 46 of 768 MB in use).mainhas no such line. This is a standing scene after one teleport, not the repeated zone changes where the PR expects its gain.CPU-bound (GPU 5.1 ms of a frame of about 8 ms). Market (child), headless Linux 7.3.3-1-cachyos, Ryzen 9 7900X, GeForce RTX 3090 with NVIDIA driver 620.70.06, 1920x1080 output at 100% render scale, no upscaler, uncapped with V-Sync and frame generation off. 60 seconds per capture after warm-up, each a timing job of the queue.
dev.py abmarked the set only for the two builds' version strings and an internalLONGSHOT_CRASH_BLOCKnumber differing between runs, neither of which is a setting under test.Beanstalk test farm
Commit
2c439c1· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.I corrected L1 in
a5a08d0f8. I also have some numbers for you:I think your A/B runs are the most accurate FPS numbers I've seen, and no change in a static scene is totally reasonable. The value add here is the fault storms at area changes.
I don't think there's a failure this doesn't cover. And the nit is reasonable: each switch only disables its own component, so I reworded Risks to reflect that.
AMD lab A/B/A/B:
main7bc53f841(A) against this PR's heada5a08d0f8merged onto it (B). AMD lab PC: Linux 7.3.3-1-cachyos, Core i7-9700K, 15 GB RAM (zram swap), Radeon RX 580 with Mesa RADV 3:26.2.6-1. A/B/A/B, 90 s per run after a 15 s warm-up, each a timing job in the queue, headless, uncapped, V-Sync and frame generation off.Scenario: area changes. After one untimed lap, teleports through Hyrule Field, Kakariko, Kokiri Forest, Lost Woods and the Market, 6 s apart plus loading. 1280x720 output, 33 % render scale.
Major faults nearly gone and less time in hitches, but the replay's memory sync costs about 0.4 ms more a frame. Both held in both pairs.
memsync_ms, mean of the 12-50 ms framesmemsync_ms, mean of the frames under 5 msmemsync_ms, summed over the runvk: capture buffers (600 presents): 2415 in the arena and 2415 back to it (3 blocks, 33 of 768 MB in use, 0 MB given back under memory pressure so far); 0 made at a capture ...(B2: 2305, 86 of 768 MB).a frame's replay time (ms): ... memory syncfigure is higher on B too (0.67-0.97 ms in each B run's last five lines, 0.36-0.48 ms in A's). Thememsync_msmean of the 12-50 ms frames in #3114's runs, on the same lab PC just before these, was 0.59-0.62 ms on both of its sides, so the machine itself had not shifted. I did not find the cause.Not covered: memory pressure (the arena gave nothing back here), Steam Deck, Windows. An earlier still-Market A/B here (on
742b45e8f) was within the run-to-run spread.@review
Recommendation: Request changes. The arena can still retain empty blocks throughout a memory-pressure event when no arena buffer is retired during that event. Area-change runs show fewer major faults and less time in long frames, but also about 0.4 ms more memory-sync time per frame.
The change prepares capture memory ahead of use and reuses mapped arena blocks to reduce allocation and page-fault stalls. It adds up to 768 MB of host memory by default on eligible Linux systems and more allocation and synchronization complexity.
Blocking (1): must change before merging.
gpu/vk/vk_vma.cpp:767: Empty arena blocks are reclaimed only when an arena buffer is retired during pressure. When: If all arena buffers retire before memory pressure begins, the pressure event has no reclamation call and the empty mapped blocks remain allocated until another arena buffer retires while pressure persists. Do: Invoke arena reclamation from the existing memory-pressure handling path as well as on arena-buffer retirement.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_memory.cpp:1724: The player-visible area-change results are now measured, but the host-memory cost against main remains unknown. When: The arena reserves up to 768 MB on eligible Linux systems; the reported arena usage does not show how much additional resident or committed memory the same workload uses compared with main. Do: Compare peak and steady host-memory use and swap activity against main over repeated matching area-change runs. (@fixdoes its part first: Make the arena reclaimable under pressure to reduce the persistent memory cost.)gpu/vk/vk_memory.cpp:1630: The changed allocation and prefault paths still need coverage on the other supported systems they affect. When: Windows defaults to prefaulting newly prewarmed buffers and can create a 256 MiB spare; Linux drivers and Steam Deck may have different mapping, memory-pressure and timing behavior from the tested RADV machine. Do: Complete the requested Steam Deck and Windows scene-load comparisons, and test the affected Tier 1 GPU and driver configurations with frame-time and memory observations. (@fixdoes its part first: Keep unmeasured platform-specific behavior disabled by default until its cost is known.)@fixcan do L1, L3 and L4.Since the last review (on
742b45e8f1)Resolved: L2 (The Risks section says each new switch individually restores the old behavior, but each co…)
Still open: L1 (Empty arena blocks are reclaimed only when an arena buffer is retired during pressure.); L3 (The player-visible area-change results are now measured, but the host-memory cost against…); L4 (The changed allocation and prefault paths still need coverage on the other supported syste…)
Checks: Still running: 10 checks.
Also noticed (2; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes, in the AMD lab area-change runs: major faults fell from 12,229 and 11,379 to 14 and 17, while time in frames of at least 50 ms fell from 5.2 and 4.4 seconds to 3.2 and 3.7 seconds. The same runs showed mean memory-sync time roughly 0.4 ms higher per frame; the memory cost has not been compared against main.
Other systems: The arena and ready-buffer paths affect Linux Vulkan drivers and memory budgets; the recorded AMD and NVIDIA Linux runs cover normal operation but not pressure reclamation in game. Windows still uses the prefaulted spare path and needs its requested scene-load comparison; Steam Deck remains untested.
Switches: RX_VK_CAP_PREFAULT defaults on; RX_VK_CAP_READY defaults on for Linux and off for Windows; RX_VK_CAP_ARENA_MB defaults to 768 MB on eligible Linux configurations and otherwise 0. The Linux defaults improve the measured area-change workload, but their memory and memory-sync costs still need evaluation. Rows are present in switches.def.
Reviewed:
a5a08d0f83against299ed5b704: Read repository agent and contribution rules and the pull request template; docs/review-checklist.md is absent. Read the fix diff and the relevant arena, capture-free and pressure call sites; skimmed the changed test harness and switch rows. The full original diff and all changed code files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run for this review. The author reports game-free tests and a Linux build; CI is still running. Recorded game runs and their limits are described above.
Overlaps and merge order: Not checked; network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@fix
a5a08d0f832c439c1b60Recommendation: Approve. The code is ready: only testing is left. The area-change A/B shows fewer major faults and less time in long hitches, but also about 0.4 ms more memory-sync time per frame. Comparable host-memory measurements and the requested Steam Deck and Windows runs remain outstanding. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
2c439c1b60. I rebased it ontomain(f5c97a608e). I edited its description to match the change.Changed
Changed in part (the rest is for the author)
Left for the author
Nothing was built or run: the checks run again on the new head.
Capture buffers use prefaulted mapped arena blocks to reduce allocation and page-fault stalls. The fix also reclaims empty blocks during Linux memory-pressure samples; it retains the arena but adds persistent host-memory use and synchronization work.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/vk_memory.cpp:1724: The player-visible area-change results are now measured, but the host-memory cost against main remains unknown. When: The arena reserves up to 768 MB on eligible Linux systems; the reported arena usage does not show how much additional resident or committed memory the same workload uses compared with main. Do: Compare peak and steady host-memory use and swap activity against main over repeated matching area-change runs.gpu/vk/vk_memory.cpp:1630: The changed allocation and prefault paths still need coverage on the other supported systems they affect. When: Windows defaults to prefaulting newly prewarmed buffers and can create a 256 MiB spare; Linux drivers and Steam Deck may have different mapping, memory-pressure and timing behavior from the tested RADV machine. Do: Complete the requested Steam Deck and Windows scene-load comparisons, and test the affected Tier 1 GPU and driver configurations with frame-time and memory observations.Checks: they run again on this head; a failure shows on the pull request.
Also noticed (4; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes for the measured Linux area-change workload: major faults fell from 12,229 and 11,379 to 14 and 17, and time in frames of at least 50 ms fell from 5.2 and 4.4 seconds to 3.2 and 3.7 seconds in HumanBean's two A/B pairs. Mean memory-sync time for 12–50 ms frames rose from 0.63–0.65 ms to 1.05–1.08 ms; its cause remains unknown.
Other systems: The arena and ready path default on for Linux, including Steam Deck; Windows retains the prefaulted spare path by default. Steam Deck play, Windows scene loads and comparable host-memory use under pressure remain unmeasured.
Switches: RX_VK_CAP_PREFAULT defaults on; RX_VK_CAP_READY defaults on Linux and off Windows; RX_VK_CAP_ARENA_MB defaults to 768 MB when ready is on and otherwise 0, with a 2048 MB maximum. The rows are present in switches.def; the remaining platform and memory measurements are needed to judge the defaults fully.
Reviewed:
2c439c1b60againstf5c97a608e: Read AGENTS.md, CONTRIBUTING.md, the complete fix diff, tests/test_linux_pressure.py and the relevant arena, capture and pressure-handling sections. Skimmed the larger base diff and commit list; the specified base diff includes 1,058 files beyond the listed pull-request changes, so it was not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run code were executed. The author reports Linux game and test runs; CI has not yet run on this head.
Overlaps and merge order: Not checked; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.