Repository navigation
fix(agc): keep resident heap mirrors without host copies - #15296
Prophet069 wants to merge 6 commits into
Conversation
A heap mirror slab refused by a full device heap stopped the title. The slab now falls back to host memory, as buffers and images already do, and a refusal lowers the heap mirror budget, evicts down to it and retries; a failed bind gives back the blocks it took. A slab is refused before the device heap is exhausted: when all live slabs would pass APS5_HEAP_MIRROR_MIB or when the device heap would keep less than 256 MiB of its reported budget, so the shrink and sweep path runs before Windows pages device memory. A budget lowered by refusals is a soft target a mirror may pass up to the configured budget when nothing can be evicted, and the headroom refusal is not repeated within two seconds on one thread. Blocks are taken from the fullest slab, so partly used slabs drain and are freed. Nonzero scans remember each 64 KiB block with its write generation and read only blocks written since. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
XairRrR
left a comment
There was a problem hiding this comment.
Reviewed — comments
The PR merges and builds, the heap-mirror tests pass, and the validation comparison shows no new VUIDs. But the new tests also pass with main's production code, and the new slab-refusal, budget-shrink and nonzero-scan-cache paths have no test.
What I ran
Head a64a9a4a280cb5be0f80bb01ce98812e56bcda6d, main 5cb015caaaaf83f8ee431414ee6a457b5b307d49, merged tree a5a36646c486d472781b0f1732a84113e9acecda (--no-ff), Debian 13 VM, GCC 14.2.0, lavapipe (Mesa 26.1.6, LLVM 19).
git diff --check 5cb015caaaaf83f8ee431414ee6a457b5b307d49...a64a9a4a280cb5be0f80bb01ce98812e56bcda6d
python3 tools/check_conventions.py --base 5cb015caaaaf83f8ee431414ee6a457b5b307d49
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "heap_mirror|lod_clamp"
# negative control: the five production files from main
git show 5cb015caaa…:core/libs/prx/libSceAgcDriver/Graphics/{include/Context.hpp,include/GuestBufferMemory.hpp,include/ResidentMirror.hpp,src/GuestBufferMemory.cpp,src/ResidentMirror.cpp} > …
ninja -C build -j32 -l32 agc_driver_resident_heap_mirror_tests agc_driver_image_sample_lod_clamp_tests
ctest --test-dir build --output-on-failure -R "^agc_driver_resident_heap_mirror$|lod_clamp_shader_lane"
# restore the merged files from a5a36646c4…, rebuild everything
ninja -C build -j32 -l32
git status --porcelain
Results
| Check | Result |
|---|---|
git diff --check |
clean |
check_conventions.py |
All conventions checks passed |
| Configure / build / libs (script) | ok |
agc_driver_resident_heap_mirror (with the new PartialBlockTests and ConcurrentWriteTests) |
passed |
agc_heap_mirror_*, agc_sparse_heap_mirror_* (10 tests) |
passed |
agc_driver_image_sample_lod_clamp_shader_lane (listed by the script as a new failure) |
fails, and fails the same way with main's production files, so it comes from main (baseline was the older 096c45570f), not from this PR |
unwrap_self_..._destination_directory_group (listed as a new failure) |
a Python tool test failing on os.chown in a temporary directory (EINVAL); this PR changes no tool or relinker file, so it is the environment, not the PR |
| Validation layer (script, 759 tests) | layer loaded in 758, missing in none, 0 tests with new VUID- lines |
| Worktree after restore | git status --porcelain empty |
lod_clamp_shader_lane output (same on merged tree and with main's production files)
AGC graphics: image_sample_lz through the S# that holds the LOD at 0 with T# MIN_LOD 768 over BASE_LEVEL 0 with a second S# of words 1 0 and 2 5242880, and a second T# of MIN_LOD 0 and LAST_LEVEL 0: thread 0 component 1 is 0.000000, expected 0.062500
Negative control
I put back main's versions of Context.hpp, GuestBufferMemory.hpp, ResidentMirror.hpp, GuestBufferMemory.cpp and ResidentMirror.cpp, kept the PR's tests/execution/ResidentHeapMirror.cpp, and rebuilt. agc_driver_resident_heap_mirror still passed (2.23 s).
That can be expected: the new partial-block, in-flight CPU write and double-dispatch cases describe behaviour that main's host-copy design already had. So they guard against regressions in the rewrite, but they don't show the change itself. Nothing tests the host-memory saving, the slab refusal, the budget shrink-and-retry loop or the nonzero-scan cache. I then put the merged files back, rebuilt the whole tree, and checked that the worktree is clean.
Findings
Blocking
None.
Non-blocking
- No test reaches the slab-refusal and budget-shrink path.
ResidentMemory::refuseSlab(core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp:176),shrinkHeapMirrorBudget(core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:2814) and the 8-attempt retry loops (GuestBufferMemory.cpp:2849,GuestBufferMemory.cpp:3387) are the fix the PR depends on for PPSA02015. They run only when the device heap fills or when slabs passAPS5_HEAP_MIRROR_MIB. The existing tests pass onmainwithout any of this code. Suggested fix: add a case that sets a small budget withSetHeapMirrorBudget(whichHeapMirrorSlabBudgetalready reads). It should check that a slab past it is refused, the budget is lowered, an older mirror is evicted, and the new mirror is still built. - The lowered budget never goes back up.
heapMirrorMemoryLimit(GuestBufferMemory.cpp:2714) is only ever lowered, atGuestBufferMemory.cpp:2824, and nothing raises it again. So one refusal caused by a temporary peak in device-heap use leavesheapMirrorBudget()lowered for the rest of the process. The soft-target escape inreserveHeapBytes/growResidentonly applies on a retry, after a sweep has already evicted mirrors. So after one temporary peak, mirrors keep being evicted early for the whole session. Suggested fix: raise the limit again once the reported heap has headroom, or say in the description that the drop is permanent by design. - The refusal is recognised by matching the error text.
shrinkHeapMirrorBudgettestserror.what()for"of a heap mirror slab". A change to either message (refuseSlaborallocate's operation string) would silently turn off the retry and bring back the stop this PR fixes. Suggested fix: use a dedicated exception type derived fromstd::runtime_error, or a flag returned byTake. Context::HeapReport::Fitsis never used (core/libs/prx/libSceAgcDriver/Graphics/include/Context.hpp:340).refuseSlabdoes its own headroom arithmetic. Either useFitsor remove it.- The nonzero-scan cache is shared global state.
GuestNonzeroBlocksnow keeps a process-wideunordered_mapof up to 4M entries (ResidentMirror.cpp:379-380) behind one mutex, which it takes once or twice per 64 KiB block. The whole map is dropped when it fills (ResidentMirror.cpp:408). Its correctness depends onUnchangedSincecoming back false for pages that were unmapped and mapped again (ForgetPages). I didn't find a test of that for this cache (ReusedAddressTestspasses, but it also passed before the cache existed). This is the third separate change in the first commit; see the next item. - One topic per PR. Besides dropping the host copies, the PR also includes a cherry-picked commit by another author (
8a30d9a70f8b, "store a resident heap mirror's write-back from its readback buffer"), the slab-refusal and fallback work, fullest-slab allocation, and the scan cache (1743177ae4af). The checklist namesDepends on: #15295, #12827. If those PRs carry some of these commits, the commits would be merged twice or conflict. Please state which commits belong to which PR, or move the separate fixes into their own PRs.
Not verified
- The claimed host-memory saving and the PPSA02015 world-load result: I launched no title. lavapipe has a 64 GiB host-backed heap, so the device-heap headroom refusal and the host-memory fallback never run here.
- The Windows/NVIDIA validation run in the description: I only ran on lavapipe.
- The contents of #15295 and #12827: no context was available, so I couldn't check the overlap described in finding 6.
- Whether a
RecordStagingCopiesflush that uploads newly marked ranges aftertakeHeapReferencesrecorded the device reference could put those bytes into the write-back. That would happen if the range differs between the reference and the readback without any shader store. I didn't build a test for this ordering. The newConcurrentWriteTestsdoesn't cover it.
To get this to a good state
- Add a test that reaches the refusal, shrink, sweep and retry path (finding 1). Ideally also add one for the scan cache across an unmap and remap at the same address (finding 5).
- Decide whether the lowered budget should recover (finding 2), and replace the error-text match (finding 3).
- Remove or use
HeapReport::Fits(finding 4). - Clarify how this PR's commits relate to #15295 and #12827, or split the separate fixes out (finding 6).
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, 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)Validation IDs already present on main (4 IDs in 517 tests)Skipped (44)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. |
|
Hi Prophet069, This head contains the exact commit from #15295 plus four follow-up commits, while its checklist says Please also settle the overlap/order with open #12827 (the same readback-vector-copy removal) and #12840 (BDA heap-store work). At their current heads, combining this PR with #12827 conflicts in |
…ost fallback A slab refused for headroom or for APS5_HEAP_MIRROR_MIB while the heap mirrors held 256 MiB or less stopped the title: the budget shrink has nothing to evict there. Refuse a slab only while more than that is held, so the allocation and its host-memory fallback run otherwise. Refusals and failed slab allocations throw HeapMirrorSlabRefused instead of being matched by their text, a budget lowered by a refusal recovers after 30 s, and the headroom check uses HeapReport::Fits. A test reports the device heap full and checks that small mirrors are still made. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k buffer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit c12a20f)
A resident heap mirror kept a 16 MiB host copy per slab, so rebuilding a multi-GB mirror needed as much host memory again. Refreshes now only mark the changed ranges, the flush reads them straight from guest memory into bounded staging and zero-fills new blocks on the device, and the write-back reference of each use is a device copy recorded after the uploads and before the shader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… references inside completions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…waves RecordStagingCopies flushed changed resident heap mirror blocks without allowing a wait, so a multi-GiB mirror upload held every 64 MiB staging segment until the batch finished, gigabytes of host memory at once. It now waits after each 256 MiB wave like UploadFinish does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a64a9a4 to
7bbf091
Compare
|
Thanks. This PR is stacked: it builds on #15295 (its first two commits) and on #12827 (the cherry-picked write-back commit); its own commits are "drop the host copies of resident heap mirrors", "count heap mirror transfer buffers as kept bytes and record references inside completions" and "let staging-copy recording wait between heap mirror upload waves". The checklist says On the review points: the refusal type, the budget recovery and |
|
Hi Prophet069, Thanks for declaring
|
|
@Prophet069, on the order with #12840 (BDA stores into writable heap mirrors), which oneandonlydean asked about above: #12840 can go after this PR.
#12840's checklist will say |
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validation IDs already present on main (4 IDs in 525 tests)Skipped (49)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. |
✅ AMD GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (9, not counted against this PR)Validated but not compared (56, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 519 tests)Skipped (54)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
XairRrR
left a comment
There was a problem hiding this comment.
Re-checked — approved
The new commit 89e3292072 ("let a small heap mirror reach the slab allocation and its host fallback") does four things. It replaces the error-text match with a HeapMirrorSlabRefused type. It lets a lowered budget recover after 30 s. It uses HeapReport::Fits. It refuses a slab only while the heap mirrors hold more than 256 MiB. Its new FullDeviceHeapTests case fails when that last guard is removed. The other commits were rebased onto it with the same content.
What changed since my last review
- New commit
89e329207201, between the slab-refusal commit and the cherry-picked write-back commit. The later commits were rebased onto it. Per the range-diff, they only change around the new test struct and thetry/catchinResidentMemory::Take. The head commit7bbf091cf8is unchanged. - The author explained in discussion how the commits split across PRs. The first two commits are #15295,
7c184fb3aeis the cherry-pick from #12827, and the last three are this PR's own. The checklist saysDepends on: #15295, #12827. The author also agreed with EagleBearerYS that #12840 lands after this PR.
What I ran
Head 7bbf091cf83a767b16e38f966d2d72d9321b0d81, main d1ae628bc2f62459cce1e9872ba5632c938c71f2, merged tree bf1ec647053b1866f995446eb40a85dcac8f0323 (--no-ff). Debian 13 VM, GCC 14.2.0, lavapipe (Mesa 26.1.6, LLVM 19).
git diff --check d1ae628bc2f62459cce1e9872ba5632c938c71f2...7bbf091cf83a767b16e38f966d2d72d9321b0d81
python3 tools/check_conventions.py --base d1ae628bc2f62459cce1e9872ba5632c938c71f2
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "heap_mirror"
# negative control: delete `if (live <= Reserve) return;` from ResidentMemory::refuseSlab
sed -i "/if (live <= Reserve) return;/d" core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
ninja -C build -j32 -l32 agc_driver_resident_heap_mirror_tests
ctest --test-dir build --output-on-failure -R "^agc_driver_resident_heap_mirror$"
# restore
git show bf1ec647053b1866f995446eb40a85dcac8f0323:core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp > core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp
ninja -C build -j32 -l32
ctest --test-dir build --output-on-failure -R "^agc_driver_resident_heap_mirror$"
git status --porcelain
| Check | Result |
|---|---|
git diff --check |
clean |
check_conventions.py |
All conventions checks passed |
| Configure / build / libs (script) | ok |
heap_mirror tests (10, including agc_driver_resident_heap_mirror with FullDeviceHeapTests) |
all passed (2.5 s) |
| Validation layer (script, 767 tests) | layer loaded in 766, missing in none, 0 tests with new VUID- lines |
unwrap_self_..._destination_directory_group (script: new failure) |
os.chown on a temporary directory fails with EINVAL. This PR changes no tool file, so the cause is the environment, as in my last review |
| Negative control (guard removed) | agc_driver_resident_heap_mirror fails |
| After restore | test passes, git status --porcelain empty |
Negative control output
[heap-mirror] refused: slabs 0 (0 MiB), free slots 0 MiB, live mirrors 0 bound 0 MiB, budget 24576 MiB
AGC graphics: heap mirror of 0x7f7b55800000+0x2000000: vkAllocateMemory of a heap mirror slab refused: its device heap would keep less than 256 MiB of its reported budget; heap mirrors hold 15 MiB of 24576 MiB (APS5_HEAP_MIRROR_MIB)
I didn't do a full restore of main's production files. The new test calls SetDeviceHeapFullForTests, which doesn't exist on main, so it wouldn't compile. Removing only the guard is the narrower control, and it shows the new test exercises the headroom refusal.
Previous findings
- No test reaches the refusal/shrink path. Partly resolved, still open for the shrink.
FullDeviceHeapTests(core/libs/prx/libSceAgcDriver/tests/execution/ResidentHeapMirror.cpp:370) now reachesrefuseSlab(see the negative control). But it holds less than 256 MiB, soshrinkHeapMirrorBudgetreturns atcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:2841. The lowering, the eviction sweep and the 8-attempt retry are still not run by any test. Non-blocking. - The lowered budget never recovers. Resolved.
heapMirrorBudgetputs the limit back after 30 s (GuestBufferMemory.cpp:2734), and the time a refusal lowers it is stored atGuestBufferMemory.cpp:2842. No test covers it. - Refusal matched by error text. Resolved. It is now
dynamic_cast<const HeapMirrorSlabRefused*>(GuestBufferMemory.cpp:2834). Both the refusal and a failed slab allocation throw that type (core/libs/prx/libSceAgcDriver/Graphics/src/ResidentMirror.cpp:155-159,:199). That is the same set of errors the old text match caught. HeapReport::Fitsunused. Resolved. It is used atResidentMirror.cpp:193.- Nonzero-scan cache is shared global state, with no test across unmap and remap. Still open, unchanged (
ResidentMirror.cpp:381). Non-blocking. - One topic per PR. Resolved by declaration. The commits are attributed to #15295 and #12827 in discussion, and the checklist says
Depends on: #15295, #12827. The landing order is author-reported. I couldn't check the other PRs' heads.
New findings
Blocking
None.
Non-blocking
- A flush after the reference copy is still possible. oneandonlydean raised this, and it was under "Not verified" in my last review. The author said they would look at it next, and the head commit hasn't changed. I can confirm the order this would happen in.
recordTransferrecords uploads intorecorder->Commands()in sequence (ResidentMirror.cpp:61-68), and so doesRecordReference(ResidentMirror.cpp:616-627). So any range still marked whenRecordStagingCopiescallsResidentBuffer::FlushChanged(context, true)(GuestBufferMemory.cpp:6928) is uploaded after the reference thattakeHeapReferencescopied (GuestBufferMemory.cpp:6715-6718). The write-back would then treat it as a shader write. I didn't build a case that puts a mark between the two calls. Suggested fix: show that no mark can land there, or make the write-back ignore ranges flushed after the reference. Add a test either way. - Recovery is by time only. After 30 s the limit goes back to unlimited, whether or not the device heap has room again (
GuestBufferMemory.cpp:2734). On a heap that stays full, this can mean another refuse, shrink and evict cycle every 30 s. That is acceptable as a design choice, but a short note in the commit or description would help.
Not verified
- The host-memory saving and the PPSA02015 world-load result: I launched no title.
- The NVIDIA/Windows run in the description (author-reported). lavapipe reports a large host-backed heap, so the real headroom refusal and the host fallback only ran through the test override.
- The shrink, evict and retry loop, and the 30 s recovery: no test reaches either, and I didn't write one.
- The contents and landing order of #15295, #12827 and #12840.
|
A real-world data point for this PR, from Ghost of Tsushima DC (PPSA02225) on a 16 GB RAM / 8 GB VRAM Windows laptop (RTX 4060 Laptop), main b11c7bf + #12840 + #12792.
I'll build this PR on top of that tree and report the private-memory, freeze and logo results on the same machine. |
|
@sktharunbalaji13-cmd a note before you build it: this PR and #12840 don't merge together yet. Both change |
|
@EagleBearerYS thanks, that matches what I saw: this PR doesn't apply on top of #12840 (the write-back and resident-copy hunks are rejected). So I'm testing the two memory PRs separately on the same 16 GB / 8 GB machine:
Each is compared with that tree's run, on the same machine and in the same conditions: free RAM and private bytes over time, freeze length after the intro soundtrack starts, how far the intro gets, and whether the 135 s VRAM abort still happens. I'll post the numbers here and on #15295. |
|
Results from Ghost of Tsushima DC (PPSA02225) on the 16 GB RAM / 8 GB VRAM laptop (RTX 4060 Laptop, driver 617.42). This PR was applied onto
Logs are available on request. |
|
One more data point on the same 16 GB RAM / 8 GB VRAM laptop: main b11c7bf + this PR, PPSA02225, nothing else open, Defender off, 11.3 GB free at launch. The VRAM abort from the base tree is gone, but after the budget was lowered this run stopped at 147 s with a different abort: The 4.7 GB heap 0x1200000000 is over the 3.9 GB host-import budget, and once the lowered budget refuses its mirror, the only path left is the copy, which Is that path meant to evict and retry, or to let the mirror pass the lowered budget? Your description says a lowered budget is a soft target that a mirror may pass when nothing can be evicted. The earlier run of this PR on the same machine (no abort in 150 s) is in the comment above. |
|
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.
|
|
I am preparing a Windows 007 First Light cross-test of this existing memory series, not a competing implementation. Our pinned GPU-heap integration is bde5e19 (main378945815f + canonical #9508/#22072 and previously qualified dependencies). It still has ResidentMemory::Slab::host and the per-slab host allocation. A 32 GiB machine reaches the menu but hits the unchanged RAM guard during Resume; synchronous draws alone did not contain it. This motivates testing your change but does not yet attribute the growth to those copies. I have reviewed the #12840 incompatibility and will keep it out of this trial. Next I will integrate the exact #15295/#12827/#15296 heads in isolation, inspect current-main conflicts, then run matching native Vulkan controls with actual Khronos insertion before staging a title runtime. No test or performance claim for this series on 007 yet. Current diagnostic source head and aggregate outcomes are on discussion5714, comment19696380. Raw title data stays local. AI-assisted: yes. |
|
Current-main Windows cross-test found an existing mirror check that this integration no longer passes, so I have not staged it into the 007 runtime. Fetchable WIP: https://github.com/Scramblrrrr/AnyPS5/tree/codex/007-resident-host-copies-nov18 at a3e7715. Baseline81e0f6382df5af0640ce23d8d94e539878954e88 is our qualified bde5 integration plus maincf208a139395efef478f58d4c2724054001ef4f4. Candidate merges exact #15295 4c3e5d1, #12827 c12a20f and this PR7bbf091cf83a767b16e38f966d2d72d9321b0d81. #12840 is excluded. The four GuestBufferMemory conflict hunks use your Bound/MarkChanged and device-reference paths and remove the old Block/Store copies. The current storeChanged(..., GuestMemory::WriteChanged) callback is preserved. Latest15295 small-mirror/refusal fixes are retained. Source conventions: zero errors, only the inherited22072 debt-length warning. Same ten CTest names: agc_driver_resident_heap_mirror, seven memory-accounting cases, agc_driver_pm4_order_signal, agc_sparse_run_import. Baseline frozen fixtures pass10/10 in each of three runs. Candidate with ABI-matched rebuilt fixtures passes9/10 in its first run and is stopped there. Both logs confirm two real Khronos insertions/run, the physical NVIDIA device, zero skips and zero VUID/SYNC identifiers. The candidate mirror fixture reports: This is the unchanged-byte optimization check from main64aaaece28aa2c5b2b49e0d917934f1cdf277d94. Removing the host comparison in compareBlock means that stamp now queues another upload. This is an observed upload-count regression, not a claim of incorrect pixels. The failure occurs before the new partial/concurrent-write cases, so those remain unqualified here. An initial provider-only swap also crashed sparse_run_import because GuestBufferMemory's C++ layout changes; rebuilding that fixture against the candidate removes the crash. That mismatched-fixture crash is excluded as evidence against the source change. Separately, our last007 run reported at most64MiB of active mirror slabs across74 memory-report samples. That bounds the observed duplicate host slab copies far below the multi-GiB loading spike; I cannot claim this series fixes our current RAM stop. All native evidence is independent of title data. Windows11 26200, RTX5070Ti/NVIDIA617.42, Ryzen7800X3D,32GiB; GCC15.2r7 Release, SPIRV ToolsOFF, headers1.4.340, actual validation1.4.363. Required Vulkan/no shader cache and serial CTest used in both arms. No title performance claim. AI-assisted: yes. |
|
Follow-up: the one-second worker-complete allocation capture now catches the 007 loading burst. This makes the series materially relevant; my earlier 64 MiB mirror observation was from before this phase. On the same bde5 production stack plus opt-in diagnostics at public head 818ef57, the final completed snapshot has 167 retained 16 MiB allocations under ResidentBuffer::ResidentBuffer -> ResidentBuffer::Create -> acquireMirror -> GuestBufferMemory::AcquireRegistered: 2,801,795,072 raw sampled bytes. The open-source constructor inlines ResidentMemory::Take, whose per-slab host copy is exactly 16 MiB. This is allocation attribution from our own module, not a guess from total process memory; all title frames remain excluded and private. The matching five-second metadata samples show the fast part of the burst outside the source guest-address window: between 05:43:53 and 05:43:58 UTC, private commitment went 22.93 -> 28.21 GB, outside-window commitment 15.20 -> 20.46 GB, while inside-window commitment stayed 7.74 -> 7.75 GB. The verified own mimalloc commitment counter rose 4.82 -> 7.30 GB. These counters are not RSS or proof that the entire outside-window delta belongs to the host copies. The original RAM guard ended this run after 923.282 s, peak sampled private 31.76 GB; zero fatal/VUID identifiers, loading only. Same 1024 MiB import / 2048 MiB texture caps and all original safeguards. The diagnostic uses the existing pinned mimalloc plus its official worker-profiling activation fix, isolated from normal runtimes; its CPU and real-validation native controls are in the 007 tracker. Your exact series heads and the unchanged-byte upload-count failure above are unchanged. The continued native cross-test is now public at 6bed05f52e3fa027c63c2385441b655fc911fb08: a3e771 plus the opt-in allocation diagnostic, then a test-only failure-reporting change. The default resident-mirror fixture still fails immediately at the original unchanged-byte upload assertion. With All nine other common cases pass three times (27/27). Four existing heap draw/compute cases also pass three times (12/12). Real Khronos insertion is confirmed: two per common/diagnostic run, nine per heap run; zero skips, missing-layer messages or VUID/SYNC identifiers. The baseline's original ten common cases previously passed 30/30 on the same machine. Candidate fixture executables were rebuilt against its ABI; the qualified baseline libc/libkernel/libSceAgc and support DLLs were retained. The guarded 007 prototype at 6bed05f has now ended at the original RAM safeguard: peak sampled private commitment 30.43 GB, minimum free RAM 2.07 GB, zero fatal/VUID identifiers. Loading was reached; gameplay and a performance gain were not verified. Different menu-input delays make total run durations unsuitable for a speed comparison. The final worker-complete own-driver allocation snapshot retained 1.040 GB of raw sampled allocations, compared with 3.894 GB in the baseline loading snapshot. The source removes the per-slab host copies, and the previous 167 x 16 MiB ResidentBuffer allocation site is absent. This is useful progress, but not a total-process memory fix: GPU mirrors still grew to 256 slabs / 4096 MiB, with 832 live mirrors binding 4079 MiB. No mirror evictions were reported under the default 24576 MiB limit. The configuration-only follow-up has completed at exactly the same 6bed05f source and providers with the documented APS5_HEAP_MIRROR_MIB=3072. It reached offline menu and Resume, then explicitly refused a live heap mirror during loading: Windows GPU counters rose during loading to about 10.35 GB dedicated / 2.64 GB shared / 13.00 GB total committed for this process on the NVIDIA adapter. These overlapping counters are not disjoint from process commitment or proof that all remaining growth is mirrors. The own-driver raw retained sample total was 0.997 GB; the old per-slab CPU-copy site remains absent. No gameplay or FPS gain is verified. Lowering the mirror limit to 3 GiB is not a usable workaround on this stack, and the production budget refusal remains intact. The known redundant-upload native regression remains unresolved, so this is a diagnostic prototype, not merge-ready. No title data is uploaded. AI-assisted: yes. November 18 allocation-category follow-upThe memory prototype is now carried by c6900b5091158af9684d3b2f54e07552d29d1b1b, with the separately qualified #7508 relocation change and #21501 rejection memo. The unchanged-byte redundant-upload test failure remains unresolved; this is not a merge-ready memory series. With the default 1 GiB import cap, 2 GiB texture cap and 24 GiB mirror limit, a working Allocation-event counters reach 256 mirror slabs / 4096 MiB, with 15 MiB free and 833 live mirrors binding 4078 MiB. The final summary reports 1115 heap mirrors / 4294.1 MiB, one address-based build, 808,944 sparse-heap bindings, and no mirror budget evictions or releases for imports. The largest periodic report before the fast slab burst has heap 0 active/retained allocation of 5.031/1.763 GB and heap 1 active/retained allocation of 1.672/0.825 GB ( The 1-to-2 GiB import-only comparison also hit the guard, so it is not a workaround. A separate comparison of the documented For the pool-capped run, the last regular CSV sample is 28.601 GB private, while the guard's immediate post-trim recheck records 30.167 GB and triggers the 28 GiB threshold. The sampler alone misses part of this fast burst; I have preserved both measurements separately rather than claiming a 2 GB improvement from the CSV maximum. Four bounded trims occurred. Its working 4.97 MB log records no fatal or unhandled exception. Raw title logs, code, traces and captures remain local. AI-assisted. |
|
Tested this existing proposal against a pinned recent main on Linux after the Hot Wheels heap-reference report. There is one reproducible regression in the private composition:
The failing case is
The common baseline uses dependency parent Hardware: RX 6650 XT, RADV Mesa 26.2.7-arch1.1, Linux 7.2.14, GCC 16.2.1 Release. All three arms selected the physical GPU, exercised sparse resident paths, and recorded 16 validation-layer insertions each, with zero skips, VUIDs or device losses. The other 15 cases passed on the proposal arm. There is no native Hot Wheels run, measured speed/memory benefit, or Windows result in this report. Reproduction sources: common baseline, proposal composition. Evidence archive includes recipes, source patches, exact pins, complete CTest/JUnit and provider hashes; no binaries or game assets. Download and all 45 payload hashes verified. Archive SHA-256: AI-assisted: yes |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this change; the checks and source ranges I inspected support merging, though I did not run the reported tests.
What I ran
Reviewed head 7bbf091cf83a767b16e38f966d2d72d9321b0d81 against the prepared diff and targeted source context. I did not run commands or tests. The author reports focused test runs on main and this branch; those are not runs I performed.
Results
| Check | Result | Note |
|---|---|---|
| Source review | passed | Changed code and relevant callers inspected |
| Tests | not run | Only author-reported results available |
| Build and runtime | not run | No local execution |
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read all six changed files listed in the manifest: Context.hpp, GuestBufferMemory.hpp, ResidentMirror.hpp, GuestBufferMemory.cpp, ResidentMirror.cpp, and ResidentHeapMirror.cpp. No changed file was excluded. I did not read every added line in the large GuestBufferMemory.cpp or all added lines in the test file, so the review is not complete against the review folder's instruction to read every changed line. Build, automated tests, and physical-console behavior were not independently verified.
To get this to a good state
Nothing is required.
ligmaSec
left a comment
There was a problem hiding this comment.
The trial merge onto c1601e56d5 conflicts in the mirror context, implementation, and ResidentHeapMirror fixture. Please preserve one focused case in which two queued uses of the same slab need different write-back reference bytes. Removing the host copies means the device reference must be captured after the upload and before that use’s writes. A successful current readback alone would miss reuse of the wrong reference. The Windows result in the PR is from the author.
AI-assisted: yes.
What
A resident heap mirror kept a 16 MiB host copy of every slab, so building a multi-GiB mirror needed as much host memory again, and a rebuild while the old mirror was alive needed it twice. The host copies are gone.
A refresh now only marks the changed ranges (
ResidentBuffer::MarkChanged, an interval map in which a later mark wins). The flush reads the marked ranges straight from guest memory into bounded 64 MiB staging segments, waits after every 256 MiB when the caller allows it, and fills newly bound or zeroed blocks on the device withvkCmdFillBuffer.The write-back reference of each use is a device copy of the written ranges recorded after the uploads and before the shader (
ResidentBuffer::RecordReference); the write-back compares the readback after the shader with it, so only bytes the shader changed reach the guest and CPU writes made meanwhile are kept. Non-resident heap mirrors keep their pooled host references.Reference, upload and readback buffers count as kept bytes of the recorder, so its existing bound submits before they pile up, and references made inside a batch completion are recorded in order with the uploads.
Tests: partly written 64 KiB blocks, CPU writes made while a dispatch is in flight, and two dispatches writing the same range.
Tested
NVIDIA GeForce RTX 3080 Laptop GPU, driver 616.64, Windows 10 Pro 22H2 (19045.6466).
Focused tests on
main(9090972) and on this branch withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,ctest -V -R "heap_mirror|^agc_driver_graphics$|^agc_driver_key_miss$|^agc_driver_bda_device$|^agc_driver_recorder$|native_multisample_depth|depth_storage|^agc_host_import_retire$|^agc_host_import_sparse$":main: 17 of 20 selected tests passed (agc_host_import_sparse skips on this machine; the three agc_driver_depth_storage_* tests were not built in this run); validation layer loaded in both logs;VUID-errors: none.VUID-errors: none.agc_driver_resident_heap_mirrorincludes the new partial-block and in-flight CPU write cases.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)🤖 Generated with Claude Code