perf(agc): import resident direct memory through a section alias on Windows #5851
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5851"
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?
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-14T13:46:24Z.
What
Since #5596, a direct memory page mapped at one guest address is private write-watched memory on Windows. The AGC driver imported such ranges as plain read-write memory, without an alias. On Windows a host import without an alias is removed from guest write tracking, and its changes are found by comparison. Every use of these ranges was compared and refilled on the CPU, on the graphics queue worker.
With this change, an import range that holds resident direct memory takes the alias path.
MapAliasmoves every resident run the range touches into the section, as a second mapping already does, instead of refusing runs that extend past the range. The import then stays write-tracked through the guest views. Direct memory the GPU never imports keeps #5596's fault-free write watching.MapAliasleaves a resident run alone while any of its pages has a host write open (an APR or file read, a socket receive), so a write in flight can neither fail on the fence nor be lost by the demotion. The driver imports such a range without an alias, as before. It does not wait, because some host writes block.The libc debt entry for the Windows direct-memory backing now says that a GPU import also moves the run into the section.
Related: #5688 handles the same #5596 effect further down, in heap mirrors, for the Resident Evil Village abort ("an address-based build copies 419 MiB ... past 64 MiB"). With this change the window import of such a heap stays write-tracked, so the mirror should no longer meet unwatched blocks there. I could not test Village. The two changes touch different functions and do not conflict.
Tested
Windows 11 (10.0.26200), RTX 4090, NVIDIA 617.42, i9-13900K, 3840x2160. Title: Ghost of Yōtei (PPSA26344), intro presents 150–180 (
APS5_TRACE_FRAMES=150:30). Caches were warm: the scene ran once and the title was restarted. No otherAPS5_TRACE_*orAPS5_PROFILE_*switch was set and the log was not redirected.A and B are not bare
main. The title does not boot onmainwithout #758, #4450 and #4475 plus a local startup patch. A (3b54a9f220ff) ismain9a3e2ac4dwith #758, #4450 and #4475, #5089 reverted (it conflicts with #758), and our local patches; none of them touches the files of this PR. B (ff303dac6c56) is A plus this PR's commit, sogit diff A Bis exactly this PR's diff.Summary lines (A1, B1, A2)
B takes 58 % less time per frame than A (p50 117 ms vs 279–283 ms). In A,
Resources.Completecosts 107–109 ms per frame on queue worker 0x0; in B it is no longer among the eight largest phases.Queue worker 0x0, exclusive ms per frame over the 30 presents (from the traces):
Resources.CompleteGraphics.Draw.draw_and_resource_releaseRecorder.SyncGpuMutex.wait.fillDriver.Packet.prepare_memoryVulkan.Dispatch.shader_resourcesGraphics.DrawWithRecipeRecorder.WaitSerial"–" means the phase is not among the worker's ten largest in that capture. The time A spends completing resources, syncing the recorder and waiting for fills is the comparison and refill of the unwatched direct-memory imports.
The three traces are available on request.
Tests:
agc_driver_recorder_tests --host-import-second-mapping-onlypasses. Its new assertion (the first import of singly mapped direct memory has an alias and is not unwatched) fails without the change.guest_memory_testspasses, including the newCheckAliasLeavesResidentRunsUnderAHostWrite, which fails without the host-write commit (22091410a).ctest, Windows, RTX 4090): 1183 of 1184 pass.check_main_syncfailstest_paths_with_spaces_and_unicode_are_reported_verbatimbecause this machine's console code page printséasé; it does not touch this change.agc_driver_recorder_tests(not registered with ctest) stops at(9) a scan under a pending write was keptinkeyProofTests, the same onmain5a6ad0ed3without this change.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
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T13:51:54Z.
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.
main)docs/dev/debt/libc.mdL36docs/dev/debt/libc.mdL35-36docs/dev/debt/libc.mdL36-37Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T13:55:42Z.
Checked the diff against #5596's
WindowsMappingscode:demotealready moves the whole resident run into the section, so dropping the "run extends outside the range" refusal inMapAliasis consistent, andGuestArenaResidentSpangates the alias path correctly. Linux build and the libSceAgcDriver/libc ctest scope are green (only the pre-existingagc_driver_tessellationsegfault on main).Added one commit: removed "A host import alias over part of a resident run is refused" from the libc debt entry, since this PR makes it false.
The Windows job (full Build dispatch) must be green before merging; merging once it is.
Imported from boykopovar/AnyPS5. Originally posted by Sevthered on 2026-10-14T14:16:08Z.
Tested on Windows with Astro Bot PPSA21567 v01.019.000 (my own copy, from a repack folder; its
fakelibandampr_emu.indexare kept out ofapp0). Windows 11 (build 26300), Ryzen 7 5800X, RTX 3080 Ti 12 GB (NVIDIA 616.56), 32 GB RAM, system-managed page file, WinLibs GCC 15.2.0 r7, Release. A ismain85f240e3c; B is the same commit with this PR's two commits cherry-picked (they apply cleanly, local commitad293e25faab), sogit diff A Bis this PR. Same relinked executable, warm shader cache, no switches.On A the title is bound by queue worker 0 from the title intro on: 1.3 to 1.9 presents per second for the 200 s it ran there, with
[rescache]taking the full walk for 96 % of revalidations (fast-fail by reason: collect) and about 2 GiB of storage uploads per 10 s markeduntracked. The full A report is in #357.With B the logos run at 36 to 50 presents per second instead of 11 to 13, and the title intro and the save-slot menu after it at 8.5 to 10.6 for the 140 s I watched, against 1.3 to 1.9 on A. In that time B reaches the save-slot menu, which A never got to in 300 s. Traces early in the title intro (Team Asobi logo), A by seconds and B by presents because B gets there sooner:
Graphics.Drawgoes from 449 to 18 ms per frame.Two costs that may be worth knowing. The first frame comes at 46 and 60 s on B against 10 s on A with the same warm cache. And the working set at the title is 30.5 GB on B against 19.5 GB on A (private bytes 9 to 10 GB against 22.7 GB, so the direct memory now sits in the section). During the second B run the system commit reached 36.8 of 37.7 GB while Windows grew the page file from 2.6 to 5.9 GB. About 15 GB of that was committed by other programs before the start, and I didn't sample commit on A, so I can't say how much of it is the change.
No error or abort in either B run, and the logos and the title intro look as they do on A. I didn't go past the save-slot menu.
GPUs tested here: NVIDIA RTX 3080 Ti, 616.56, Windows 11.
AI-assisted: yes (Claude Code); the runs are from my machine.
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-14T14:16:31Z.
Please hold this one: a 25-minute run of Ghost of Yōtei with it crashed when an APR file read failed (
_readFile,std::ios_base::failurefrom the stream). The likely cause is a race this change makes common:demote()fences a resident run read-only and then replaces its pages with section views, without waiting for host writes that are in flight on those pages (an APR or file read betweenBeginHostWriteandEndHostWrite). Such a write can fail, or land in the private pages after they were copied and be lost. A second mapping already had this race, but it was rare.I'm moving it to draft while I make
MapAliaswait for open host writes on the runs it demotes, and will mark it ready again after a long run passes.Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-14T14:43:59Z.
Pushed
22091410aon top of your docs commit, for the race above.MapAliasnow returns null, without demoting anything, when a page of a run it would demote has a host write open (betweenBeginHostWriteandEndHostWrite). The driver then imports that range without an alias, as it did before this PR, and the next import of the range can take the alias once the write has ended.MapAliasdoes not wait for the write, because some host writes block:sceNetRecvholds one across::recv.CheckAliasLeavesResidentRunsUnderAHostWriteintests/GuestMemory.cppholds a host write open on one page of a two-page resident run. It checks thatMapAliasleaves the run as it is and that a byte written during the host write survives the later demotion. It fails without the guard, at theMapAlias(...) == nullptrcheck.A Ghost of Yōtei run with both commits had no failed APR read through the loading screen, 1,104 s in. It then stopped at present 841 on "guest buffer view ... exceeds its GPU owner ... (direct 1)", the same abort as a
main-based run without this PR at present 829. That abort comes from something else, and I'll look at it separately.Marking this ready again.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T14:48:43Z.
Resident Evil Village (PPSA01556, 01.210.000) with this PR, at the title on current
main. Windows 11 Home 10.0.26300, RTX 3070 Laptop (driver 617.42), Ryzen 9 5900HS.It boots without #5688.
mainwithout #5688 aborts 19-48 s in withan address-based build copies 419 MiB .... With this PR instead, there's no abort and no other fatal error in 16 minutes, and it reaches the title.The last 5 minutes at the title, 30 reports on each side, the same save and inputs, warm shader caches,
APS5_PROFILE_DRAW=1:[guestmem]compare over the 5 min[address]per 10 sSo with this PR the title runs about 6.6 times as many frames, and the CPU compares in
[guestmem]and the address space drop to zero. This is the title screen only; the first 3D scene isn't measured yet.Setup:
main23be5a02bwith #5703 and #5815, plus local commits that prepare shaders at their first draw (APS5_RE8_LAZY_PREPARE=1, withAPS5_NO_GPL=1) and fix later stops. The two sides differ only in this PR versus #5688's three commits. The[guestmem]counters are running totals, so the 5-minute figures are differences between reports.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T15:28:19Z.
For the record, the Village runs above used 59b49aac0, before
22091410a.Imported from boykopovar/AnyPS5. Originally posted by kjhq on 2026-10-14T15:36:40Z.
Tested on Sifu (PPSA03001, Unreal Engine 4, #5908), together with #5906. Windows 11 (build 26300), NVIDIA GeForce RTX 2070 (610.88), MinGW GCC 15.2.0, main
8dfaafe62,APS5_PROFILE_DRAW=1. Same title screen, 200 s runs.So on this title most of the remaining queue-0 cost was compared (unwatched) direct-memory imports: template revalidation failed on
collectand rebuilt the draw's resources. With this PR those ranges stay write-tracked. I saw no new errors or aborts in the log.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T15:45:04Z.
The same Village A/B on this PR's current head,
22091410a: the gain holds. The last 5 minutes at the title, warm cache, the same setup as above, plus a frame-trace aid that was switched off:[guestmem]and the address-based builds compare nothing;No
ios_baseor_readFilefailure, and no fatal error, in 12 minutes.Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-14T17:08:24Z.
@Sevthered thanks for the Astro Bot numbers. I measured the first-frame and memory cost on Ghost of Yōtei, to see whether it comes from the demotion.
Setup: three 300 s boots from the same warm cache on Windows (RTX 4090, i9-13900K), identical except for this PR.
On this title the demotion costs about 4 s and the change saves about 40 s and 11 GB, so it doesn't explain what you saw on Astro Bot.
One candidate: before #5698 (merged today), a watched import first copied its whole range, to compare pages when its window closed. With this PR, Astro Bot's direct memory takes that watched path, so on a base without #5698 its imports were copied in full. Your test predates #5698.
If you have time, could you rerun Astro Bot on current
mainwith this PR applied? It would show whether the first-frame delay and the working set are still there.Separately, the demotion copies every page of a run, although almost all of them are zero. I have a follow-up that copies only nonzero pages. It brings the copy before Yōtei's first frame from 2.3 s to 1.1 s, and I'll open it after this PR merges.
Measured and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T17:54:47Z.
Measured on a second title: PPSA25344 (Sword of the Sea, UE5), title screen. It recovers what #5596 cost there, and the image is unchanged. It also brings back the #361 red-zone crash on this title, in 1 of 6 runs.
What #5596 cost, as a merge-boundary A/B (box 2: RTX 3060, i5-12400F, 32 GB, NVIDIA 617.42, Windows 10; one relinked executable, libraries from
0a56aaaf4=mainjust before the merge vs3e4fe4ce3= the merge, 3 alternating rounds × 300 s, mean of the last twelve 10 s windows):[guestmem]compare per 10 s[storage]uploads, reasonuntrackedThis PR,
mainf0854887dvsf0854887d+ this PR (22091410a), same executable, alternating:main[guestmem]compare per 10 sreadTargetper 10 s[storage]untrackeduploadsFrame dumps (box 2, frame 2 of the title): mean difference 0.13 of 255 between
mainand this PR, 0.12 between twomainruns.The crash: one of the six runs with this PR (box 1, ~170 s in, on a game worker thread) stopped at
app.exe+0x37f77b3,read of 0x740. That's the same leaf as SotS's boot crash before #5596 (#361, also hit by the pre-#5596 build in 1 of 4 boots today). With the alias imports, the GPU-imported direct memory is a section view tracked by write faults again, and those faults clobber the red zone. 0 in 3mainruns and in 4 runs of this PR on box 2. So this is the trade between #5596 and #5851 on this title: about 2.5× the frame rate back, and some of the fault exposure back with it.cc @AlxcBTW (SotS working group)
Imported from boykopovar/AnyPS5. Originally posted by Sevthered on 2026-10-14T18:17:26Z.
@Pipodi reran it on current
main763ad20fc, which has #5698, with this PR's three commits cherry-picked (they apply cleanly). Same machine, run folder, relinked executable, save and warm cache as before; runs alternate between builds, each started after the previous process exited and free memory was back above 16 GB.mainmain+ this PRSo with #5698 the delay and the larger working set are both still there on Astro Bot. Timing put around
demotein a local build (not for merging) shows where the delay goes: 6144 runs, 12 GiB, 98.3 % of the 4 KiB pages zero, 15.6 s copying and 14.1 s remapping before the first frame, so about 30 of the 33 extra seconds. On this 5800X that is about 2.5 s per GiB against your 1 s per GiB on Yōtei, which would explain why it shows here and not there.I have a commit for it on my fork:
github.com/Sevthered/AnyPS5@2c87d02b4(branchperf/demote-resident-run, on this PR's head). It does two things indemote:VirtualFreeinstead ofsplit(), which queries the allocation twice per page (the last page keepssplit()as a check).mapSharedand the layout, one view per page, are unchanged.With it, on the same current
main+ this PR:demote17.2 s (7.9 s copying, 9.3 s remapping) and the first frame at 32, 33 and 36 s against 44, 44 and 45 s in alternating runs. The full suite passes on it (1184 of 1184, Windows). I also tried mapping a demoted run as one view (remapping drops to 0.7 s), but a later unmap or protection change of part of the run would have to unmap the whole view, and a host write in flight elsewhere in the run would not survive that, the same race as22091410a, so it isn't in the commit.Since your follow-up covers the nonzero copy: would you like me to open this as a follow-up PR that depends on this one, or would you rather take the remapping part into yours? Either is fine with me.
One more data point: booting with the game's
-lvl hub_crashsiteworks with this PR. Crash Site renders correctly (banner, HUD, Astro) at about 3 fps, after a loading screen that stays black for a few minutes.AI-assisted: yes (Claude Code); the runs are from my machine.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T18:23:15Z.
Village's write faults with this PR, for the trade parl0v describes above. Run on Resident Evil Village (PPSA01556, 01.210.000), Windows 11 Home 10.0.26300, RTX 3070 Laptop (driver 617.42), Ryzen 9 5900HS.
Setup:
main23be5a02b, which is before #5698;22091410a(its three commits), three commits from #5761 and #5815's two;MapAliasmoves into sections.The executable was relinked with a local red-zone framer (a workaround, not for merging). No stop in this run.
MapAliasmoved (at least)Separately, without the framer, Wwise's
AK::EventManagerthread stopped during the scene load in 1 of 4 scene loads today: 0xc0000005, a read of 0xffffffffffffffff in a list walk. 10 of 10 scene loads with the framer, from yesterday and today, were clean. That matches the #361 class parl0v reports on Sword of the Sea.A full attribution, with every moved run, on a base with #5698 follows. If you try a variant that avoids these faults, I can run it on Village.
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-14T18:40:36Z.
I'm working on the demotion cost (@Sevthered) and the write faults it brings back (@parl0v, @EagleBearerYS), so please don't start a separate fix for them. I'll post results here tomorrow.
The approach is to keep private direct memory write-watched through a direct import, with no section alias. That would avoid the demotion and its write faults altogether.
MEM_WRITE_WATCHmemory. A standalone probe on an RTX 4090 (NVIDIA 617.42) imported such memory withVK_EXT_external_memory_host. The import marks every page, but only duringvkAllocateMemoryitself, insideImportWatched's window. After a reset there were no marks over 1 s: none idle, none after GPU reads, none after GPU writes, in 3 rounds. CPU writes were reported exactly.@Sevthered, could you hold your
demotefollow-up until then? If this works, demotion may not be needed. If it doesn't, your commit is the way to make it cheaper. Your rerun also showed that #5698 doesn't explain the delay, as I had suggested; thanks for the timing.Written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by AnzouBelilita on 2026-10-14T18:40:40Z.
Independent local validation on PR head
22091410a602030a23d9dc33819f57cc38daab69(Windows 10, Intel Core i5-4570, Radeon RX 580, MinGW-w64 GCC 16.2):ctest --repeat until-fail:25 -R "^guest_memory$" --output-on-failure: 25/25 passed (about 74.7 s total).tests\agc_driver_recorder_tests.exe --host-import-second-mapping-only: 25/25 passed (loop exit code 0); output reported that host imports are compared and separate shared aliases retain guest write tracking.git diff --check: passed; the review checkout remains clean.This is a repeatability check on the PR head, not a main-vs-PR performance benchmark, and the local RX 580 results do not independently verify the reported NVIDIA game-performance gains. I did not rerun the full unregistered
agc_driver_recorder_tests.exesuite; its documentedkeyProofTestsfailure is reported in this PR as also occurring on main.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T18:44:48Z.
Thanks, we won't start one. When your variant is up, I'll run the same Village count on it: write faults by thread and region, and scene loads without the framer.
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T18:53:37Z.
A variant that keeps these imports write-tracked without moving runs into the section, so no views, no demotion and no write faults. Measured on Sword of the Sea; one question is open before it can be a PR.
Why it can work: on Windows, a host import without an alias leaves guest write tracking (
watchedHostPointer = entry.alias != nullptr || !state.unwatchImports, andunwatchImportsis always true there;ProbeImportWriteProtectionreturns "the Linux write watch"). Since #5596 the memory behind these imports is privateMEM_WRITE_WATCHmemory, soGetWriteWatchcould keep tracking it if an import doesn't break it. A standalone probe (importMEM_WRITE_WATCHmemory withVK_EXT_external_memory_host, then GPU reads, GPU writes and CPU stores, collectingGetWriteWatchwith reset after each step) gives the same result on an RTX 3060 and an RTX 4060, NVIDIA 617.42, 16 and 4,096 pages:So CPU stores stay exactly reported, and GPU writes are invisible to it (the driver stamps its own). The noise is a one-time mark of every page. It's asynchronous: in three runs, 1,632–3,033 of 4,096 pages were marked before any submit, the rest by the first GPU use completing. Nothing after that.
Experiment: with
APS5_EXP_WATCH_PRIVATE_IMPORTS=1, a direct import of all-private read-write memory stays watched (|| (writable && GuestMemory::WriteWatched()),staysWatchedinImportWatched). Same binary (mainf0854887d+ the 3-line change), env off vs on, alternating:mainbehaviour)[guestmem]compare per 10 sreadTargetper 10 s (box 2)+0x37f77b3Frame dumps: mean difference 0.13 env on vs off, 0.13 between two off runs. About 97–98 % of this PR's frame rate, with nothing moved into a section.
Open question: the one-time marks after the import.
ImportWatched's window filters the ones that land inside it (saved copy, compare). The rest arrive later and get stamped as CPU stores on unchanged bytes. Where storage-image results are pending over such a range, a spurious CPU stamp could make a refresh prefer guest memory. I tried closing the window after a 4-byte GPU read of the new import, which settles the marks in the probe. ButimportAllocationruns under the imports mutex without the GPU lock (lock order isGpuMutex→ imports), so it can't submit there. Two ways I see: settle the import at its first submission by the recorder (keep the saved copy until that batch completes and compare then), or check content for CPU stamps on fresh imports. Is one of those acceptable to you, or is there a hazard I'm missing that made Windows direct imports compared in the first place?Branch with the experiment and the probe: parl0v/AnyPS5
exp/watch-private-imports(20c2d0262, the 3-line switch;207abb46a,tools/wwprobe/wwprobe.cpp). @EagleBearerYS, this is a variant that avoids the faults. If you can run it on Village withAPS5_EXP_WATCH_PRIVATE_IMPORTS=1(onmain, without this PR), the fault counter and the AK::EventManager stop rate would show whether it holds there. The probe would also be worth one run on an AMD or Intel GPU.cc @AlxcBTW
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T19:04:20Z.
Correction to my variant above: the open question isn't hypothetical. It loses GPU results.
libSceAgcDriverctest onmain6bb4fdc4f+ the switch (RTX 4060, Windows 10): 544 of 546 pass either way. Butagc_driver_layered_volume_submitfails 3 of 3 withAPS5_EXP_WATCH_PRIVATE_IMPORTS=1and passes 3 of 3 without it:64 is the test's CPU pre-fill (
Kept = 0x40), so the draw's results never reached guest memory. The volume is committed arena memory, imported directly by the draw. That fits the one-time marks the driver makes after an import landing after the GPU write and being taken as a newer CPU store. So keeping these imports watched needs those marks filtered before they're trusted, and the 3-line switch alone is not safe. Frames on Sword of the Sea's title looked unchanged, but that was the wrong test.@EagleBearerYS please don't spend a Village run on the branch as it is. I'll come back if I get a version that passes this test.
Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T19:12:03Z.
@Pipodi i love you <3
A Windows run of this PR with Onimusha: Way of the Sword (PPSA27836, RE Engine, like Village):
22091410amerges cleanly intomained835aa76together with the title's other PRs (#5769), and builds with WinLibs GCC 15.2.0 r7. Runs were on an RTX 5070, Windows 11 Pro 26200.guest snapshot differs from registered memory. The same stop happens without this PR, so it isn't caused by it; #5484 lets the run continue.mainthe title shows a black screen after that point, with and without this PR. I'll postaps5-summary.jsonllines formainand for this PR once it reaches a stable scene.Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-14T20:27:08Z.
Besiege (PPSA20313),
mainata1b6be7efvs the same plus this PR (22091410a), Windows 11, RTX 4070 SUPER, 1080p: title screen 14.6 / 15.1 -> 23.8 / 25.1 FPS (+66%). Frames presented in the first 40 s: 420 / 720 / 727 -> 877 / 951 / 965.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T20:44:55Z.
@adriadam10 this looks like the forward fix for the Windows cost #5596 left: issues #5692 and #5842 trace it to the same thing (every frame compares the unaliased imports; on #5842 each frame waits out the title's 1 s timeout, and the Sword of the Sea title drops from ~7.4 to 2.4 FPS). With the Besiege (+66%) and Onimusha runs above, it would help to have those two reporters rerun on this head too, so #5692 and #5842 can close with it. We're happy to review the
MapAliasdemotion path (the case where a host write is open and the range is imported without an alias) if that's useful; we can't run Windows here, so the numbers would have to come from the reporters.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T21:03:03Z.
Follow-up to the variant and its correction above: it's now #6060, with the asynchronous import marks handled. Each new import of write-watched private memory is settled inside
ImportWatched's window by a 4-byte read on a second queue of the graphics family, and a WindowsProbeImportWriteProtectiondecides per device.agc_driver_layered_volume_submitpasses with it (it failed 3/3 without the settle). On Sword of the Sea's title: box 2 3.01 → 9.51 FPS. Over 120 s boots it stopped at+0x37f77b3in 0 of 20, against 5 of 20 for this PR on the same boxes and executable. The two can coexist: this keeps private memory private, while yours moves runs into sections. @EagleBearerYS, #6060 is the one worth a Village run if you have time.Imported from boykopovar/AnyPS5. Originally posted by winstrex on 2026-10-14T21:55:03Z.
Tested on The Pathless (PPSA01825) at the main menu: Windows 11, RTX 5070 Ti,
APS5_PROFILE_DRAW=1, alternated runs.#5596 alone (its merge
3e4fe4ce3against the parent, 3+3): 84 → 422 ms per frame; template-hit draws 135 → 1710 µs.This PR on
mainf59d91ffc(2+2):On queue worker 0 (sampled on the previous main,
e6ef803ce),memcmpdrops from 37.8 % to 2.4 % of the samples andStorageTexture::Refreshfrom 33.5 % to 1.7 %.Wwise red-zone crash (#361,
AK::EventManager,app.exe+0x54c313a): 0 of 8 runs to the menu with this PR (0 of 16 counting the measured runs). Before #5596 it was 4 of 16 (on758aca737). The hazard is back for these pages, though. With this PR the title's direct memory is all section views, and about 1.15 GiB of it is read-only (armed) 55 s into a run. That includes the pages Wwise wrote in the old crash; on main they are private read-write. So these pages fault on write again; the crash just didn't show up in these runs.Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-14T22:16:43Z.
Windows run of
22091410aon this box, since no NVIDIA full-suite result was posted: merged ontomain4808d9c20(clean); Windows 11 10.0.26200, Ryzen 7 5800X, RTX 4090 (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 r7, Release,BUILD_TESTING=ON, default environment.mainon this machine.guest_memory(which carriesCheckAliasLeavesResidentRunsUnderAHostWrite) 5 of 5;libSceAgcDriverscope 556 of 556;agc_driver_layered_volume_submit5 of 5.No title here, so nothing on the first-frame cost or the write faults @parl0v and @EagleBearerYS measured. Tested with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-14T22:22:15Z.
AMD and homebrew data point: SuperTuxKart (PPSA69421, catalog release), the title screen it starts on. Windows 11 (26300), Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Ryzen AI 7 350, WinLibs GCC 15.2.0, Release, relinked with
--windows --trap-sdk-syscall-stubs, warm caches, 60 s per run.main9bec20233and the same with this PR's head22091410amerged; the runs alternate between the builds, same relinked executable, only the.prxfiles swapped.mainmain+ this PRThat's +43%. From one
APS5_PROFILE_DRAW=1run each (difference between the last two[guestmem]reports, and the last[draws]line):main[guestmem]compare per 10 sreadTargetper 10 sThe time goes to
refreshResidentTarget→StorageTexture::Refresh, collecting writes over the colour target for every draw (details in #5692). No stop, crash or visible change in the image in any run. Not measured: write faults, memory use, longer runs.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-14T23:24:51Z.
Review: COMMENTED
User-data scope correction (2026-10-15 UTC): the earlier manifest restored tracked legacy
/app0files; the game uses/data/UnleashedRecomp, which was outside that audit. Protected original/runtime/guest-libc hashes remain verified, but full active-user-data restoration and identical active-save state were not established. The first “None” configuration trial edited the legacy file and is invalid as a no-AA test. Maintained correction and verified two-root snapshot/restore scope. Numeric fixture evidence remains valid.Independent Windows retest of #5851 head
22091410a602030a23d9dc33819f57cc38daab69in our retained Sonic integration (2026-10-15 UTC).Retained integration
9e4925b75refreshes the earlier E1 composition onto mainab9a4768407d862d1879d7d0ee66bd9c3d9d67a8and adds #5496's reviewed test corrections. It preserves the broad initial/expanded DCC imports, transfers, immutable snapshots, tracked publication, MSAA arrays and native-depth work. #5851 remains at unchanged head22091410a602030a23d9dc33819f57cc38daab69, applied through its three range-equivalent commits. This is composed-stack evidence, not untouched PR-head or unchanged-main title validation.Full Windows app/libs/conventions/registration pass.75 focused CTest groups pass once (maximum25.0983s);40 critical groups pass five times under each NVIDIA/AMD selector (maximum5.3113/5.49355s).22 critical fixtures have physical-device evidence for both RTX5080 (610.62) and AMD Radeon Graphics (32.0.21036.18); the other18 have no recorded device evidence and are not counted as GPU coverage. No CTest failures/skips or tests over30s. StoreOverUntracked still has three internal “not run” cases. Windows11 Enterprise26200, WinLibs GCC15.2.0. The126-PRX/three-DLL frozen profile loads5/5. No Linux/full-suite/performance or console-hardware claim.
Sonic Unleashed Recompiled PPSA99902,01.003.000 (#4443):
Fresh conversion of the original executable/guest libc reaches the title/autosave screen, opening cutscene and level-loading screen. It stops after 703.882s, exit
0xC0000409, without a timeout:All six scheduled input pulses were sent;48 ordinary BMPs were captured. The inspected
frame_047.bmpat602.301s shows NOW LOADING. No gameplay or FPS result is established. The changed plane, first writer and failing import predicate remain unidentified. The same message is emitted by two revalidation branches, so it does not identify a producer or root cause. No refusal or tracking check was bypassed. Original binaries, baseline runtime/guest libc and user data were restored and hash-verified, with zero cleanup errors.Comparison: the preceding integration without #5851 stopped at32.816s on untracked color reuse. The first #5851 composition, E1 on main4808, reached the same loading screen and stopped at the same revalidation guard after706.129s. This refresh retains that progress; the timings are not a performance comparison.
Partial validation, not an approval recommendation. Controlled neighboring-alias observation: alias/no-alias/restored controls confirm conservative generation invalidation on public synthetic memory. Its role in the game's stop remains unverified.
The neighboring-import test checkpoint is 669170ea1 on maind92. Its public test-only extension verifies all1024 samples of a GPU-written16x16/4x RGBA16F target across a declined neighboring import, retaining its watch. Five runs per actual NVIDIA/AMD GPU pass before and after the control; removing only the optional-import safety check gives ten intended assertions. Full Windows app/libs/checkers and15 related groups per selector pass in both positive stages (max24.21s). Details and remaining metadata/title/Linux limits are in the maintained report linked below. Earlier8a3 applies #6225 to the recorder test harness; full Windows build/checkers and42 recorder groups pass per actual GPU, with two internal compared-import paths untested. The measured title replay remains5aa. The original PR-composition evidence above remains pinned to9e42. The separate local import correction at6bd passes the full Windows matrix but its original-dump replay still ends at the same guard after704.404s. The later whole-buffer regression4310b82cc checks all64KiB; ten partial-fill controls fail as intended and ten restored runs pass. The refreshed5aa composition passes full build/checkers and the affected test matrix. Maintained correction, device scope and negative title result. A fresh5aa title replay also reaches loading and the same guard after706.328s without timeout. Its wrapper ended during restoration; separate recovery completed and verified all baseline hashes and archived the48 frames. No isolated PR-head or gameplay claim.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by orishamir on 2026-10-14T23:59:14Z.
This PR and #6060 side by side on free catalog titles, on one NVIDIA machine and one base. Windows 11, RTX 4080 (616.56), WinLibs GCC 15.2.0 r7, Release. Builds:
main6239ceffc, #6060 at its head f97762019 (based on it), and this PR's22091410amerged onto it. Warm run directories, a 40 s warm-up, then two 30 s windows (APS5_TRACE_SECONDS=20:30, no other switch), in FPS:mainmain153d5d469, with #6060 at e13268f4f, gives the same order: Showcase 3.7 / 6.5 / 7.0, UI Lab 16.1 / 20.0 / 24.3, ProsperoStore 17.9 / 21.8 / 25.6, SuperTuxKart 5.5 / 8.65 / 7.15.main), yet its frame rate is lower than this PR's. A frame dump of the start screen looks the same in all three builds.main153d5d469, the worker sampler puts 69% of queue worker 0's samples during the Showcase inStorageTexture::Refresh. 39% are undercompareUntracked→GuestMemory::EqualsCommittedUnsyncedand 24% underStorageTexture::upload.keep the write watch: yes (4096 of 4096 scratch pages reported written at the import, 0 by its 4-byte settle read, 0 after it, 0 after a full GPU read, 0 after a second, 0 after a GPU write, 1 after a CPU store).Summary lines and traces: https://gist.github.com/orishamir/028d13ae9e4b8551c8b3538748f94948 (the
153d5d469set, with digests and the symbolized samples: https://gist.github.com/orishamir/ec021f52703c05926631c38b953414d6).AI-assisted: yes (Claude Code Opus 5.5)
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-15T00:25:20Z.
@Pipodi heads-up for longer runs: this PR on SotS (title, ~8.5 FPS) stops after about 12 min with
vkAllocateDescriptorSets texture detiler: Vulkan result -2, the same stop #6060 hit. It's amainbug that any title fast enough to keep the recorder busy reaches: the detiler only reset its descriptor pools when the recorder was idle. #6168 fixes it; with it, SotS ran the full 40 min at 10.4 GB private.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-15T01:06:45Z.
Independent safety follow-up: #6260 preserves and revalidates @Pipodi's open-host-write guard separately from the superseded alias optimization: main-pin test fails5/5; the three-line guard passes5/5. No title corruption or producer is attributed. The retained MSAA migration/control results are maintained in our #6060 comment.
User-data scope correction (2026-10-15 UTC): the earlier manifest restored tracked legacy
/app0files; the game uses/data/UnleashedRecomp, which was outside that audit. Protected original/runtime/guest-libc hashes remain verified, but full active-user-data restoration and identical active-save state were not established. The first “None” configuration trial edited the legacy file and is invalid as a no-AA test. Maintained correction and verified two-root snapshot/restore scope. Numeric fixture evidence remains valid.Synthetic reproduction: neighboring alias/import triggers resident-MSAA revalidation
Extended the earlier CPU-only control with a real AGC/Vulkan fixture. Only the existing test file changes; production remains the retained integration on main
8cd937e291da28aaa7080be13cb08d7f55d1da33, including unchanged #5851 head22091410aand the disclosed MSAA stack.Setup: one private resident run of two 64 KiB blocks. A zero-initialized 64×64, 4× RGBA8 native target occupies the first block. Initial creation and a baseline reuse succeed. There are no preceding draws or DCC/CMASK/FMASK metadata. The alias/import cases make no explicit store into the target block.
Both import assertions pass: a tracked section alias is used (
alias != nullptr,unwatched == false), and its returned span has offset=65536, bytes=65536. It does not directly cover the native target block.The three refusal cases emit:
Five complete fixture runs per actual GPU, 40 case observations: NVIDIA RTX 5080/610.62 and AMD Radeon Graphics/32.0.21036.18, Windows 11 Enterprise26200. Matching library/fixture builds and conventions pass; zero skips, timeouts or device-loss errors. Slowest invocation in the final span-checked run:0.42s NVIDIA/0.45s AMD (the first earlier validation peaked at1.02s). This is the existing MSAA runtime fixture with its earlier tests retained.
The earlier CPU-only reproducer observed
unchanged=0 written=1 stored=1for the untouched first block after aliasing its neighbor. Omitting only the alias givesunchanged=1 written=0 stored=0; restoration reproduces the original result, five runs each. All15 same-value-store controls detected the store. The first setup attempt was excluded and its section cleanup corrected.Source matches: demote migrates the whole resident run, resets
seenand invalidates every shared page. The AGC fixture now demonstrates that this transition can reach the resident-MSAA guard even when the requested import is disjoint.Local fork proposal
Small production/test delta: decline the optional alias import when its full private resident-run span overlaps a GPU-owned image. The existing copied-buffer path executes the requested operation.
With this change, a real GPU fill stores
0x12345678into neighboring guest memory and native-target reuse succeeds. Direct alias creation and a same-value CPU store retain their refusals. Both actual GPUs pass five runs before and after the one-line fault control; removing the safety check produces ten intended assertions (five/vendor), with no device loss or abort.The full-buffer regression4310b82cc, on maina077, verifies all65536 bytes of the copied fill. Full Windows app/libs/checkers pass;75 focused groups once (max24.7584s),40 critical groups five times per selector (max5.54321/5.17630s), with22 fixtures showing the requested physical device per vendor. Four new main draw/sample-mask fixtures also pass five times per actual GPU. The half-fill control leaves the first16 bytes correct but triggers the new whole-buffer assertion in all10 runs; restoration gives10 passes. No CTest failures/skips in the normal runs; three internal StoreOverUntracked “not run” cases remain. No Linux/full-suite claim.
The native-image tracking helper and MSAA revalidation involved here belong to our retained implementation; this is a composed integration proposal.
GPU-written native-target extension
The public synthetic fixture delta draws a triangle into a 16x16, 4x RGBA16F native target in the first 64 KiB block of a private resident run of four blocks. Shader sample loads verify all 1024 samples, including partly covered pixels. An optional import of the second block is declined; the target remains watched and every sample and its triangle coverage are preserved. The earlier whole-buffer copied-fill case remains separately tested; this extension does not add a neighboring fill while the drawn target is live.
At
669170ea154867215b57cabae227bad07e37f7c6, full Windows app/libs and conventions pass. The extended fixture passes five times per physical GPU before and after the control: NVIDIA RTX 5080/610.62 and AMD Radeon Graphics/32.0.21036.18, Windows 11 Enterprise26200. The fault control removes only the optional-import safety check and triggersthe neighboring import would migrate a GPU-written resident targetin all ten runs (five/vendor). The MSAA guest-write guard remains intact. Exact source restoration and matching rebuild give ten more positive runs. The 15 related groups also pass once per selector both before and after the control (60 runs, maximum24.21s); nine groups record the requested physical device. No CTest skips, timeouts, device-loss errors or internal not-run messages in this matrix. No Linux/full-suite claim.This test's fork checkpoint is 669170ea1, with this test-only delta above 8a3efe771. The game replay remains the measured5aa run below; this synthetic extension does not establish its triggering import, plane or first writer.
**Original-dump retests completed:**9e42,6bd and5aa reach loading and the same guard text after703.882/704.404/706.328s respectively, all0xC0000409 without timeout. Latest5aa sends six inputs and records48 BMPs; frame047 at601.211s shows loading. Its wrapper ended during restoration; a separate recovery completed and hash-verified originals/runtime/guest/user-data restoration, archived all48 frames and removed the temporary executable. For9e42→6bd only AGC changes; the6bd→5aa refresh rebuilds all126 PRXs, with three DLLs and converted executable/guest libc unchanged. This does not establish an isolated cause. The import correction fixes its synthetic case but does not unblock the title's first stop; plane, writer and failed predicate remain unidentified. No FPS or speed claim.
Earlier integration8a3efe771 retains the correction on maind92 and applies #6225 to the private recorder fixture's GPU selector. Full Windows build/checkers and42 recorder groups per physical NVIDIA/AMD pass,0 CTest failures/skips (39 device-recorded fixtures plus three CPU groups, max0.457s). Unit-shadow and kept-index internal compared-import paths remain untested. Earlier5aa's full4x source-footprint adaptation remains; its initial unadapted merge failed that explicit check. Title evidence remains the5aa replay above;8a3's own delta is in the test harness. Continue ordinary bring-up and public synthetic narrowing with the guard preserved.
Scope: clean native-target reuse and the GPU-written16x16/4x RGBA16F neighboring-import case on the disclosed composition. Other dirty-target formats/modes, metadata transitions, isolated #5851/main-only reproduction and Linux remain unverified. Our Sonic replay reaches loading and stops at the same message, but its triggering import, plane and first writer are unidentified. The local proposal is shared with the demotion work already coordinated here; no upstream PR is opened from this composed source.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-15T06:36:28Z.
Closing this in favour of #6060, which fixes the same #5596 cost without moving direct memory into sections.
The side-by-side results point that way:
main. Frames are about the same, and guest-memory compares drop from ~105k to ~1.4k per window with both. Private peak is 29 GB with #6060 against 24.5 GB with this PR, but #6060 doesn't need the demotion copy and remap.The two can't usefully coexist: with both merged,
writable = !GuestArenaResidentSpan(...)here routes resident runs toMapAlias, so #6060's settle never applies to them.Thanks to everyone who tested this: @JAB-dev, @LeandroLP23, @frankea, @winstrex, @orishamir, @Amoenus, @Sevthered, @EagleBearerYS and @parl0v. The numbers carry over to #6060's review. The SuperTuxKart per-submission settle cost is the one thing I'd still like to see addressed there (batching or skipping the settle for a range that's re-imported at the same address).
Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-15T17:52:58Z.
Astro Bot on an RTX 4090 (NVIDIA 616.92), the title intro, this PR against
mainand #6060 on one base, three alternating rounds each:main3.0 FPS, this PR 16.0 FPS, #6060 15.1 FPS; GPU busy per present 164 → 33 ms. No stop in three 200 s runs. The full table, setup and summary lines are in https://github.com/boykopovar/AnyPS5/pull/6060#issuecomment-6198650709 (same executable, onlylibs/swapped). Round 1 here was the cold shader cache and still completed its window. I did not measure the first-frame delay @Sevthered reported.Tested with AI assistance (Claude Code).
Pull request closed