perf(agc): compare sampled snapshots outside the write watch only after a write-watch mark #5892
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5892"
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 WallisSkill on 2026-10-14T14:49:01Z.
What
Split as asked in the review: this PR now carries only the sampled-snapshot change. The audio, storage write-back and allocator commits will come as separate PRs, in the order CnRJay suggested (allocator, storage write-back, audio), once this one is merged. My account has no merged PR yet, so the contributing rules allow only one open PR at a time.
perf(agc): compare sampled snapshots outside the write watch only after a write-watch mark. The commit is SoRadGaming's (f75234e9d, authorship kept), offered in their comment above. It replaces my earlier version of the same idea, because it:The only change I made is rebasing it onto current
main: the[textures]counter line now prints both the image-table counters frommainand the new untracked-snapshot counters.On Windows every direct host import leaves the write watch. A sampled texture snapshot over that memory has no write generation, so every cache hit compared the whole snapshot with guest memory. In Cat Quest III's overworld that was about 63,000 compares (150 GiB) every five seconds, two thirds of the queue worker. The snapshot is now keyed like
StorageTexture::compareUntracked(#4878):It is compared again only when that key changes.
Tested
Windows 11 Pro 26200, MinGW GCC 15.2.0, NVIDIA GeForce RTX 5070 (driver 616.92).
agc_driver_untracked_snapshot_hint(the new test) and theagc_driver_partially_resident*tests: 3 of 3 pass; the new test passes 20 of 20 repeated runs.Cat Quest III (PPSA15065): overworld, standing still after loading the save,
APS5_TRACE_SECONDS=240:20, warm caches, one build, same scene in both runs.cee9841b6.APS5_DBG_UNTRACKED_MODE, not in this PR) turns the key off (0, as onmain) or on (1, this commit).compareUntrackeddoes, measured 8.98 ms p50, within noise of this commit, so I left it out.mainbehaviour)Summary lines (
APS5_PAD_INPUT_FILEremoved):The traces (
aps5-trace-6786710dec77-19516,-35268) are attached in a comment.SoRadGaming's ASTRO BOT (PPSA21564) numbers and test results are in their comment above.
Checklist
main; no other open PR implements the same functionsdocs/dev/debt/libSceAgcDriver.mdchange)NotImplemented_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 WallisSkill on 2026-10-14T15:13:20Z.
aps5-trace-aeacd38910ea-23280.json.gz
aps5-trace-aeacd38910ea-41544.json.gz
aps5-trace-aeacd38910ea-5156.json.gz
Imported from boykopovar/AnyPS5. Originally posted by SoRadGaming on 2026-10-14T17:03:10Z.
Independent confirmation of the third commit (ea8a7b98c, sampled snapshots over untracked memory), plus a test for it. I had written the same change for ASTRO BOT (PPSA21564) before seeing this PR, and only measured that commit, not the other three.
Host: Windows 11 Pro 26200, Ryzen 7 5800X3D, Radeon RX 9070 XT (driver 32.0.23033.1002), WinLibs GCC 15.2.0, Release.
Effect on ASTRO BOT's title screen
maina3aeaf884+ #5671 + #5679 + #5707, withAPS5_PROFILE_DRAW=1:Graphics::Draw: 2,349 → ~1,150 us per draw packet.main84b01f9cd,APS5_TRACE_SECONDS=300:30, warm caches, same session. The gain is smaller here, because the GPU is busy ~785 ms per present at this scene:mainGraphics.DrawResources.CompleteA test
It is in SoRadGaming/AnyPS5@f75234e9d, as an
--untracked-hintmode ofagc_driver_partially_resident_snapshot_tests, registered asagc_driver_untracked_snapshot_hint(Windows; skipped elsewhere). The surface leaves the watch throughGuestMemory::Unwatch, and the flush hook counts the guest reads of each lookup. It checks:MarkWrittendriver store costs one compare and keeps it.Results:
mainit fails at the first epoch without a store.My version takes the key before the snapshot is read and stores it with a new entry, unless
Recorder::SnapshotWriteOverlapsreports a recorded write over the surface. That saves one full compare per new or refreshed snapshot. Feel free to take the test, the store-at-creation part, or both.ctest -R "agc_|guest_memory|write_watch|write_tracking": 537 of 538 pass with my version.agc_driver_layered_volume_vertex_no_gpl("slice 1 texel (0, 0) channel 0 is 64, expected 255") fails the same way onmainon this GPU.AI-assisted (Claude Code); the builds and runs are on my machine.
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T17:17:57Z.
Review: COMMENTED
These four commits are separate changes to three libraries. CONTRIBUTING asks for one topic per PR, and here it matters beyond form: each part has a different risk and a different reviewer.
compareUntrackedstamp, which it reuses.operator new/delete) has the widest reach: it replaces the global allocation operators oflibSceAgcDriveron Windows. It needs a native TLS slot,--exclude-symbolsso other libraries don't bind to the operators through the import library, and a size-class choice based on_msize. That deserves its own PR and its own look at blocks that cross module boundaries (allocated in one.prx, freed in another), plus thread exit (what happens to a thread's cached blocks when the thread ends).FindPendingreturns and which get stored. That is a correctness change to the storage write-back that every title relies on, andAPS5_NO_ALIAS_SUPERSEDE=1is a new switch to keep the old behaviour. Maintainers have asked for that kind of fallback switch to stay offmain.THREAD_PRIORITY_HIGHEST,APS5_AUDIO_LATENCY_MS) is audio, with a new tuning variable.Splitting them in this order (3, then 4, then 2, then 1), each with its own Tested section, would let commit 3 land quickly. The others would then get the scrutiny they need. The frame-rate table already isolates commits 3 and 4 through their switches, so that evidence carries over.
Imported from boykopovar/AnyPS5. Originally posted by WallisSkill on 2026-10-14T17:58:21Z.
@CnRJay thanks, split as suggested. This PR now carries only the sampled-snapshot change. The allocator, storage write-back and audio commits are ready on their own branches and will follow in that order once this one lands; my account can have only one open PR until one is merged. The storage write-back one no longer has
APS5_NO_ALIAS_SUPERSEDE.@SoRadGaming thanks for the test and the store-at-creation version. I took your commit as is, with your authorship, and only rebased it onto current
main: the[textures]counter line now printsmain's image-table counters and your untracked-snapshot counters. Your test passes here 20 of 20 runs on an RTX 5070. I also tried keying hint-less ranges by the collect epoch, ascompareUntrackeddoes: 8.98 against 9.08 ms p50 in Cat Quest III, within noise, so I left it out. The Cat Quest III numbers for this commit are in the description; the traces follow in the next comment.Imported from boykopovar/AnyPS5. Originally posted by WallisSkill on 2026-10-14T18:00:09Z.
aps5-trace-6786710dec77-19516.json.gz
aps5-trace-6786710dec77-35268.json.gz
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T20:35:59Z.
Checked the key logic against
StorageTexture::compareUntracked(#4878): the key is taken before the snapshot is read or compared, a snapshot read over pending recorded writes gets no key, and an odd forget serial yields no key, so the fallback is the byte compare. The debt entry matches.The only conflict with
mainwas the adjacent line indocs/dev/debt/libSceAgcDriver.md; I rebased and resolved it.agc_driver_untracked_snapshot_hintis Windows-only (skips on Linux), so the Windows build is the gate; merging once it is green.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T21:33:28Z.
mainmoved again (#5906 changed the same technical-debt line indocs/dev/debt/libSceAgcDriver.md). I rebased and kept both statements in that entry: main's "snapshot reuse limited to draws of one collect epoch" and this PR's sampled-snapshot wording. No code changed. libSceAgcDriver build and ctest are green here exceptagc_driver_tessellation, which also segfaults onmain;agc_driver_untracked_snapshot_hintis Windows-only, so merging once the Windows build is green.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T21:38:10Z.
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/libSceAgcDriver.mdL58-59