perf(agc): on Windows a small compared host import takes its whole 64 KiB tracker blocks off the write watch, and their other pages fall to full revalidation walks (DEATHLOOP) #12329
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 BunnyFl on 2026-10-28T10:03:31Z.
What happens
On Windows, with tibzejoker's port of #6192, DEATHLOOP (PPSA01670 01.405.000) still spends 5.5-6 s of every 10 s of its opening cutscene in
[rescache] revalidate, almost all of it full walks after a collect is refused because the range is not covered by the write watch. A local diagnostic classified those refusals by why the first uncovered page left the watch. Most of them are on pages that were never imported: they share a 64 KiB tracker block with a small host import that is still compared, andWriteWatchCoverage::Excludetakes the whole block off the watch.Two local changes together remove those refusals. With them the cutscene reaches its first gameplay banner in about half the time. I'm asking whether either direction is acceptable before making a PR, because each one changes a behaviour that is there on purpose.
Setup
Windows 11 Pro 10.0.26200, RX 9070 XT (AMD 26.10.1), Ryzen 7 5800X3D, WinLibs GCC 15.2.0 r7, Release.
main46fe6f2437with tibzejoker'sport-6192(8150c25a68) merged on top (the only conflict was the test list inlibSceAgcDriver/CMakeLists.txt, both sides kept).APS5_FORCE_SDR=1, scripted pad input from a fresh save (menus, then Break the Loop),APS5_PROFILE_DRAW=1 APS5_TRACE_SUMMARY_EVERY=10. The cutscene renders the same content in every run: the "The Longest Day" banner appears after about 2,900 presents in each, so I compare time to that present.Where the refused collects come from
A local diagnostic (not part of any change) recorded, per 4 KiB page and per 64 KiB block, which call took it off the watch, and classified every refused collect by its first uncovered page. One played session of about 5 minutes on the tree with change 1 below:
GuestMemory::UnwatchfromGuestBufferMemory.cpp's refresh), page itself not in the importImportWatchedwithstaysWatchedfalseImportWatchedSo about 94 % of the refusals are on neighbours of the unwatched imports, not on the imports themselves.
The two changes
importRunAt): an unwatched import that is not a whole number of 64 KiB blocks is queued like a whole-block one instead of only markedsettleOnDemand. #9941 kept those out of the deferred path on purpose ("They still aren't queued, so the deferred path is unchanged for them"); its own-pages rewatch and the shared-block check inrewatchSettledImportsare what then return them.WriteWatchCoverage::Exclude): set the page bits of the range in each block instead of the whole block's mask.CoversandRestorealready work per page, so partly excluded blocks already occur after aRestore; a caller asking about a whole block still gets "not covered".Diffs (against
46fe6f2437)With both, the same diagnostic counts 0 refusals on neighbours in a played session (219,970 remain inside 127 pages of imports).
Measurements
Three alternating runs per build, 420 s each, same input. Base is
main+ the port + change 1; the other adds change 2:[rescache] revalidateper 10 s, cutscene windowsA second set the next night, both builds also carrying #11265, #11368 and a local f16 change, three runs each at 600 s: banner at 353 / 517 / 392 s without change 2 and 154 / 178 / 179 s with it.
What I could not show:
main(no port, no change 1), one run each: no difference (revalidate7.3-7.7 s vs 6.7-6.9 s per 10 s, no cutscene speed-up).APS5_TRACE_SECONDS), only the 10 s summaries.What they conflict with
agc_write_watch_coverageasserts the whole-block behaviour (a range crossing into the import is watchedfails with change 2: it imports a page atblock + 4096and expects page 0 of that block unwatched).tests/Recorder.cppcase (m) requires that a deferred settle does not return an import that is not a whole number of 64 KiB blocks to the write watch (line 2755 onmain), which change 1 is meant to reverse. I have not run the recorder tests on these changes.af4e074a02gives the unwatch hook the whole excluded block span so pending storage results in the block are saved; with change 2 the hook still gets that span (ExcludedSpanis unchanged), so it saves more than strictly needed, which I believe is harmless but have not tested.Questions
Covers/Restorework per page, or is there a reader that relies on a whole block being excluded (for example something that walks or stamps whole blocks for an import)?If both are fine I can open a PR with the two changes, updated tests and a run on current
mainwith the port.AI-assisted: yes (Claude Code)