Repository navigation
fix(agc): free a completed batch's command buffer instead of keeping it - #9565
oneandonlydean merged 5 commits into
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Early review feedback while this remains a draft: the Linux red/green allocation probe gives useful evidence that completed batches free their command buffers, and the change is scoped to the recorder. Before marking this ready, please resolve the listed overlap with #9289 in |
jotitadev
left a comment
There was a problem hiding this comment.
Ran this on real hardware (Linux, NVIDIA and lavapipe). Head 22bf8fcc9, merged onto origin/main at 6ef5a1c4c.
Machine: Ubuntu 26.04, GCC 15.2.0, ninja -j3, ANYPS5_NO_SHADER_CACHE=1, device picked with VK_ICD_FILENAMES.
agc_recorder_command_buffer_release (the new --command-buffer-release-only case), ctest --repeat until-fail:3:
| device | result |
|---|---|
| NVIDIA GeForce RTX 3070 | Passed (3/3) |
| llvmpipe (lavapipe, LLVM 21.1.8) | Passed (3/3) |
Negative control: reverting Recorder.cpp/Recorder.hpp to origin/main and keeping only the test + its add_test makes it fail on both devices with the expected message, so the test is a genuine red→green guard:
AGC graphics: command buffer release: after 1 completed batches 1 command buffers were allocated and 0 freed (a completed batch kept its command buffer)
No regression in the recorder/graphics ^agc suite versus origin/main on the RTX 3070 (same pass set; lds_atomics64/driver_flip/display_buffer_dcc excluded).
GPUs tested: NVIDIA GeForce RTX 3070 (proprietary), llvmpipe/lavapipe (Mesa, software).
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
|
@jotitadev thanks for running it on the RTX 3070 and lavapipe, with the negative control and the |
|
Windows native cross-test of22bf8fcc92 completed on c915980. Baseline62cf2d1a04 is current main7e2ba73e4 plus our #9591/#6918 prerequisites and #9652; the memory change is the only difference between these recorder arms. All authors' commits retained: Windows11 10.0.26200, RTX5070Ti/NVIDIA617.42, Ryzen7800X3D, WinLibs GCC15.2r7 Release, SPIRV Tools OFF:
Clean final packaging and all369 runtime-module SHA256 values verified before staging. A combined007 loading probe has just started with the same28GiB private/2GiB free guard. No isolated Windows memory saving claimed yet: this title run also carries #9652, and its prior large pipeline was not completely warmed. I will report observed private memory and your freed-buffer counter without attributing an unpaired saving. Raw title data stays local. AI-assisted: Codex. |
|
Correction to the title-run status above: c915's first007 launch aborted after about29s with I am separating the changes: isolated memory headc4162b2156b8 differs from c915 only by retaining the old joinedRun predicate, plus removing #9652's added fixture assertion. Rebuilt successfully, same recorder/import native gate is running before its title control. No attribution to #9565 yet. The other author's coordination thread has the exact heads: |
|
@Scramblrrrr thanks for the Windows run on the RTX 5070 Ti, with the red control against |
|
Isolated #9565 control c4162b2 reached the correctly rendered offline007 menu and did not reproduce c915's VOP2 startup abort during its17-minute run. Menu78/62.137794s=1.25527FPS, GPU196.17083ms/present, effectively unchanged versus b36's1.22951FPS. Freed-command-buffer counter was active. This is one run, not sufficient to attribute the combined build's early failure. Resume09:13:12.714UTC; the game then logged a RenderThread access violation reading0xffffffffffffffff at the previously discussed terrain/quadtree site. The guard terminated it at09:14:29.572UTC,76.858s after input, while the fatal report was being written. It was NOT the28GiBprivate cap: last private23,834,996,736bytes. Free memory fell from~5.3GB just after a trim to166MB at the final sample; the causal ownership of that late drop is unverified. The guest fault is present before guard termination, so this must not be reported as a pure memory-guard exit or a completed gameplay pass. No isolated Windows RAM-saving claim from this pair. The five-frame menu trace has no dropped events: p50803.7ms/GPU196.0ms, queue0~748.6ms busy per frame, other queues mostly waiting. Next controlled work is #8887; runtime remains c416, no opcode/guest-title bypass. AI-assisted: Codex. |
|
Rechecked the exact head The stated ordering with #9289 is documented and its author agrees. One integration caveat: #9289 is stacked on open #9176 → #9287, neither of which is in this PR's ancestry. Three-way merge checks of #9565 with #9176/#9287/#9289 flag shared AGC files and I found no isolated code blocker in the current diff. |
MarcZX10
left a comment
There was a problem hiding this comment.
The updated head 1da6feaf1699ecdaaee9eaa1a124cf22466edafc has strong red/green evidence: the new resolver-probe test fails against main and passes with the implementation, repeated on llvmpipe, RTX 3070 and RTX 5070 Ti; the paired validation-layer comparisons report no new VUIDs. Hosted eligibility, conventions, labels and report pass; product and relinker jobs are skipped. I did not run a local GPU build.
I refreshed upstream/main to 329efe1bfdaff116c57cdf62718026ee4f5521ae. This head is 3 ahead / 45 behind (merge base 4777caca343bf09a3fe245830acd9e9f433e8e18); current-base merge-tree, diff-check and conventions pass. The intervening main changes do not touch this PR’s recorder implementation, test or CMake registration. Please bring the branch up to current main and rerun the focused command-buffer-release recorder case before merge, per the branch rule.
The current #9289 head 2f412bb25fd3c389381ad6cac1cabda75137438c includes the #9176 → #9287 stack, but it does not contain this PR’s latest head; the current pairwise merge-tree still conflicts in Graphics/src/Recorder.cpp. The stated order is #9565 first, then #9289 rebases. Please ensure #9289 is rebased over the merged #9565 head and the combined recorder tests are run before that stacked change merges. This is an integration follow-up, not a new defect in this PR’s isolated fix.
|
Thanks, @MarcZX10. |
|
I’ve noticed that asking you to hold this PR was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course. |
The recorder kept up to 64 completed command buffers for reuse and began new batches on them. fablevoid found that on Windows drivers a command buffer keeps the host memory of its largest recording until it is freed: neither the implicit reset at begin nor a releasing reset gives that memory back. Every kept command buffer held the peak of its own recordings, and in a title run the driver's command arenas grew by 3.4 GiB in 17 s until the run hit the RAM cap. Recorder::release now frees a batch's command buffer, and every batch allocates its own from the context's pool, so the pool holds no more than the batches still recording or in flight need. Fences are still kept for reuse. agc_recorder_command_buffer_release (new mode --command-buffer-release-only of the recorder tests) counts the recorder's vkAllocateCommandBuffers and vkFreeCommandBuffers calls through a resolver probe over three completed batches: each must free the command buffer it allocated. Adapts fable-void's dfbbdfd (his recorder keeps a pool and a spare list per stream; main has one of each). His GPU test idle_command_memory reads Windows private bytes through a test fixture main does not have and is not carried.
With APS5_PROFILE_DRAW set, the [recorder] submits line now counts the command buffers freed when their batch was released and the fences kept for reuse (cumulative). The host memory a driver held in those command buffers is not visible to the recorder; on Windows the process's private bytes show it.
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
3c44708 to
c47f504
Compare
|
@adriadam10 I've added myself as a co-assignee here (you stay on it). #9287 and #9289 build on this PR and have already passed review on our side, so I'd like to get this one reviewed too and keep both moving. If you'd rather keep it to yourself, just say so and I'll step back. |
…st list, add agc_recorder_command_buffer_release
# Conflicts: # core/libs/prx/libSceAgcDriver/CMakeLists.txt
✅ NVIDIA GPU test: passedPR head
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (2, not counted against this PR)Validated but not compared (1, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 425 tests)Skipped (41)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
What
The recorder keeps up to 64 completed command buffers for reuse and begins new batches on them. fable-void found that on Windows drivers, a command buffer keeps the host memory of its largest recording until it is freed. Neither the implicit reset at begin nor a releasing reset gives that memory back. So every kept command buffer holds the peak of its own recordings. In one of his title runs, the driver's command arenas grew by 3.4 GiB in 17 s, until the run hit the RAM cap.
This adapts fable-void's dfbbdfd from his fork (
wip/new-gpu-path). His recorder keeps a pool and a spare list per stream, andmainhas one of each:Recorder::releasefrees a batch's command buffer, and every batch allocates its own from the context's pool. The pool then holds only what batches still recording or in flight need. Fences are still kept for reuse. The spare list's comment, which described command buffers being kept, goes with them.APS5_PROFILE_DRAWset, the[recorder] submitsline also givescommand buffers freed at batch release N, fences kept for reuse N. Without the profile it costs one test of astatic const bool.The cost is one
vkAllocateCommandBuffersper batch, wheremainreused a kept one.fable-void's own test,
idle_command_memory, reads Windows private bytes through a test fixturemaindoesn't have, so it isn't carried.Overlap: checked with
git merge-treeagainst every open PR touching these files, onmain8c26eac. Two conflict:Recorder::release, and keepsmain's reuse of the batch's own command buffer. The two touch the same lines ofrelease. Composed, the batch's own command buffer is freed and the chunk handling stays as feat(agc): batch a dispatch run's staged copy-ins ahead of it #9289 has it. This PR goes first, as Celegans12 agreed (reply), and feat(agc): batch a dispatch run's staged copy-ins ahead of it #9289 rebases over it (note).tests/Recorder.cpp'smain(). Their library changes don't meet: fix(agc): save the guest bytes of results that become pending over a surface that is no longer fully write-watched #7048's are inTexture.cpp. Neither needs to wait, and whichever merges second keeps both test modes (note).Tested
agc_recorder_command_buffer_release(new mode--command-buffer-release-onlyof the recorder tests) counts the recorder'svkAllocateCommandBuffersandvkFreeCommandBufferscalls through a resolver probe, over three completed batches. Each batch must free the command buffer it allocated.main's code, it fails ×3 with "command buffer release: after 1 completed batches 1 command buffers were allocated and 0 freed (a completed batch kept its command buffer)".maincf2c667: 1812/1818, with the same 6 failures asmain.mainagainst this PR (CONTRIBUTING's AGC rule), on one GitHub Linux runner (run). Both runs usedVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1andctest -V, withVK_LOADER_DEBUG=layerto show the layer loading. The device was llvmpipe (LLVM 20.1.2) on Mesa 25.2.8, Ubuntu 24.04.5, Khronos validation layers 1.3.275.agc_recorder_command_buffer_release, plus the 56 tests whose build inputs this PR touches, such asagc_storage_write_back,agc_host_import_unmapandagc_pipeline_cache: 57 with this PR and 56 onmain, where the new test doesn't exist. On both trees 6 of them skip on llvmpipe,agc_unit_shadowamong them, and none fail:mainran its other 50 once and this PR its other 51 three times.mainand 153 with this PR, and neither log haswas not found.VUID-VkImageViewCreateInfo-usage-02275andVUID-vkCmdCopyBuffer-srcBuffer-00118, from tests this PR doesn't change. This PR adds noVUID-message.main6ef5a1c,ANYPS5_NO_SHADER_CACHE=1.agc_recorder_command_buffer_releasepasses 3 of 3 on an NVIDIA GeForce RTX 3070 (proprietary driver) and on llvmpipe (LLVM 21.1.8).Recorder.cppandRecorder.hppatmainand the test kept, it fails on both devices with the expected message.^agctests have the same pass set asmainon the 3070 (lds_atomics64,driver_flipanddisplay_buffer_dccleft out).main7e2ba73 plus other open PRs, with this PR's change the only difference between the two arms.main'sRecorder.cppandRecorder.hppand the new test, it fails after batch 1, with 1 command buffer allocated and 0 freed. With this PR it passes.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andctest -V. Both arms log the same twoVUID-VkImageViewCreateInfo-usage-02275errors, fromagc_sampled_storage_base_level_usage. This PR adds noVUID-message.main4777cac merged in (clean; the PR's own diff is unchanged), on GitHub's runners (run): On Linux,agc_recorder_command_buffer_releaseand 49 of the other 55 AGC tests run with it pass 10 of 10, and 6 skip; none fail. On Windows all 69 build: 3 pass 10 of 10 and the other 66, the new test among them, skip without a Vulkan device. On Linux's one run withmain's implementation,agc_recorder_command_buffer_releasefails,agc_gpu_timing_completetimes out, 48 pass and 6 skip. libkernel's suite passes on both and libc's on Windows. On Linux libc's one failure isprecise_wait, a timing test this PR doesn't touch.mainb7d1d47 merged in (clean; the PR's own diff is unchanged), on GitHub's runners (run):agc_recorder_command_buffer_releaseand the AGC tests run with it pass 10 of 10. On Linux that is 56 tests, 6 of them skipped. On Windows all 69 build and pass, and 66 skip without a Vulkan device. On Linuxagc_recorder_command_buffer_releasefails withmain's implementation. The libc and libkernel suites pass on both runners. The libc and libkernel suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.check_conventions.pypasses, with no comment lines added.APS5_PROFILE_DRAW=1; no fatal error. The last[recorder]line readssubmits 44845, ... command buffers freed at batch release 44844, fences kept for reuse 44844, so the release path runs for every batch in this title.mainf3eb573 (run). The one conflict was the Windowsset_tests_propertieslist incore/libs/prx/libSceAgcDriver/CMakeLists.txt, where Astronaut10's perf(agc): repeat a draw shape's resident targets and pipeline instead of looking them up again #11696 addsagc_repeat_storage_guardand this PR addsagc_recorder_command_buffer_release; the merge keeps both. This PR's other changed lines are the same. On Linux,agc_recorder_command_buffer_releasefails withmain's code and passes 10 runs in a row with the change, run with the recorder and AGC tests that share its executable and perf(agc): repeat a draw shape's resident targets and pipeline instead of looking them up again #11696'sagc_repeat_storage_guard. Linux: 75 run, 68 pass, 7 skip, 0 fail; the skips (agc_driver_unit_shadow,agc_driver_unit_shadow_budget,agc_import_settle_initial_dcc,agc_pipeline_cache_file,agc_shadowed_key_stores,agc_storage_clear_hand_overandagc_unit_shadow) skip withmain's code too. Windows: 91 run, 4 pass, 87 skip (the Vulkan device tests), 0 fail. Suites: libc and libkernel pass on Linux (171 and 289). On Windows libc passes (199), and libkernel passes 309 of 312:exec_arguments,guest_timed_join_import_libkernel_sysandguest_timed_join_import_libkernel_webfail at their setup in the verify's Windows build (FileNotFoundErrorstarting the title, or copying the libraries they load), withmain's code too, and pass inmain's own Windows job at 1829def (job). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)