perf(agc): settle Windows imports under 1 MiB without waiting #6678
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6678"
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 EagleBearerYS on 2026-10-16T04:07:57Z.
What
This implements the non-blocking settle that the debt entry for pages under an import window lists as missing. The entry (
23fccd7632, merged with #6060) ends: "Settling without blocking the importing thread (submit the read, keep the import compared until its fence signals, then switch it to the write watch) is not implemented."Why. Since #6060, a Windows host import of private write-watched memory stays in the write watch only after its settle, a 4-byte GPU read that the importing thread waits for. Only imports of 1 MiB or more are settled (
23fccd7632): SuperTuxKart (PPSA69421) maps, imports and unmaps a 64 KiB buffer around every submission, and waiting for each settle cost it about 19% of its frame rate (Dripl1x, on #6060). A smaller import is compared instead, and its range leaves the write watch for good.Resident Evil Village (PPSA01556) maps its GPU heap in 64 KiB pieces of resident direct memory. In a profiled boot to the menu, 12,628 of the 14,881 imports were made at map time, in such pieces. So on
main's settle code that whole heap is compared, and so is every texture sampled from it.APS5_PROFILE_DRAW=1, per 10 s:[textures]kept 16.5 M untracked snapshots by their hint and compared 283,785, and[guestmem]compared 33 GB in 3.4 s.cachedTexture's snapshot compare.The game's menu, unprofiled, as the median of the 60-s intervals 5–15 min after the menu stands, on our Resident Evil Village test tree (
mainplus the open fixes the title needs, ours and others'), Windows 11, RTX 3070 Laptop:main'smain's settle code. The PR's row ran b62a0572e7, the revision before this head. The head only adds theSetHostImportDeferredSettlestest hook, which is on by default, and tests, so it runs the same code.main's settle code.#5692 tracks the same comparison cost on other titles. This PR covers the part of it that comes from imports under 1 MiB. I don't know whether the titles there make such imports, so it's listed as related.
How:
GpuMutexwhile the imports match the registry records the reads queued since into one command buffer on the settle queue (up to 256 reads per batch, four batches in flight) and submits it. The thread that maps and imports neither submits nor waits.GuestMemory::Rewatch, the first commit, collects and drops the blocks' write-watch marks and stamps every block as a CPU store with a new generation. So anything derived from the range while it was compared (a snapshot without a generation, a proof by its untracked hint) reads as changed once.Rewatchthat refuses a page, which happens only for pages an import wouldn't have pinned.SetHostImportDeferredSettles(false), a test hook likeSetHostImportBudget, keeps imports under 1 MiB compared as before.agc_driver_dcc_keys_first_write's hinted-import case uses it, because that case tests the untracked hint of an import that stays compared. That still happens on a device without a settle queue, and until the read completes.APS5_NO_DEFERRED_SETTLES(any value) does the same for a run (5f822a5008), so a title can be compared with and without the deferral on one build.SuperTuxKart (PPSA69421) stays whole. Nothing that maps, imports or unmaps its per-submission buffer waits for a settle:
GpuMutex, only queues its read. Reads go out only from a lookup underGpuMutex.WaitForLeasesAndImports), as onmain. A read still queued is dropped. One already submitted has almost always finished by then, and the retire checks its fence before it would wait.Why not #4448's
GuestMemory::Rewatch. On Windows its body is empty: it re-registers the range with Linux's write watch, for imports retired after sixty idle frames. This PR'sRewatchis the Windows re-include, by whole tracker blocks. The two take different arguments, so they would sit side by side as overloads.The commits:
feat(agc):GuestMemory::Rewatch, with a write-tracking case.perf(agc): the settle, with its tests. It also keepsagc_driver_dcc_keys_first_write's hinted-import case on a compared import.docs(agc): ARCHITECTURE.md and the debt entry.perf(agc): an import retired during its settle read is freed after the read instead of waiting for it. The[buffers]line counts settle reads submitted, back in the write watch, retired during their read, the unmaps that waited for one, and pending.test(agc): the two canaries for the driver's marking, and the docs to match.Overlap.
#5905 (hugodearaujo, merged) settles dma-buf imports on Linux on the settle queue. This PR's merge of
main(c7e07cae44) keeps both:settleImportbuilds on both platforms, and the batched settle of Windows imports under 1 MiB and its counters stay Windows-only. The paragraph and the debt entry keep both texts.#7269 (JJenkx, merged) holds the synchronous settle's buffer, memory and fence per device in
ImportSettle. This PR's merge ofmain(8f03535c8f) keys its settle batches the same way: each device'sImportSettlealso holds its batch target, memory, batches and their fences, so a device switch keeps every device's batches, andClearHostImportswaits for and destroys only that device's. A submitted settle records its device, and the per-import map ispendingSettles, clear of #7269'ssettles.#6457 and #6479 (mine) conflict with this PR in
GuestBufferMemory.cpp, at four places:importRunAt's andimportAllocation's signatures;Each resolution keeps both sides, as already done in my Resident Evil Village test tree. Whichever PR lands second takes it.
#5390 shares the debt file.
#6472 (ahir061) adds
HostImportBudgetnext to this PR'sSetHostImportDeferredSettles, inGuestBufferMemory.hppand.cpp. Whichever lands second keeps both.#6499 (parl0v) also retires its trimmed imports when
refreshImportsfinds the device changed. This PR drains the pending settles there first, so whichever lands second keepsdrainSettles(state)ahead of #6499's loop over both maps.#6546 (mariuszkreft) refreshes a heap mirror conservatively where its range has left the write watch. On Windows an import under 1 MiB is one way a range leaves it. With this PR such ranges come back after their settle, so that fallback is taken less often. The two change different functions in
GuestBufferMemory.cppand merge cleanly.#6192 (TheAggie) makes revalidation over untracked memory cheaper, and #6308 (LeandroLP23) runs the unwatch hook in
ImportWatched's fallback. Both merge cleanly with this one, and both keep mattering for what stays compared.#6918 (Scramblrrrr, draft) clips a partly committed import window to the aligned committed span that holds the request. It merges cleanly with this PR. A clipped window is aligned to the device's import alignment, not to 64 KiB, so one that isn't whole 64 KiB blocks stays compared, like any import this PR doesn't settle.
Related: #6060, #5851, #4448, #6192, #6308, #6546, #5692.
Tested
agc_write_tracking(CheckRewatch): a rewatched block is watched and collected again, reads as changed since before it left and as CPU-stored, its untracked hint stops applying, and the blocks around it keep their stamps. Part of a block, and a block with uncommitted pages, stay out.agc_import_settle_deferredandagc_import_settle_deferred_other_family(Windows, a Vulkan device with a settle queue):main'sGuestBufferMemory.cpp, without their counter checks, fail with "(d) a 64 KiB import did not return to the write watch after its settle".agc_write_tracking,agc_import_watchandagc_import_watch_other_family.agc_driver_host_import_windows,_at_map,agc_host_import_retire,agc_driver_dcc_keys_first_write,agc_driver_layered_volume_submit,agc_driver_multisample_fill_host_only,agc_driver_store_over_untrackedandagc_storage_cpu_snapshot.agc_import_settle_retire("64 while the read ran, 0 waits, 0 unmaps waited for a read"; with retirement waiting for the read again it fails 3 of 3, "0 while the read ran, 64 waits" and "replacing an import during its settle read waited for the read"), and the canariesagc_import_settle_first_use(back in the write watch 21.7 to 30.4 ms after 4,096 main-queue copies of the import were submitted, while they still ran, with no driver marks afterwards) andagc_import_settle_earlier_import(an earlier import's first use runs only after the range is back in the watch, with no marks). The canaries have no red by design: they fail only on a driver that keeps marking. The other settle and watch tests pass 2 of 2.141d605b90(the first-use canary retries with more copies instead of failing when its copies finish first), onmain66e290f1c0with this PR, #6454 and #6911 merged (the other two don't touch this path):agc_import_settle_first_usepasses 10 of 10, racing in its first round (back in the write watch 26.7 ms after 4,096 main-queue copies, which were reaped by 47.9 ms; no driver marks after its return).agc_driver_store_over_untrackedsometimes fails onmainon this PC too ("the result was never held pending").^agctests (run; #6452's test fix applied there only, becausemaindoesn't build in full with MinGW since #5747):agc_driver_pm4_replay_tool(0xc0000139) fails onmainon that runner too.agc_driver_flip_computeprinted "AGC flip and suspend tests passed" and then timed out at exit. That's the pattern of the exit hang #6641 fixes. In 20 more runs it passed every time, on this branch alone (run) and with #6641's commits added (run).guest_kqueueandprecise_waitin the libc and libkernel suites, which fail onmainon those runners too.guest_kqueueon Windows, a kqueue test this PR doesn't touch.HostImportSettles, which returns zeros there:guest_datagram_*tests andguest_tcp: that machine has no IPv6, and they fail the same way onmain.agc_write_trackingandagc_import_watchpass 20 of 20.mainonly byGuestMemory::Rewatch, which is empty outside Windows, and bysettleImport's device setup, which ran the same steps fromadoptSettleDevice; since the merge ofmain98c251fc62that setup issettleFor, with the same steps. Everything else this PR adds is inside#ifdef _WIN32.^agcpasses 606 of 606 (43 skip), and the preprocessed Linux sources change only by two counter fields.main's settle code ran 0.029 fps there (one earlier run at control). All four runs fill the 6400 MiB import budget in the scene. With this PR the budget fills during the load, about 100 s before control, because imports under 1 MiB no longer wait; with synchronous settling it fills about 100 s after control, once the scene has imported its ranges. While the budget is full, every import an address-based build maps is stamped as recently used, so none of them can be evicted, and a range first needed after that, here one build import at 0x2372400000 (512 KiB to 1 MiB), is copied on the CPU at each use. That comes from the import budget's eviction, not from this PR's settle.main; it carries the open fixes the title needs) with #6455 and this PR, Windows 11, RTX 3070 Laptop, warm shader cache, noAPS5_PROFILE_*(the trace summary on). The meadow save is loaded from the title menu, then the player stands still; each value is the median of the five 60-s intervals from 180 to 480 s after the first present. One build, run OFF (APS5_NO_DEFERRED_SETTLES=1, the only difference between the launches), ON, then OFF again:gpu_busy_ms_per_present): 50.3, 54.4 and 44.0 ms. ON is at the high end, but inside the 6.3 ms between the OFF runs, so it can't be told apart from run-to-run spread. parl0v's RTX 3060 rows below go the same direction.APS5_PROFILE_DRAW=1andAPS5_ADDRESS_COPY_MAX_MIB=8192for 90 s (comment):main3b10c7ef0it aborts after 25 s witha heap mirror's range is no longer write-watched.main47a266cf9with #6455 and this PR merged on top (comment). In game at the start of Act 1, 60 s of frames standing still from 120 s after Continue, no profiler, one run per build (noise about ±5 %):main: 3.63 fps. With #6455 and this PR: 8.12 fps.mainwith the settle floor lowered from 1 MiB to 64 KiB (synchronous settles, a local control): 8.45 fps.mainthe render targets' DCC key ranges sit in compared imports: none of about 400,000 clear-key proofs per 10 s is reused (CollectWritesreturns 0 for each),[dcc]reports about 570,000 key scans (78 GiB) per 10 s, and 15 % of the draw committer is inAllKeysEqual. With this PR, 33,207 proofs per 10 s are reused.APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1,main93e54ceddagainstmainwith this PR at141d605b9, two rounds (comment):main, 6.50 and 6.53 with this PR (−1.4 %).main.APS5_NO_UNIT_SHADOW=1, withAPS5_NO_DEFERRED_SETTLES=1, and with the settle-batching commits.APS5_TRACE_SECONDS=60:30). The base ismain84b0d2f24with #6557, #6727 and #6762, 6 runs (3 before and 3 after this PR's); this PR is merged on top of it, 3 runs (comment):Driver.Packet.memory_waitper frame, in run 1 of each: 107.0 ms on the base, 78.5 ms with this PR. GPU busy per present is unchanged at 27.4 to 27.6 ms (GPU clocks weren't reported).main1b1f8483ca(c7e07cae44, with5f822a5008), on GitHub's runners (run): the settle, import and write-tracking tests and #5905'sagc_driver_sparse_dma_buf_importpass 3 of 3 on Linux (45 tests) and Windows (53, of which 50 skip without Vulkan). The run shows as failed because the Windows libkernel suite'sguest_kqueuefails on that runner with and without this PR (nomaincomparison was run).main98c251fc62(8f03535c8f, the per-device settle batches after #7269):agc_import_settle_deferred,agc_import_settle_deferred_other_family,agc_import_settle_retire,agc_import_settle_first_use,agc_write_tracking,agc_import_watch,agc_import_watch_other_family,agc_driver_host_import_windows,agc_host_import_retireandagc_storage_cpu_snapshotpass 5 runs in a row each, with none skipped.^agctests pass 3 runs in a row on Linux. On Windows, where the settle tests skip without a Vulkan device, the only failures areagc_driver_pm4_replay_toolandagc_shader_replay_tool, which fail the same way on that runner for an unrelated branch (run).python3 tools/check_conventions.py --base origin/main: passed.Checklist
main5d9dcc42d2, merged withmain1b1f8483ca; 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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T04:34:59Z.
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)core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppL73-74core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppL2601docs/dev/debt/libSceAgcDriver.mdL82-84core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppL73-74Some 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.
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/ARCHITECTURE.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/ARCHITECTURE.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/ARCHITECTURE.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/ARCHITECTURE.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/ARCHITECTURE.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/include/GuestMemory.hppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/ARCHITECTURE.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/tests/Recorder.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cppcore/libs/prx/libSceAgcDriver/tests/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppdocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-16T12:44:57Z.
Data point from Metal Gear Solid 4 (PPSA18194, Master Collection) on Windows 11, RTX 3080 (NVIDIA 610.74), with this PR picked onto main
5d9dcc42dplus #6188, #6192/#6187, #6273 and #6292.bytes % settleBlockBytes == 0, so they stay compared.ProvedClearKeysthen never gets a collect (itsCollectWritesover the key range returns 0), every lookup rescans the keys, and in gameplay that is about 230k scans, 26 GB and 1.1 s per 10 s on the draw committer, with 0 proofs.agc_import_settle_first_usefailed 5 of 15 runs under ctest here, always with "(f) the main-queue copies had finished before the import returned to the write watch, so its read did not race them". That is, it fails when the race it checks does not occur, rather than reporting itself inconclusive.AI-assisted (Claude Code); numbers from runs on my machine with
APS5_PROFILE_DRAW=1.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T14:51:37Z.
@ps54all thanks for trying it on Metal Gear Solid 4 (PPSA18194), and for the numbers.
141d605b90retries with 4 and 16 times as many copies, and reports the case as not tested when the copies finish first every time. The test now fails only when the driver marks the import's pages after its settle read.ProvedClearKeysnever gets a collect over them. That case is outside this PR. Thanks for trying the whole-block version; the two missing UI texts are a useful lead, and I've noted the case with your numbers for a follow-up.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-16T19:03:11Z.
A Windows NVIDIA data point, and one that goes the other way: RTX 3060 12 GB (NVIDIA 617.42), i5-12400F, Windows 10 19045, MinGW GCC Release. Minecraft Dungeons II (PPSA16064 01.100.100), title screen, no input, 200 s rows,
APS5_PROFILE_DRAW=1 APS5_PROFILE_GPU=1;main93e54ceddvsmain+ this PR, interleaved with three other PRs in one batch, two rounds. FPS is the mean of the last 10[present]windows, GPU busy and idle gaps per frame over the last 8.main141d605b9)The idle gaps shrink as intended (-10 ms per frame), but GPU busy grows by 13 ms per frame, so the frame rate drops a little. The command classes are unchanged (draw 32.3 / 31.5 ms, storage write-back 17.4 / 17.2 ms per present); the growth is all in the title's compute dispatches. By rank (the program addresses move between runs), both rounds:
mainSo the heaviest dispatches run 1.6-2.4x longer on the GPU when the sub-1 MiB settles no longer wait. My guess is that those dispatches now read buffers that are still on the slower path because their import wasn't settled yet when they were recorded; a
[guestmem]/ import breakdown on your side would tell. 0 fatal in all rows.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T19:06:08Z.
@parl0v thank you, this is the cost side we hadn't measured: the idle gaps shrink by 10 ms per frame as intended, but the heaviest compute dispatches take 1.6–2.4× longer, so the frame rate drops a little on the 3060. We'll look at where those dispatches' buffers come from with and without this PR, a settled import read from host memory or a device copy, with an import breakdown, and report back here.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T19:20:35Z.
Thanks for the numbers, @parl0v. From the code, #6678 doesn't change which buffer a read binds. An import under 1 MiB is read in place from host memory on both trees; main creates it too, unwatched.
What #6678 changes is the write tracking. Once its settle read lands, the import is back in the write watch, and watched memory takes the unit-shadow path (
ShadowDestinationForinUnitShadow.cpp). A storage image's write-back then goes to a device-local slab instead of straight into the import. Units it covers only partly are first seeded from the import, and the slab is published back when something reads the range. On main these imports stay unwatched, so none of that runs for them. If those three dispatches write small storage images, the seeds and publishes would be new GPU work per frame. They may also land in the dispatches' own GPU time.Could you run #6678 once more with
APS5_NO_UNIT_SHADOW=1(same title screen, same profile env)? If those dispatches drop back to main's GPU time, that's the cause. The fix would then keep imports under 1 MiB off the shadow path, or skip the seed for them.Two lines from each tree, over the same window, would also help:
[storage], itsshadow:part (retiled, seeds, published by reason);[buffers] host imports under 1024 KiB: ...line. That tells whether settles keep running once the title screen is steady, as they would for imports that come and go every frame.If your per-program lines have dispatch counts too, the per-dispatch time would rule out a change in how often they run.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-16T20:14:55Z.
@parl0v #6678 now also has
APS5_NO_DEFERRED_SETTLES=1(5f822a5008), which keeps every import under 1 MiB compared, as on main. If you can, run it next to theAPS5_NO_UNIT_SHADOW=1run, so the settle's own cost and the unit-shadow path can be told apart.Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T08:33:20Z.
AMD / Windows data point: Radeon 780M APU (Ryzen Z1 Extreme, 16 GiB shared), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release. Title: SILENT HILL: Townfall (PPSA33286) from boot, same settings for both builds (
APS5_PROFILE_DRAW=1,APS5_ADDRESS_COPY_MAX_MIB=8192, 90 s cap).main3b10c7ef0main3b10c7ef0+ #6455 + this PR (d52283945)compute shader 0x14919ce00: AGC graphics: a heap mirror's range is no longer write-watchedunwatched heaps(image mirrors line)4507 settle reads submitted, 4525 back in the write watch, 0 retired during their read (0 unmaps waited for it), 0 pending; 189 larger imports settled inside their windowMerged without conflicts on top of
3b10c7ef0. Not measured: frame rate (the title does not reach a menu on this device in 90 s; on this APU the host heap is 3 GiB, see #7047), and the GPU tests of this PR.AI-assisted: yes (runs made on the device above).
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T08:40:53Z.
Thanks @keravyn-ops, that's a useful AMD data point. The abort's line is the throw #6646 handles: a heap mirror whose range has left the write watch, which #6646 plans again instead of failing (mariuszkreft's #6546 handles the same throw with a full refresh). With #6455 and this PR, imports under 1 MiB go back into the write watch without waiting (your 4,507 settle reads), so far fewer heaps are unwatched (3,711 → 829), which likely keeps that throw away for the 90 s. If you have time, a run of
main+ #6646 or #6546 would show whether the abort also goes away without the import changes. The peak private bytes aren't comparable, since themainrun stopped at 25 s.Imported from boykopovar/AnyPS5. Originally posted by HQasper on 2026-10-17T15:59:25Z.
Hello Neighbor (PPSA35154, UE4) on Windows and NVIDIA: 3.6 → 8.1 FPS in game
Setup:
47a266cf9with #6455 and this PR merged on top. Both merged without conflicts.47a266cf9. Neither PR changes the relinker.Method:
APS5_PAD_INPUT_FILE.47a266cf9Why it helps this title:
ProvedClearKeysnever gets a collect. A local counter showed 0 reused proofs out of about 400,000 per 10 s, every one withCollectWritesreturning 0.[dcc]reported about 570,000 key scans (78 GiB) per 10 s.DrawPipeline::run) put 15 % of it inAllKeysEqualunderreadDccKeys.CollectWritesreturning 0.Not seen or not tested:
With my local vertex/index-in-VRAM patch (described in #357), the in-game numbers are 5.82 FPS on main and 9.25 FPS with this PR.
Done with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T16:16:19Z.
Thanks @HQasper for the run, the synchronous control and the DCC counts, which show where the time goes on
main. Since every import here is made while loading, it fits that synchronous settling does as well as this PR in game; Resident Evil Village (PPSA01556), which imports at map time, is where the deferral makes the difference (the table in the description). I've added your run to Tested and Hello Neighbor (PPSA35154) to Unblocks.@parl0v, a follow-up on your RTX 3060 numbers. On an RTX 3070 Laptop GPU, Planet of Lana (PPSA19450) points the same way, but not clearly. In an OFF, ON, OFF run (
APS5_NO_DEFERRED_SETTLES=1for OFF, one build), GPU busy per present was 50.3, 54.4 and 44.0 ms, so ON was at the high end. That's inside the 6.3 ms between the two OFF runs, at unheld clocks, so we can't separate it from run-to-run spread. The frame rate showed no drop there (5.06, 5.00 and 6.08 fps), but that scene is CPU-bound. Details are in Tested.One thing this PR does that a GPU-bound setup like yours would feel more: while a title keeps making small imports, it submits their settle reads to the settle queue as often as every 100 µs, and on NVIDIA that queue is a second queue of the graphics family. Two commits on top of this PR,
EagleBearerYS:followup/6678-settle-batching(aaa1a3856e), hold the reads until 256 are queued or the oldest has waited 100 ms, so such a title submits there about ten times a second at most. Its testagc_import_settle_batchingchecks that 16 small imports a millisecond apart settle in at most 2 submissions.Could you rerun Minecraft Dungeons II's title screen with it, with the same setup and profile env?
APS5_NO_DEFERRED_SETTLES=1on the same build gives the row without settles, so one build covers both. Please merge it onto currentmain: the branch alone predatesmain's MinGW fix for a test's alignment (4fe92c9c23). If you have time for a third row,APS5_NO_UNIT_SHADOW=1from my earlier comment would still tell the unit-shadow path apart.Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-17T22:08:21Z.
Tested on Onimusha's menu: a small but consistent gain.
Setup: Onimusha: Way of the Sword (PPSA27836), boot to the language menu with no input,
APS5_TRACE_SECONDS=60:30, warm cache. Windows 11 26200, RTX 5070 (617.42), 3840x2160. Basemain84b0d2f24+ #6557 #6727 #6762 (5c521efea), 6 runs (3 before and 3 after the PR runs). The PR is merged on top of it (clean merge), 3 runs.Driver.Packet.memory_waitper frame in run 1: 107.0 ms on base, 78.5 ms with the PR. GPU busy is unchanged (27.4-27.6 ms per present).Summary lines (run 1 of each):
Traces available on request. AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T23:14:22Z.
Thanks @simonbronk, I've added your runs to Tested.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T23:26:45Z.
#7269 has merged. It keys host-import settle state per device, so this PR no longer merges cleanly (GuestBufferMemory.cpp). Could you rebase onto current main? The settle batch here (target, memory, fences) needs the same per-device keying, and the
settlesmember will need a new name so it does not collide with the one #7269 added. We will run review and full CI on the new head from there.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-18T01:39:42Z.
@oneandonlydean
mainis merged in at8f03535c8f(main98c251fc62), so the conflict with #7269 inGuestBufferMemory.cppis resolved. The settle batch is now keyed per device: each device'sImportSettleholds its batch target, memory, batches and their fences, next to #7269's buffer, memory and fence. A device switch keeps every device's batches, andClearHostImportswaits for and destroys only its own device's. The per-import map is nowpendingSettles, clear of #7269'ssettles. I merged rather than rebased, so the head you reviewed,5f822a5008, is the merge's first parent.On an NVIDIA GeForce RTX 3070 Laptop GPU (driver 617.42), the settle, write-tracking, watch and host-import tests (10 in all, listed in the description) pass 5 runs in a row each, with none skipped. On GitHub's runners (run), they and the
^agctests pass 3 runs in a row on Linux. On Windows, where the settle tests skip without a Vulkan device, the only failures areagc_driver_pm4_replay_toolandagc_shader_replay_tool, which fail the same way on that runner for an unrelated branch today (run).