perf(agc): keep Windows host imports of write-watched private memory watched #6060
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6060"
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 parl0v on 2026-10-14T21:02:52Z.
What
On Windows, a host import without a section alias leaves guest write tracking, and its changes are found by comparison (
unwatchImportsis always set there). Since #5596, singly mapped direct memory is privateMEM_WRITE_WATCHmemory, so its imports take that path. On PPSA25344 (Sword of the Sea) every storage-texture refresh then compares its whole snapshot: about 579,000 compares of 2.2 TB per 10 s at the title, and the title drops from 8.13 to 2.09 FPS at the #5596 merge.#5851 moves these runs into a section so they import through an alias. That brings back write faults, and with them #361's red-zone crash on this title. This PR keeps the memory private and keeps its imports on
GetWriteWatch:ProbeImportWriteProtectiongets a Windows body: it imports aMEM_WRITE_WATCHscratch range, reads it twice on the GPU, writes it once, stores to it once, and collectsGetWriteWatchwith reset after each step.runImportProbenow takes the collect function, and Linux passes its own. It also reads a second time, forwrittenAfterSecondSubmit.decideImportWatchkeeps direct imports of private read-write memory watched (watchPrivateImports) when the probe shows nothing written after the second read and the GPU write, and the CPU store collected. Imports through views keep their alias path. The[write-watch]startup line reports the probe counts and the decision.ImportWatched's window would be taken as CPU stores newer than GPU results, which loses those results (agc_driver_layered_volume_submitfails that way). So each such import is settled inside the window:settleImportcopies 4 bytes out of the new import on a settle queue and waits, and the window's comparison drops the marks.importAllocationholds the imports lock, andGpuMutexcomes before it in the lock order, so the main queue can't be used there. On Windows the device gets a second queue of the graphics family, with its own pool and lock, for this read.APS5_NO_WATCHED_PRIVATE_IMPORTSswitch for the off side; it was removed in review (6c6a6c85a), and the other-family settle is tested byagc_import_watch_other_familyinstead of an environment switch.Tested
Windows 10 19045, MinGW-w64 GCC 15.2, NVIDIA 617.42. Measured on
maina050f856f; rebased onto0ae1deb85(the debt entry's neighbours changed), whereagc_import_watchandagc_driver_layered_volume_submitpass with the change and withAPS5_NO_WATCHED_PRIVATE_IMPORTS=1. Box 1: i5-14400F, 16 GB, RTX 4060. Box 2: i5-12400F, 32 GB, RTX 3060.libSceAgcDriverctest (box 1): 545 of 546 with the change, 545 of 546 withAPS5_NO_WATCHED_PRIVATE_IMPORTS=1. Both timesagc_shader_disk_cachefails because Windows denies removing its cache directory on this machine.agc_driver_layered_volume_submitguards the settle. Watched imports without it fail 3 of 3 (slice 1 texel (0, 0) channel 0 is 64, expected 255: the draw's band reads back as the CPU pre-fill). With it, the test passes.New ctest
agc_import_watch(agc_driver_recorder_tests --import-watch-only, like the other-onlyentries; on currentmainthe full recorder run isn't registered). The Windows branch ofimportWatchTestsnow runsProbeImportWriteProtectionand requires it to succeed and to collect the CPU store. That fails onmain, where the Windows probe returns "the Linux write watch", and the test doesn't build without the new field. On both GPUs the probe reports: 4 of 4 scratch pages at the import, 4 after the first GPU read, 0 after the second, 0 after a GPU write, 1 after a CPU store.Standalone probe: importing
MEM_WRITE_WATCHmemory of 16 and 4,096 pages on both GPUs gives the same pattern. The marks after the import are asynchronous: 1,632 to 3,033 of 4,096 pages before any submit, the rest by the first GPU use completing. A 4-byte read completes them.tools/check_conventions.py --base origin/main: passes.PPSA25344 title screen, same relinked executable and libraries, the change on vs
APS5_NO_WATCHED_PRIVATE_IMPORTS=1, alternating,APS5_PROFILE_DRAW=1, mean of the last twelve 10 s windows. The startup line readskeep the write watch: yes (... 0 after the second ...).[guestmem]compare per 10 sreadTargetper 10 s (box 2)app.exe+0x37f77b3(#361)Frame dumps (box 2, frame 2 of the title): mean difference 0.13 of 255 between off and on, 0.13 between two off runs. - Stops at
+0x37f77b3vs #5851, 120 s boots of the title, alternating, the same executable, both GPUs:f0854887d+22091410a)With #5851, imported direct memory is tracked through views and write faults again, and SotS's leaf at
+0x37f77b3reads its red zone back after one of them. This PR imports it as private memory, so it takes no faults.Fork CI (the
build.ymlsteps on GitHub runners): Windows passes, 1,217 of 1,217. Linux: 1,194 of 1,195. The one failure isagc_driver_recorderat(u) the dma-buf import probe failed at open /dev/udmabuf(the runner denies/dev/udmabuf), and plainmainfails the same way on the same runner. Linux's import probe prints the same counts on both (0 of 4 scratch pages written after a GPU read, 4 after a GPU write, 0 after the import), so therunImportProbechange leaves Linux as it was.Checklist
main; no other open PR implements the same functions (#5851 addresses the same #5596 effect by moving runs into sections instead; the two change different paths)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)Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T21:11:47Z.
Will do on Resident Evil Village (PPSA01556): resumed write faults,
[guestmem]compares, title presents per 10 s against the #5851 tree, and the Wwise thread's stop rate over unframed scene loads, plus the probe's decision on an RTX 3070 Laptop. Our PC is booked for the rest of today, so most likely tomorrow; results here.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T21:24:33Z.
Rebased onto
0ae1deb85(conflict was only the neighbouring lines of the debt entry). Currentmainno longer registers the fullagc_driver_recorderrun, so the import-watch check now has its own entry,agc_import_watch(--import-watch-only). It passes with the change and withAPS5_NO_WATCHED_PRIVATE_IMPORTS=1;agc_driver_layered_volume_submitpasses too.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T21:31:33Z.
Full
libSceAgcDriverctest on the rebased head (919f39109, box 1, RTX 4060): 556 of 557 with the change, 556 of 557 withAPS5_NO_WATCHED_PRIVATE_IMPORTS=1. The only failure both times isagc_shader_disk_cache(Windows denies removing its cache directory on this machine).Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T21:54:35Z.
Checked the diff against the repo rules and ran the libSceAgcDriver build and ctest on this head merged onto current
main:agc_import_watchandagc_driver_layered_volume_*pass; the only failure isagc_driver_tessellation, which segfaults onmaintoo. Windows/NVIDIA behaviour (driver marks, FPS, #361) rests on your measurements; the full Windows Build will run before merge.Added one commit on your branch:
docs/dev/ARCHITECTURE.mdnow describes the settled watched imports (second graphics-family queue, probe decision, lock-order reason, off switch), since the PR changes how host imports and queues work.Merging once the Windows Build is green.
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T21:55:15Z.
@adriadam10 thanks, and for the
ARCHITECTURE.mdcommit. Before merging: a 40-min title run with this PR (box 2, RTX 3060) stopped after ~12 min withvkAllocateDescriptorSets texture detiler: Vulkan result -2(out of device memory), on the presentation thread. I'm running the same 40 min withAPS5_NO_WATCHED_PRIVATE_IMPORTS=1now, to see whethermainreaches it too at the same frame count (it runs ~3× slower there), then the PR again. Results in about an hour; I'll post them here.Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-14T22:16:42Z.
Windows run of this PR on a third NVIDIA box, with a different driver branch from the two above. Head
919f39109merged ontomain4808d9c20(clean merge); Windows 11 10.0.26200, Ryzen 7 5800X (Zen 3), RTX 4090, NVIDIA 616.92 (Vulkan 1.4.351), MinGW-w64 GCC 15.2.0 r7, Release,BUILD_TESTING=ON, default environment.Full ctest: 1235 of 1235 passed, 14 environment skips (the same skips as
mainfa539dd9bon this machine, 1233 of 1233).The decision through the real
VulkanDevice(printed byagc_driver,agc_driver_layered_volume_submit,agc_driver_multisample_fill_host_only):The only difference from your 617.42 boxes is the first-read count: 0 here against 4 there. On this driver the one-time marks have all landed by the time the first GPU read completes, which fits them being asynchronous. The decision is the same.
libSceAgcDriverscope (ctest -R ^agc_), the watched path active: 557 of 557.agc_driver_layered_volume_submit5 of 5.The same scope with
APS5_NO_WATCHED_PRIVATE_IMPORTS=1: 556 of 557,agc_driver_multisample_fill_host_onlyfailed once. Rerun 10 of 10 with the switch, 10 of 10 without it, and 10 of 10 onmain, so I can't attribute it to this PR.agc_driver_layered_volume_submit5 of 5 with the switch too.One nit:
agc_import_watchruns on the recorder tests' own device, which has no settle queue, so its[write-watch]line readsWindows direct host imports use comparisons (no second queue to settle imports on)even where the real device decidesyes. The probe counts it prints are the same as above. If the test is meant to pin the decision, the test device would need the second queue as well.For the record,
vkGetPhysicalDeviceQueueFamilyPropertieshere: family 0 graphics+compute+transfer, 16 queues.No title on this machine, so no frame rate or
[guestmem]compare figures. Tested with AI assistance (Claude Code).Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T22:17:29Z.
@frankea thanks, a third box and an older driver branch is exactly what this needed. The 0 after the first read on 616.92 fits: the marks are asynchronous, and on your machine they finish before that read does.
On the nit:
agc_import_watchis meant to pin the probe, which is what fails onmain("the Linux write watch"). The decision with the settle queue is exercised through the realVulkanDeviceinagc_driver_layered_volume_submit, which prints theyesline you quote and fails if imports stay watched without the settle. If a reviewer wants the decision pinned inagc_import_watchtoo, I'll give the recorder tests' device the second queue.Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-14T22:22:49Z.
On AMD's Windows driver this PR falls back to comparisons, because the graphics family has a single queue.
Radeon 860M (RDNA 3.5), Windows 11 (26300), driver 32.0.13058.8001.
vulkaninfolists every family withqueueCount = 1: graphics+compute+transfer, compute+transfer, transfer, video decode. So thequeues[family].queueCount >= 2check inVulkanDevice.cppfails, and the startup line reads:SuperTuxKart (PPSA69421), title screen,
main9bec20233with and without this PR's head 919f39109, 60 s per run, runs alternating with #5851 on the same relinked executable:mainWith
APS5_PROFILE_DRAW=1this PR still compares 4997 calls, 41.2 GiB and 1.9 s per 10 s (main: 5333 calls, 44.4 GiB, 2.0 s), andreadTargetstays at 2973 ms per 10 s. Numbers for #5851 are in https://github.com/boykopovar/AnyPS5/pull/5851#issuecomment-6179812577.Other AMD parts on Windows likely expose the same single graphics queue. A settle queue from another family that can copy might cover them. Here the compute+transfer family already gives its one queue to sparse binding (the first non-graphics family with
SPARSE_BINDING), but the transfer-only family (TRANSFER | SPARSE_BINDING, one queue) is unused, if I read the queue setup right. I haven't checked whether the settle copy needs the graphics family specifically.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T22:23:57Z.
@LeandroLP23 thanks, that's a real gap. With one queue per family, AMD falls back to comparisons, so it loses nothing but gains nothing either (your 5.07 vs 5.13 FPS).
The settle read only has to make the import's allocation resident, and that happens per allocation, not per queue. So it doesn't need the graphics family. Plan: when the graphics family has a single queue, take the settle queue from another family with
TRANSFER. On Windows that's free: the sparse queue is only created with dma-buf imports, so it never exists there. The 4-byte read then goes through a small alias buffer bound to the import'sVkDeviceMemoryand created for that family, which avoids a queue-family ownership transfer on the import's own buffer. I'll push it here; would you rerun SuperTuxKart on the 860M when it's up? NVIDIA keeps its second graphics queue as now.Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-14T22:27:51Z.
Read #6060 at
919f39109(base0ae1deb85). The approach is sound and keeps #5596's private memory private, which #5851 can't. Notes, most important first:#5851 shadows this PR when both are merged. #5851 sets
writable = !GuestArenaResidentSpan(...)inimportRunAt, so resident direct memory goes to theMapAliaspath, andsettledrequireswritable. The two merge without conflicts, but with both merged #6060 never applies to resident runs, which is the memory it targets. They don't coexist in practice: whichever lands second has to decide. I'll take that on #5851's side once a Yōtei A/B of the two is done.The probe doesn't test the settle that production relies on.
runImportProbereads the whole scratch range (VkBufferCopy{0, 0, bytes}) on the main queue.settleImportreads 4 bytes at offset 0 on the settle queue. So the startup decision proves that a full read settles 4 pages, while production assumes a 4-byte read settles every page of imports that run to many MiB. Could the Windows probe settle withsettleImportitself (or the same 4-byte copy on the settle queue), on a larger scratch range (e.g. 4,096 pages, as in your standalone probe), and require 0 marks after it?A failed settle leaks the import. If
createImportsucceeds andsettleImportfails (vkAllocateMemory, or the 10 s fence wait),step != nullptrtakes the copy fallback but never destroysentry.buffer/entry.memory. The host pages stay pinned.destroyImport(context, entry)on that path would fix it.Each import now waits for a GPU round trip under the tracker lock.
ImportWatchedholds the write tracker lock (andimportAllocationthe imports lock) acrossimport(), which now includes a buffer create,vkAllocateMemory, a command buffer, a fence and a wait. A persistent 256-byte destination plus a reusable command buffer and fence would leave only the submit and wait. Do you have a count of imports per 10 s on Sword of the Sea? On Yōtei we saw ~11k resident-run imports in the first 300 s.Only devices with two graphics queues get it. The settle queue needs
queueCount >= 2in the graphics family. NVIDIA has 16, but AMD's Windows driver exposes one graphics queue, so AMD stays on comparisons. That's worth a line in the debt entry. A transfer-family queue would work for a 4-byte copy, but it needs concurrent sharing or an ownership transfer on the import.Checked and fine: the probe runs from
PrepareImportWatchin the device constructor, after the settle pool exists, so using the main queue there is safe. Linux's decision is unchanged (the extra read only fillswrittenAfterSecondSubmit).APS5_NO_WATCHED_PRIVATE_IMPORTSdisables both the queue and the decision.Yōtei (PPSA26344) A/B. RTX 4090, NVIDIA 617.42, i9-13900K, Windows 11 26200. All three builds share the same tree: our Yōtei branch, main at
9a3e2ac4dplus the PRs the title needs. A is that tree, B adds #5851 (ff303dac6+ the host-write guard), C adds #6060 (cherry-picked; the only conflicts were with our local timing counters). Same executable and warm shader cache. 300 s cold boots, order A B C C B A, no environment variables. The window is the first 240 s, because B and C both stop at about 255 s; more on that below. Here the startup line readskeep the write watch: yes (4 of 4 ... at the import, 0 after the first GPU read, 0 after the second, 0 after a GPU write, 1 after a CPU store). Unlike your boxes, all the marks land inside the import on this GPU.[guestmem]comparesImportWatchedcompute shader 0x8000316900: guest snapshot differs from registered memoryat 255–258 s. We have seen that check fail on this shader before (pre-#5596 builds, after 9–29 min), and we normally run withAPS5_NO_SNAPSHOT_CHECK=1. It looks like both PRs simply reach that scene sooner, while main hasn't reached it by 300 s. I'll look into it separately.On Yōtei, #6060 is at least as fast as #5851, takes no write faults and leaves memory private. If points 2 and 3 are addressed, I'd be glad to see #6060 merged and to close #5851 in its favour. Only the private peak favours #5851.
Written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-14T22:28:21Z.
@parl0v yes, I'll rerun SuperTuxKart on the 860M (same alternating A/B against
mainand #5851, plus the[write-watch]decision line) once the transfer-family settle queue is pushed.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T22:48:09Z.
@Pipodi thank you, that's a thorough review, and the Yōtei A/B is great. Pushed
2406c85f6:runImportProbetakes an optional settle step: the Windows probe imports 4,096 scratch pages, settles them withsettleImportitself (the 4-byte read on the settle queue), and the decision requires 0 marks after the settle, after both full reads and after the GPU write. RTX 4060, 617.42:4096 of 4096 scratch pages reported written at the import, 4096 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.destroyImport, handles cleared) before the copy fallback.HostImports, freed inClearHostImports), so an import pays only the reset, submit and wait. I'll post imports per 10 s on SotS with the stability numbers below.VkDeviceMemory, so no ownership transfer touches the import's own buffer.APS5_SETTLE_OTHER_FAMILY=1forces that path on NVIDIA, andagc_driver_layered_volume_submit_other_familyruns it in ctest. frankea's point is covered too: the recorder tests' device now has the settle queue, soagc_import_watchsees the real decision.libSceAgcDriverctest (RTX 4060): 562/563 with the change, withAPS5_SETTLE_OTHER_FAMILY=1, and withAPS5_NO_WATCHED_PRIVATE_IMPORTS=1(onlyagc_shader_disk_cache, a Windows directory lock here).Still open, please don't merge yet: the 40-min run. With the change off, SotS ran the full 40 min (7,132 frames). With it on, run 1 stopped at ~6,400 frames with
vkAllocateDescriptorSets ... -2, and run 2 is at 31.6 GB private bytes after 13 min on a 32 GB box. I'm measuring private bytes over time on and off next, to tell a leak from the title's normal footprint. That ties in with your higher import count and private peak on Yōtei. Back with numbers.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T22:50:55Z.
@LeandroLP23 the transfer-family settle queue is in
2406c85f6. On your 860M the startup line should now readkeep the write watch: yes(the probe settles through the non-graphics queue). If it says otherwise, the line's counts will show which step failed.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-14T22:53:04Z.
Windows validation: merged head and retained integration
#6060 is merged in main
0afa6a607. Experimental fork checkpointb5682c8f3includes that main, merged native-depth #5496, and our retained MSAA/depth follow-ups. It removes the superseded #5851 automatic alias migration; Pipodi's separate host-write safety guard remains tracked in #6260.Current composition: full Windows app/libs and conventions pass. The selected 70-group matrix runs once per NVIDIA/AMD selector: 69 pass, one fails on each, no CTest skips; maximum 2.15s/2.13s. Forty-nine passing groups per vendor have physical-device output; the other20 are not GPU coverage.
agc_driver_multisample_fill_host_onlyfails 5/5 per GPU, before its first native clear after independent plain-buffer preflight:multisample target reuse requires watched guest memory; untracked writes are not implemented (color: range excluded by host import).bade5ae0ccomposition: temporarily setting onlysettleFloorBytesto zero makes both original fixtures pass5/5 per GPU; restoring the production1MiB value byte-for-byte makes both fail5/5 again. Zero is neither committed nor proposed as a fix. The exact offending import window is not isolated yet.This remaining failure belongs to our retained native-MSAA composition; it is not an unchanged-main/isolated-PR regression or a reproduced Sonic cause. The watch/refusal guard is retained. No title replay, gameplay/FPS, performance, Linux, console or full-suite claim.
Historical 02da644cd remains preserved:70 groups x5 per selector passed with the older6c6a6c85a head, before the floor. Those green results do not describe current main. Earlier focused probe evidence remains pinned to d027f8dda.
Windows11 Enterprise26200, WinLibs GCC15.2.0 Release; RTX5080 driver610.62/32.0.16.1062 and Ryzen9950X3D Radeon Graphics driver32.0.21036.18. Required Vulkan, shader caches disabled, serial tests,30s timeout. No local Khronos validation layer. The same-value CPU-store-during-settling question below remains open; no concurrent-store injection is claimed. AI-assisted: Codex.
Earlier CPU-window control and remaining question
A scoped Windows CPU control before I try this PR's Vulkan path: test-only fork
2fc4aba8e, based on unchanged maineea428ca855fb59a3edd394bab9abf99165590f1, adds only30 lines totests/WriteTracking.cpp.A volatile CPU store of the existing byte is detected outside the import window after
CollectWritesUncached. The same store inside anImportWatched(..., true)callback reproduces this 5/5 times:The added conservative
!UnchangedSinceassertion fails. This is deliberately a fault-control assertion, not a claim thatUnchangedSincehas the same contract asUnchangedSinceCollected: main's existing window tests already expect equal bytes to remainBlockUnchangedwhile retaining possible CPU-touch information. The event information is not lost altogether.Since this PR settles the import inside that existing comparison window, could its regression coverage also exercise a same-value CPU store during settling, including the consumer's invalidation predicate? In our retained native-color composition, a GPU image can differ from its old guest bytes, so a CPU store restoring those old bytes must not be treated as proof of no CPU store merely because the window's byte comparison is equal. This control shows which generic predicates retain that distinction; it does not reproduce a Vulkan import, concurrent settle-queue behavior, this exact PR head, or a game's producer.
Built the main-pin runtime libraries and fixture; used its configured CTest environment. Windows11 Enterprise26200, WinLibs15.2.0r7 Release/SPIRV-Tools ON, five serial runs, each below1s. CPU-only; no GPU coverage or approval claimed. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T22:54:08Z.
@Amoenus thanks, that's a fair control. A same-value CPU store inside an
ImportWatchedwindow is the limitation thePages under an import windowdebt entry already names ("A CPU store of the bytes already there within the window cannot be told apart from an import that resolves the write protection without storing").mainhas it for every watched import today.What this PR changes is the window's length. The settle read keeps it open for one round trip on the settle queue, about 0.2–0.25 ms per import by Pipodi's Yōtei timing. Same-value stores in that span stay indistinguishable by design, so a test pinning them would only pin the limitation. The guarantee worth covering is the other one: a CPU store of different bytes during the settle must still count as stored over. I'll add that case, a store from another thread while
settleImportwaits, and add a sentence to the debt entry that the settle lengthens the window.Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T23:00:23Z.
@Amoenus added in
f97762019(rebased onto6239ceffc):CheckImportWindowOtherThreadinagc_write_tracking. Another thread stores into the range insideImportWatched's window: new bytes must read asBlockWrittenwith the CPU-touch bit, and the same-value store must keep its CPU-touch bit. The debt entry now says the settle keeps the window open one round trip longer.agc_write_tracking,agc_import_watch,agc_driver_layered_volume_submit(+_other_family),agc_driver_store_over_untrackedandagc_driver_dcc_keys_first_writepass on the rebased head (RTX 4060).Stability update: a second 40-min run with this PR also stopped on
vkAllocateDescriptorSets ... -2(~22 min, 12,025 frames; the first at ~12 min, 6,474 frames). The run withAPS5_NO_WATCHED_PRIVATE_IMPORTS=1went the full 40 min (7,132 frames). Private bytes over time, on vs off, are running now. Still not ready to merge.Imported from boykopovar/AnyPS5. Originally posted by SoRadGaming on 2026-10-14T23:20:45Z.
Results on an AMD GPU: Windows 11 Pro 26200, Ryzen 7 5800X3D, Radeon RX 9070 XT (driver 32.0.23033.1002), 32 GB, WinLibs GCC 15.2.0, Release. The build is this head (
919f39109) as it is, relinked withmain's relinker.Probe. The graphics family has 8 queues here, so the settle queue exists. The startup line reads:
So this driver marks the pages only inside
vkAllocateMemory, and the first GPU read finds nothing, unlike the 4 of 4 on your NVIDIA boxes. A standalone probe agrees. It imports 512 pages ofMEM_WRITE_WATCHmemory, collects with reset at +0, 10, 50, 100, 250, 500 and 1000 ms, after a GPU copy, after a GPU fill and after one CPU store, for 5 rounds. All 512 pages are marked at +0 ms and none after that. The CPU store shows as 1 page.Tests.
agc_import_watchandagc_driver_layered_volume_submitpass, with the change and withAPS5_NO_WATCHED_PRIVATE_IMPORTS=1.ctest -R "agc_|guest_memory|write_watch" -j 6passes 561 of 562 with the change. The one failure,agc_driver_layered_volume_vertex_no_gpl(vertex draw: slice 1 texel (0, 0) channel 0 is 64, expected 255 (the band of layer 0)), also fails withAPS5_NO_WATCHED_PRIVATE_IMPORTS=1, and it failed onmaine34c47921before this PR. So it's an existing AMD failure, not this change, despite the similar message.guest_memorystopped once with 0xc0000409 under-j 6. It then passed 10 of 10 runs on its own, 5 with the switch and 5 without.ASTRO BOT (PPSA21564 01.007.000),
-lvl hub_crashsite(the full Crash Site hub), no input, no profiler, warm shader cache (1,904 hits, 0 misses). FPS comes from the window's present counter over 120 s, after a 120 s settle once the level has started.APS5_NO_SNAPSHOT_CHECK=1 APS5_RESOURCE_CACHE_ENTRIES=4096. Runs alternate on one executable and one set of libraries:APS5_NO_WATCHED_PRIVATE_IMPORTS=1(comparisons, asmain)That is 6.9× on this title. For scale, I also built the same tree with a local switch in
GuestArenaMapDirect_nid_postfixthat maps singly mapped direct memory through the section, as before #5596 (a diagnostic; it brings back the write faults). On that build, this PR gives 2.88 FPS and the section path 3.31 / 3.29. So this PR wins back about 85 % of what #5596 cost here, with no write faults.What's left is not in this PR's code.
APS5_SAMPLE_WORKERsampled queue worker 0 on that build over the same 80 s window of the hub in each mode, 5,124 samples each:GuestArenaCollectWrites→WindowsMappings::Collect→collectResident, that is,GetWriteWatchover resident runs. About 8 % is in the syscall itself.ShaderResources::fastRevalidateon every draw (6.5 %),StorageTexture::Refresh(2.5 %) andPrepareDrawBindings(1.4 %).cleanRangesand don't show up.So the rest is the cost of collecting #5596's resident write watch. It isn't the settle, which doesn't appear in the samples.
With #1201's pipelining on top (its head plus @Raghav314's and @eliyarson's ordering fixes,
APS5_PIPELINED_DRAWS=1), this PR's tree runs the hub at 4.81 / 4.92 FPS.There were no stops or errors in any of these runs: 7 launches with this PR active, 3 with the section switch and 2 with
APS5_NO_WATCHED_PRIVATE_IMPORTS=1.AI-assisted (Claude Code); the builds and runs are on my machine.
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-14T23:24:04Z.
@SoRadGaming thank you, that's the first non-NVIDIA confirmation, and a third title. 0.42 → 2.89 FPS on the Astro Bot hub, 85 % of what #5596 cost, with no faults. The marks landing only inside
vkAllocateMemoryon RDNA 4 fit the settle being a no-op there and the decision coming out the same. Your sampling also points at the next cost,collectResidentunderfastRevalidate, which belongs in its own PR.Status of the 40-min stop: it isn't this PR's code.
TextureDetiler::BeginBatchrecycles its descriptor pools only when the recorder is idle. With the title fast enough that the recorder never idles, it adds a 64-set pool for every 64 detiles untilvkAllocateDescriptorSetsfails (-2). On SotS that's about 31.6 GB private after 13 min. A separate fix recycles each pool once the batches that used it complete. With it on top of this PR, SotS is at 10.4 GB and flat after 10 min of a 40-min run, which is still going. I'll open it as its own PR when the run is done, and test #5851 on the same 40 min to confirm the stop isn't specific to either.Imported from boykopovar/AnyPS5. Originally posted by ivica00 on 2026-10-14T23:38:18Z.
Tested and verified on AMD Radeon RX 9070 XT (Windows 10 / Vulkan 1.3):
The PR notes testing exclusively on NVIDIA (RTX 4060 and RTX 3060). On AMD Radeon RX 9070 XT, the probe succeeds with identical semantics:
Test suite results:
agc_import_watch: PASSED (0.21s)
agc_write_tracking: PASSED (0.10s)
agc_driver_layered_volume_submit: PASSED (0.33s)
Title verification outside PPSA25344: Tested with Hello Neighbor 2 (APS5_PIPELINED_DRAWS=32, APS5_IMPORT_GPU_ONLY=1). Renders cleanly with zero visual regressions, no red-zone or memory corruption crashes, and clean frame capture.
Imported from boykopovar/AnyPS5. Originally posted by TideOPL on 2026-10-15T00:08:25Z.
Tested on Minecraft Dungeons II (PPSA16064), Windows 11, RTX 5070 (driver 610.88), WinLibs GCC 15.2, Release.
Without this PR.
main2559e9623plus our MCD2 test patches runs the title screen at about 2.5 FPS with a warm shader cache, so the Enter press doesn't register before our 200 s boot timeout. That's the #5596 cost.With this PR. Head f97762019 merged onto the same base: the title and the level load normally (title at 42 s, gameplay at 86 s on a cold cache) and gameplay renders correctly.
Gameplay frame times. Upstream trace (
APS5_TRACE_SECONDS=25:15, opened 25 s after the gameplay HUD), interleaved with our older play build onmainfeddf7f4c, which predates #5596:mainp50 / p99 msThe p50 is within about 2% of the pre-#5596 build. The two builds also differ in other ways (current
mainlacks #1201's draw-cache commits, which our older build carries), so this compares builds, not this PR alone.Not tested. #5851 side by side with this PR on the same base, AMD, and Linux.
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-15T00:11:53Z.
@ivica00 @TideOPL thank you both. That's a second RX 9070 XT and a fifth title, and Minecraft Dungeons II's p50 within about 2 % of the pre-#5596 build is the closest to a clean before/after so far. @ivica00, one detail: your line says 0 pages were marked by the settle read, so on RDNA 4 every mark lands at the import and the settle read has nothing to clear. Same as SoRadGaming's.
The 40-min stop is fixed by #6168. SotS with this PR plus #6168 ran the full 40 min at the title: 23,678 frames, no stop, private bytes 10.0 → 10.4 GB. This PR alone stopped with -2 at 12 and 22 min (about 31.6 GB). The bug is on
main; this PR only exposes it because the title no longer lets the recorder go idle, so #6168 is its own PR and can land first. With it in, this PR has no known stop left.Correction to my last update: the run I called "still going" was killed at 15 min by a stray script of mine, not by the build. The numbers above are from the rerun. #5851 is on the same 40 min now.
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-15T00:33:57Z.
@Pipodi the import count you asked for in point 4, SotS on box 2 (RTX 3060), this PR + #6168,
APS5_TRACE_HOST_IMPORT=1, 300 s from boot to the title, counted per 10 s present window:So on SotS the settle cost is a boot cost: about 98 % of the imports (and their settle round trips) land before the title's first full window, and the title itself imports about once every 14 s. Since the review commit the settle reuses one persistent target, command buffer and fence per device, so each of those is a 4-byte copy, a submit and a wait. Yōtei's ~11k in 300 s would be the heavier case; if its import window shows up in your timings I can look at batching the settles.
Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-15T00:39:20Z.
Besiege (PPSA20313),
mainat7003eda5dvs the same with this PR (f97762019) merged, Windows 11, RTX 4070 SUPER (610.88), 1080p: title screen 14.0 / 14.2 -> 20.5 / 21.8 FPS (+50%). The startup probe chose to keep the write watch ([write-watch] ... keep the write watch: yes).Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-15T00:53:52Z.
Validation on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, NVIDIA RTX 4070 (driver 596.21), Release,
BUILD_TESTING=ON, headf97762019against its base6239ceffc. Full build andlibsbuild without new warnings.Startup line:
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)Named tests, 3/3 each:
agc_write_tracking,agc_import_watch,agc_driver_layered_volume_submit,agc_driver_layered_volume_submit_other_family,agc_driver_store_over_untracked,agc_driver_dcc_keys_first_write.Non-GPU suite (
ctest -j8 --timeout 120 -E '^agc_driver_|^video_out_flip'): 807 of 809 pass.conventions_function_bodiesandhardware_oracle_comparetime out under-j8but pass alone (55 s and 16 s); both are tool tests this PR doesn't touch. Two tests are skipped for the environment.Checks:
tools/check_conventions.py --base 6239ceffcpasses,git diff --checkis clean.ccleste (PPSA59322), 60 s runs alternated on the same relinked executable, FPS over the last 30 s:
main6239ceffc6239ceffcFor reference, a pre-#5596 build (
c2565f014) runs 107.6.[guestmem]compares per 10 s (APS5_PROFILE_DRAW=1):main1,032 calls, 30.2 GiB, 5.7 s, AGC submit 2.8–4.2 ms per submission. This PR and #5851: 0 compares, submit 0.10–0.20 ms. Switching the singly mapped direct memory back to the old shared-section path onmainlocally also gives 0 compares and ~102 FPS, so the cost is the private write-watch import from #5596 (d9852df2a,71da166a1), the same mechanism @nikowolf123 named on #5842.10-minute run:
main39,196 frames, private memory 1,541–1,548 MiB after warm-up. This PR 67,924 frames, 1,431–1,438 MiB, flat, no stop. I can't reproduce the out-of-device-memory stop from the Sword of the Sea runs on this title.Control: Capy Mobile (PPSA92280) takes 0 compares on
mainand shows no difference I can attribute to this PR (2,094–3,033 frames per 60 s on both, noisy).Not covered: no AMD GPU here, so the single-graphics-queue path (settling on another queue family) is untested; #5842's reporter is on an RX 6700 XT, so that path is the one that matters there.
Two review notes: the PR adds the env switches
APS5_NO_WATCHED_PRIVATE_IMPORTSandAPS5_SETTLE_OTHER_FAMILY(the second used by a test), which the maintainers have been declining for new paths; and intests/WriteTracking.cpptheCheckImportWindowOtherThread();call inmain()is indented 4 spaces instead of 8.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-15T01:12:36Z.
@screamm thank you, that's the most complete run this PR has had, and ccleste at 113 FPS against 107.6 on a pre-#5596 build is a useful number for anyone asking whether this costs anything. Both review notes are in 6c6a6c85a:
agc_import_watch_other_family, which builds the recorder test device with its settle queue on another family, instead ofAPS5_SETTLE_OTHER_FAMILY. On the RTX 4060 its probe line reads4096 ... at the import, 4096 by its 4-byte settle read, 0 after it, so the settle does go through the other family. 3/3 for the six named tests,ctest -R '^agc_'563/564 (onlyagc_shader_disk_cache), conventions check andgit diff --checkclean.tests/WriteTracking.cppfixed.@JAB-dev thanks, Besiege at +50 % on an RTX 4070 SUPER makes six titles.
Longer run with #6168 at its reviewed head (
0e15b9be9): SotS title, 40 min, 23,605 frames, 9.96 FPS over the last twelve windows, no stop, private bytes 10.01 → 10.34 GB (+18 MB over the last 15 min).Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T03:52:00Z.
Review: CHANGES_REQUESTED
The new probe submits a one-time-submit command buffer twice. In
runImportProbe(GuestBufferMemory.cppline 2362) both command buffers are begun withVK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, andcommands[0]is then submitted twice (lines 2383 and 2385).Current main
a077a88dfwith head 6c6a6c85a merged,agc_driver_recorder_tests --import-watch-onlyunderVK_LAYER_KHRONOS_validation, on an RTX 5080 (NVIDIA 615.78.08) and the Ryzen 7800X3D's integrated Radeon (RADV):vkQueueSubmit(): pSubmits[0].pCommandBuffers[0] VkCommandBuffer ... recorded with VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT has been submitted 2 times.The recorder suite on main under the same layer reports no such submit. The test still passes, because both drivers run the buffer again anyway. Beginning
commands[0]without the flag would fix it.The PR's 18 import and write-tracking tests pass on NVIDIA, RADV and lavapipe on this machine, and on a Radeon 680M with RADV and llvmpipe;
agc_import_watch_other_familyskips (rc 77) on all of them.Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-15T04:04:00Z.
Rerun on the new head on this box.
6c6a6c85amerged ontomaina077a88df(clean); Windows 11 10.0.26200, Ryzen 7 5800X, RTX 4090 (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 r7, Release, default environment.Full ctest: 1252 of 1254, 14 environment skips. The two failures are
main's, not this PR's:agc_driver_image_plane_address_on_linefails the same way with #6168 merged onto the samemainand onmainate52e140f5(reported on #5583), andguest_kqueueaborts in #5493's newDeniedParentWatchcase because this session runs elevated (reported there). Both passed onmainfa539dd9b.Probe through the real device, the full new sequence:
So on 616.92 every mark lands at the import and the settle read has nothing left to clear, as on the RX 9070 XT reports; your 617.42 boxes see the 4096 by the settle read instead. The decision is the same.
agc_import_watch,agc_import_watch_other_family(same probe line, through the other family),agc_driver_layered_volume_submit,agc_write_tracking,agc_driver_store_over_untracked,agc_driver_dcc_keys_first_write: 3 of 3 each.agc_driver_layered_volume_submit_other_familyis not registered in this build.ctest -R ^agc_: 570 of 571, the one failure being themainsampling test above.No title here. Tested with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-15T04:43:40Z.
SuperTuxKart (PPSA69421) on NVIDIA: this PR takes it from about 4.5 to 7.5 FPS. A second finding is about the settle: in this title it runs about 320 times a second, and its wait costs a further ~19 %.
Windows 11 Pro 26300, Ryzen 7 5800H, RTX 3070 Laptop (NVIDIA 617.42), WinLibs GCC 15.2.0 r7, Release.
maina077a88df, alone and with this PR's head6c6a6c85amerged. Same relinked executable, the tutorial prompt on the title screen, 60–75 s runs, the title's own 5 s FPS lines. The startup line readskeep the write watch: yes (4096 of 4096 scratch pages reported written at the import, 0 by its 4-byte settle read, 0 after it, ...).This PR against
main(APS5_PROFILE_DRAW=1, per 10 s):mainreadTarget[guestmem]compareRuns without the profiler agree: 4.4–4.6 FPS on
main(2 runs), 7.1–7.6 with this PR (4 runs).The settle is not only a boot cost here. The title's Mesa winsys allocates, maps, unmaps and releases a 64 KiB buffer object around every submission, at the same address each time (
APS5_TRACE_MEMORY:allocate physical,map direct 0x255200000+0x10000,unmap,release physical, repeated). WithAPS5_TRACE_HOST_IMPORT=1that is 1,584–1,632 imports per 5 s window, all+0x10000. That is about 48 per frame, against the 0.7 per 10 s you counted on SotS after boot.Each import waits for its settle on the game's thread. A timeline of that thread, sampled every 100 µs for 3 s (30,000 samples, stacks walked by return address), puts 9.9 % of its time in
ZwWaitForMultipleObjectsunderImportWatched, which is ~0.3 ms per import. The submission loop is: submit, wait for the label, unmap, map, import + settle, write commands, submit.To check that the wait is the cost, I settled only imports of 1 MiB or more and left smaller ones on comparisons, as
maindoes. This was a local test patch inimportRunAt:Alternating runs, last six 5 s windows each,
APS5_PROFILE_DRAW=1:[guestmem]compare per 10 sSo the comparisons come back, about 0.5 s per 10 s on the queue worker, but the game's thread stops waiting, and the net is +19 %. The 17 MB target is still settled, so
readTargetstays low (407–412 ms per 10 s without the floor, 440–467 ms with it).A size floor is only one way to get this. The underlying issue is that the settle blocks the mapping thread. Not waiting would also cover large imports that come and go: submit the 4-byte read without the wait, keep the new import on comparisons until its fence has signalled, then drop the marks and switch it to the write watch. I have not measured either variant on SotS.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-15T07:38:17Z.
Rerun on AMD with the new head, as promised: with
6c6a6c85athe single-graphics-queue Radeon no longer falls back to comparisons, and SuperTuxKart goes from about 5.2 to 7.3 FPS.Windows 11 (26300), Radeon 860M (RDNA 3.5,
1002:1114, driver 32.0.13058.8001; every queue family has one queue), WinLibs GCC 15.2.0, Release.maind92a8dad3, alone and with6c6a6c85amerged (clean,f63402151). SuperTuxKart (PPSA69421) catalog release relinked with--trap-sdk-syscall-stubs, warm run folder, title screen, 60 s per run, FPS from the window title. Order:main, this PR,mainagain; the third run of each set hasAPS5_PROFILE_DRAW=1.main(first set)main(second set)[guestmem]compare in the last windowreadTargetkeep 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); direct host imports of private memory are settled and stay watched. So on this AMD driver, as on the RTX 4090 and the RX 9070 XT reports, every mark lands at the import.direct host imports use comparisonsline thatmainprints (2 per run) doesn't appear with this PR.On the previous head this GPU kept the comparisons ("no second queue to settle imports on") and stayed at
main's rate. This device has one queue per family, so the settle queue here can only come from another family: the pathagc_import_watch_other_familycovers.Not tested: the full CTest suite on this head, runs longer than 60 s, other titles.
AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T07:49:34Z.
Review: APPROVED
Re-checked the new head
6c6a6c85amerged onto currentmain:agc_import_watchandagc_write_trackingpass, and the only failing test in libSceAgcDriver isagc_driver_tessellation, which segfaults onmaintoo. Windows/NVIDIA/AMD behaviour rests on the runs reported in this thread; the full Windows Build runs before merge.Added one commit on your branch, for @fma-rc's finding:
runImportProbebeginscommands[0]withVK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BITand submits it twice, so the flag is now only set oncommands[1].Merging once the Windows Build is green. The 40-minute stop you described is #6168's, not this diff's.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T07:59:01Z.
Added a second commit (
fix(agc): settle only imports of 1 MiB or more) for @Dripl1x's measurement on SuperTuxKart:importRunAtnow settles only imports of 1 MiB or more (settleFloorBytes); smaller ones stay on comparisons, as onmain. This is the same change as the test patch above (7.4 → 8.8 FPS, the settle blocked the mapping thread on ~320 imports of 64 KiB a second); the 17 MB target on SotS is still settled.docs/dev/ARCHITECTURE.mdand the debt entry say so, and the debt entry records the non-blocking settle (submit the read, compare until its fence signals, then switch to the write watch) as not implemented. The code is Windows-only, so the full Build'swindowsjob is its check here; a rerun on SotS/STK with this head is welcome.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-15T08:00:47Z.
Two small notes before this merges. Both were seen with 6c6a6c85a, and both lines are unchanged at
23fccd7632./dev/udmabuf(Ubuntu 24.04, lavapipe),agc_import_watchfails:The check at
tests/Recorder.cpp:3818requires the probe to succeed whenever the device offers dma-buf import. The driver itself handles the missing device:[write-watch] dma-buf imports keep write protection: unknown (probe failed at open /dev/udmabuf, -1000072003); imported ranges are compared. Skipping that check when/dev/udmabufcan't be opened, asagc_host_import_sparsedoes, made it pass 5 of 5 there. That code ran in no ctest before this PR registered it asagc_import_watch.docs/dev/debt/libSceAgcDriver.md:61still opens "Windows host-pointer imports of the guest mapping itself are compared instead of write-watched". With this PR, writable private imports of 1 MiB or more stay watched when the probe passes and a settle queue exists, so that entry could narrow to the imports that are still compared.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T08:05:20Z.
@EagleBearerYS thanks, both done in
test(agc): skip the dma-buf import probe when /dev/udmabuf can't be opened:importWatchTestsnow opens/dev/udmabuffirst, asagc_host_import_sparsedoes, and skips the dma-buf probe (printing why) when it can't. Checked on RADV both ways: with the device the probe runs (0 of 4 ... 1 after a CPU store); with/dev/udmabufhidden in a mount namespace the driver logs the sameprobe failed at open /dev/udmabuf, -1000072003you saw andagc_import_watchpasses with/dev/udmabuf is not accessible: the dma-buf import probe not tested.docs/dev/debt/libSceAgcDriver.md:61now names the exception: writable imports of privateMEM_WRITE_WATCHmemory of 1 MiB or more stay watched when the probe keeps the write watch and a settle queue exists.Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-15T08:30:00Z.
SuperTuxKart on AMD with the new head, as @adriadam10 asked. The 1 MiB floor adds a little here: 7.2 FPS against 7.0 at the previous head, and both stay well above
main's 5.1.Same machine and setup as my earlier run: Radeon 860M, driver 32.0.13058.8001, Windows 11 26300, where the settle goes through another queue family.
maindb81992c5, alone and with each head merged. Warm run folder, title screen, 60 s per run, FPS from the window title. Order:main, previous head (5b91ba2bb, before the floor), current head (290be5626),mainagain. The third run of each set hasAPS5_PROFILE_DRAW=1.main5b91ba2bb290be5626mainagain[guestmem]compare, last 10 s windowreadTarget(profiled run)main's 1.9 s over 42–46 GiB.killed, two onmainand one on this head: my script killed a window that didn't close within its timeout. It isn't a crash.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-15T09:12:36Z.
Rerun of the merged head
290be5626(the 1 MiB settle floor and the/dev/udmabufskip) on the same Windows/NVIDIA box as my earlier run: Windows 11 Pro 26220, Ryzen 7 5700X, RTX 4070 (driver 596.21), WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,BUILD_TESTING=ON. The head was merged ontomaindb81992c5(clean). Themainside isd92a8dad3, this PR's base.Build: all targets and
libsbuilt without new warnings, exceptagc_driver_draw_program_trace_tests, which fails to link ondb81992c5(undefined reference to __gxx_personality_v0). That's #5238's new test;main's own Windows job failed the same way, and87ee02882fixes it.Startup line, unchanged from
6c6a6c85aand the same throughagc_import_watch_other_family: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); direct host imports of private memory are settled and stay watched. No other line in the title logs mentions the settle, and no import fell back to copies.Tests:
agc_import_watch,agc_import_watch_other_family,agc_write_tracking,agc_driver_layered_volume_submit,agc_driver_store_over_untrackedandagc_driver_dcc_keys_first_write: 3 of 3 each.ctest -R ^agc_ -j6, three passes: 569 of 573 pass each time. The rest are 3 environment skips (agc_host_import_sparse,agc_driver_sparse_dma_buf_import,agc_driver_stencil_ref_export) and the unbuilt trace test above.tools/check_conventions.py --base origin/mainpasses, andgit diff --checkis clean.ccleste (PPSA59322), method:
--trap-sdk-syscall-stubs, one executable for both sides, warm run folders;mainand this PR;APS5_PROFILE_DRAW=1on the third run of each set, with figures per 10 s.maind92a8dad3290be5626readTarget[guestmem]compareThe PR side presents 1,192–1,197 frames per 10 s, which is the title's 119.88 Hz output mode. So ccleste is at its cap on this side and can't show the floor's effect on frame rate.
mainruns faster than in my earlier run (73–83 FPS), while this PR stays at the cap.Imports (
APS5_TRACE_HOST_IMPORT=1, one run per side): 34 per run on both sides, all made before the first present window.10-minute run with this PR: 72,238 frames in 610 s, no stop. Working set 657.7 / 659.1 / 663.3 MiB and private bytes 1,115 / 1,116 / 1,120 MiB at 1 / 5 / 10 min.
Not covered: SuperTuxKart isn't on this machine, so no STK figures from here. @Dripl1x's and @LeandroLP23's runs cover it.
One note on the floor's test coverage:
agc_driver_layered_volume_submitwas named above as the test that exercises the settled decision through the realVulkanDevice. It imports only 256 KiB and 64 KiB ranges (0x40000three times,0x10000once), so since23fccd763its imports take the comparison path.APS5_TRACE_HOST_IMPORT=1across^agc_, 18 tests import a range of 1 MiB or more, e.g.agc_driver_host_import_windows,agc_host_import_retireandagc_storage_cpu_snapshot. The trace line doesn't say whether an import was settled, though, so I can't tell which of them reachsettleImportthroughimportRunAt.settleFloorBytes, and checks which one stays watched, would pin the floor.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-15T09:44:12Z.
Rechecked on
main0afa6a607after the merge:agc_driver_recorder_tests --import-watch-onlyunder the validation layer prints noONE_TIME_SUBMITmessage and no VUID on NVIDIA (RTX 5080) or RADV (Raphael iGPU), so5b91ba2bbresolves what my review was about.Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-15T13:59:32Z.
Tested on Windows 11, NVIDIA GeForce RTX 5070 Ti (driver 610.88), MinGW-w64 GCC 15.2.0, with RetroArch's Flycast core (PPSA99169) running the Crazy Taxi attract demo, unprofiled,
ANYPS5_PRESENT_MODE=immediate.I cherry-picked this PR's five commits onto a local stack (
maina453108cfplus local frontend support, #4943, #5906, #5609, a port of #1201's pipelined draw committer, and #6187, #6192, #6209, #6210). Same machine, the stack with and without this PR, runs alternated, two each: audio produced at 88.8% and 89.5% of real time with it, against 78.4% and 74.7% without. Frames dumped with it render correctly.The start-up line here reads
host imports of write-watched memory 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, ...).For context: on this workload, #5596 is what made most surfaces untracked on Windows. Before it, our local build on an older
main(with a local two-stage draw worker) reached about 98% here. #6187, #6192, #6209 and #6210 make the untracked path cheaper (comparison memo, fast revalidation, DCC key proofs, presenter epoch), but they don't make the memory watched again; this PR does, and it removes most of that cost at the source. They complement each other: what this PR keeps watched never reaches those paths.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Sevthered on 2026-10-15T14:50:29Z.
@parl0v Astro Bot on NVIDIA, after the merge. ASTRO BOT PPSA21567 v01.019.000 (my own copy, from a repack folder), Windows 11 build 26300, RTX 3080 Ti 12 GB on driver 616.56, Ryzen 7 5800X, 32 GB, WinLibs GCC 15.2.0, window 1152x648. I compared
maina5e2a80c6against the samemainwith this PR's merge reverted locally (the only conflict was its test registrations inCMakeLists.txt). Both use the same relinked executable, run folder, save and warm shader cache; runs alternate between the builds, each started after the previous process had exited. The startup line readskeep the write watch: yes (4096 of 4096 scratch pages reported written at the import, 0 by its 4-byte settle read, 0 after it, ...), so 616.56 also marks everything at the import.main-lvl hub_crashsite), 60 s trace from 360 s, two runs eachThe logos run about 3.5x faster. Crash Site goes from 1.4 to 3.5 fps (2.5x) against the reverted run whose window was in front; the other reverted run (63 presents) had its window in the background for the whole trace, so I wouldn't count it. The level start is logged at 84 to 118 s in every run, so the trace windows are inside the level, and the screenshots show the same idle scene in both builds. The "Crash Site" title card stays up for about 500 frames after the level starts in both, so at 390 s the reverted build, at frame ~1300, still has it on screen.
Two costs show up in every run: the first frame comes 5 s later (9 to 10 s against 15 to 16 s in the Crash Site runs too), and each logo trace has five long frames that the reverted build doesn't have, each with one dispatch spending 225 to 330 ms in
Vulkan.Dispatch.shader_resources. To see whether that's the settle, I put timing around theImportWatchedcall inimportRunAtin a local build (not for merging) and logged every import that took 10 ms or more:ImportWatchedaround the callback (waiting for the tracker lock, the zero scan of every page and the copy of the nonzero ones, the write walks before and after). The probe doesn't split those 6.7 s further. The 4.5 GiB import alone takes 3.2 s, with 0.6 s create and 0.23 s settle.0x37e000000while its start moves up by 1.3 to 1.5 MiB or 320 to 400 KiB each time (0x3360e0000,0x336254000,0x3363a0000,0x3363f0000,0x336454000). Each takes 295 to 348 ms: 165 to 185 ms create, 34 to 51 ms settle and 89 to 128 ms around the callback. In the probe run's own trace, the five longshader_resourcesspans (350, 345, 389, 399, 350 ms) follow those five imports (302, 295, 348, 344, 296 ms) in order, each about 50 ms longer.So on this title, batching the settles would have saved at most about 0.8 s up to the end of the logo trace; most of the time is the work around the callback, where Pipodi named the saved copy as the larger cost in review. I haven't run the probe on the reverted build, so I can't say what those imports cost without this PR, or whether that build re-imports the range ending at
0x37e000000the same way. A second probe run started with-lvl hub_crashsite(200 s) shows at least 47 imports; most of its time is the same boot imports. The traces havetrace_droppedset, so phase totals may be incomplete; frame counts and times come from the presents. Traces and the probe patch are available if useful.AI-assisted: yes (Claude Code); the runs are from my machine.
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-15T14:52:22Z.
@Sevthered thank you, that's exactly the measurement this needed: a clean revert A/B, plus a probe that splits the cost. 3.5x on the logos and 1.4 → 3.5 FPS in Crash Site on a 3080 Ti, and the two costs are real and ours. @TheAggie thanks too, 75–78 % → 89–90 % of real time on Flycast is a nice non-UE data point.
On the costs, my reading of your probe:
0x37e000000while its start moves up. Each one rebuilds the whole import, so the zero scan, the copy of the nonzero pages, the write walks and the settle all pay again for pages the previous import already tracked. The settle is the smallest part (34–51 ms of ~300), which matches your conclusion that batching settles wouldn't fix it.ImportWatchednow has to do the full window instead of leaving them compared.The follow-up I'll do: when a host import replaces one that covers part of the same range, only the part that is new goes through the zero scan, the copy and the settle; the overlap carries over the old import's watch state. That should remove most of the five frames and a share of the boot cost. I'll measure it on Minecraft Dungeons II (7,500 imports at load) and Sword of the Sea, and I'll ask you for a run on Astro Bot when there is a branch. If your probe patch is easy to share as a diff, it would save me re-instrumenting the same spot.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by Sevthered on 2026-10-15T14:54:37Z.
@parl0v sure, here it is, against
maina5e2a80c6. It only builds on Windows as it is, because the print usessettled, which only exists under_WIN32.totalis the wholeImportWatchedcall,createandsettleare timed inside the callback, so the rest is whatImportWatcheddoes around it. It prints every import that takes 10 ms or more plus every 500th, and the counters are cumulative, so the import count is the value on the last line printed.probe-import-timing.patch
Ping me when the branch is up and I'll run the same A/B on Astro Bot, logos and Crash Site, with the probe on top.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-15T15:45:40Z.
@Sevthered reproduced without the game, and the cause is upstream of the settle. A test maps 1126 MiB of singly mapped direct memory (1 page in 4 nonzero), imports it with
HostImportFor, then 5 times protects the next 1440 KiB of the head and re-imports[start + k·1440 KiB, end)(RTX 4060; medians of 3 runs, ms):ImportWatchedSame shape as your probe (create ~170, settle 30–40, the rest around the callback). What happens: any protect or unmap inside a registered range rebuilds every piece of it as a new
Range(replaceRange), including the untouched tail; the next lookup'srefreshImportssees a different range identity and retires the import, andimportRunAtpins the whole tail again, which with #6060 means a new watched window, zero scan, copy and settle. The new range is always a sub-range of pages that are still imported.The fix being built: keep the import when its range was split and the new range is an untouched piece inside it, and bind a new
VkBufferto the same imported memory at the new offset, so there is no new pinning, scan, copy or settle. To keep it exact, ranges carry a page-lineage serial that only the untouched pieces of a split inherit. I'll post the before/after from the same test, then ask you for an Astro Bot run on the branch.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-15T17:38:44Z.
@Sevthered the fix for your five long frames is up as #6499: an import whose head or tail is cut off by a guest protect/unmap is kept and re-attached to the surviving range with a new
VkBufferon the same imported memory, so the tail isn't pinned, scanned, copied or settled again. In the synthetic version of your pattern (1126 MiB, start moving up 1440 KiB five times) each re-import goes from 472–560 ms to under 0.02 ms, and the test checks the trimmed import still collects CPU stores and that the GPU sees the guest bytes.If you can, the same A/B you ran on Astro Bot would settle it on the real title:
mainvsmain+ #6499, the logo trace (do the five long frames go away?), time to first frame, and Crash Site. It doesn't change the first import of the big ranges, so the +5 s boot from the 4.5 / 3.2 / 2.1 / 1.4 GiB imports should only shrink by whatever part of it was re-imports.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-15T17:52:47Z.
Astro Bot (PPSA21564, v01.018.000, from the package I own), the title intro, on a third machine and a third driver branch. Windows 11 10.0.26200, Ryzen 7 5800X (Zen 3), RTX 4090 (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 r7, Release, 3840x2160. One executable relinked once from
maina077a88dfwith--windows --registry(no--to-intel), thelibs/directory swapped between three builds on that same base:maina077a88df, this PR6c6a6c85a(merge1b5ddbc4d) and #585122091410a(merge7720d00ee). Runs alternated main / #6060 / #5851 for three rounds, 200 s each,APS5_TRACE_SECONDS=120:40the only switch, no input. Round 1 of each build is its cold shader cache (main's window did not complete before the cap; the other two did and are listed), rounds 2 and 3 are warm.Startup line with this PR, every run:
keep the write watch: yes (4096 of 4096 ... 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); direct host imports of private memory are settled and stay watched.mainand #5851:Windows direct host imports use comparisons.So on this box this PR takes the intro from 3.0 to 15.1 FPS, GPU busy per present from 164 to 32 ms, and
Driver.Packet.memory_waitfrom about 640 to 130 ms per frame. #5851 on the same base lands at 16.0 FPS, within 6 % of this PR, and neither stopped.The window is wall-clock, 120 to 160 s after start, and the title advances per presented frame:
mainhad presented about 1,150 frames when its window opened, the two PRs about 2,600, so the PR captures sit somewhat further into the intro thanmain's. The three-frame-time consistency across rounds says the scene is stable within each build. No stop, fault or device loss in any of the nine runs; each was killed by the cap. Traces (aps5-trace-*.json.gz) and the full summary lines for every run are on hand if wanted. All summaries havetrace_dropped: true(the event buffer fills in about 6 s at this frame rate), the phase totals are complete.Summary lines (round 2 of each)
Tested with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by parl0v on 2026-10-15T17:54:23Z.
@frankea thank you, a third machine and driver branch, and a clean three-way on the same base: 3.0 → 15.1 FPS on the Astro Bot intro on a 4090,
memory_wait640 → 130 ms per frame, no stops in nine runs.On the 6 % to #5851 at the same scene: part of that may be the re-import pattern @Sevthered measured in this title (a ~1.1 GiB range re-imported with its start moving up, each re-import a full watched window and settle with this PR). #6499 keeps an import across such a split instead of re-importing it (472–560 ms → under 0.02 ms per re-import in a synthetic test). If you have a slot,
main+ #6060 + #6499 on the same three-round setup would show how much of the gap it closes.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-15T20:25:53Z.
Follow-up to the Astro Bot three-way above, now that this is merged: today's
main44df21632runs the same intro window at 20.0 to 20.3 FPS on this box (3 rounds), against 15.1 for head6c6a6c85aona077a88dfyesterday and 16.0 for #5851, withmemory_waitdown from 128 to 93 ms per frame and GPU busy unchanged at 31 to 32 ms. So whatever separated the two candidates here is gone onmain. #6499 on top of it changes neither the intro nor the logo sequence on this machine; details in https://github.com/boykopovar/AnyPS5/pull/6499#issuecomment-6201569153.Tested with AI assistance (Claude Code).