fix(agc): put a retired import's unchanged ranges back in the write watch #8926
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8926"
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-21T06:29:15Z.
What
On main, Resident Evil Village (PPSA01556) aborts in its intro, between 0:43 and 6:37, with:
on main
6696def6e6. The regression is from our #6457, "import adjacent registered ranges as aligned power-of-two blocks". It was merged on 2026-10-19. Boots of main with #6730, then with #6730 and #6479 reverted still abort. Main with all three of #6457, #6479 and #6730 reverted doesn't.Cause:
retireImportdrops the pending settle and never restores the watch. An import retired before it settles therefore leaves its range outside the write watch for good.CollectWritesreturns 0, soacquireMirrorrefuses it. The build copies it, and enough of those copies reachAPS5_ADDRESS_COPY_MAX_MIB.refreshImportsretires the piece's import, before it has settled. The trace prints that as "the range was mapped again", although the range is unchanged.APS5_TRACE_HOST_IMPORT=1shows each page the FATAL lists, e.g. 0x2098900000+0x10000, as "ok … by map", then "retired: the range was mapped again", and never imported or watched again.The change:
refreshImportsand the budget eviction (retireLeastRecent) note its ranges that are still registered as the same range. Once the import is gone, those ranges go back into the write watch, as a settled import's do (GuestMemory::Rewatch).Rewatchstamps the range as written, so the next build reads it in full.Linux: imports stay watched there unless the import probe or
APS5_WRITE_WATCH_IMPORTS=unwatchsays otherwise, andRewatchis Windows-only. So this changes nothing on Linux, and the new case is Windows-only.Cost, measured on GitHub's Windows runner with a mock device (run, bench
exp/rewatch-cost4ef027a78, which is acc7b1792e, the same code as this PR's heada356b6a75a, plus a test-only benchmark commit; one run withmain's code and three with this PR). The bench replays a Resident Evil Village-sized load: 2,077 refreshes that retire 5,765 unwatched imports (2,278 MiB), with the CPU storing to every 4th page of each imported piece.main, which leaves those ranges unwatched. The whole workload takes 13.1 s, against 5.2 s.Rewatch. That is being looked at as a separate follow-up.Overlap with open PRs on the same path. Each was checked with
git merge-treeagainst this head.Rewatch. This PR covers the two existing retirements, when the run changes and on eviction.mainin the same two files with or without this PR.RetireIdleImportscan userewatchRetiredand get the same skips.refreshImportschange removes the trimmed-import reattach and keeps the retire loop this PR adds to. The two merge cleanly.refreshImportsit only clears its new set where the device changes, not in the retire loop this PR adds to. The two merge cleanly.refreshImports' loop over every import with achecklambda, which a full walk and a new incremental walk (only the imports a registry change can reach) both call.checkis the only place either walk retires an import, so this PR'snoteRetiredUnwatchedgoes there before the retire, andrewatchRetiredafter the walk (janzezno's composition). An import the incremental walk doesn't reach isn't retired, so it has nothing to put back.retireLeastRecentisn't touched by #9402. The two conflict textually inGuestBufferMemory.cpp; whichever merges second rebases into that shape, agreed in this thread.refreshImports' retirement nor the budget eviction. Each conflicts withmainin the same files with or without this PR.Tested
agc_driver_graphics, newretiredImportWatchTests(Windows):GuestBufferMemory.cpp: "AGC graphics: a 64 KiB piece whose import retired when its run grew into a block stayed outside the write watch", in 3 of 3 runs.GitHub's runners (run), targeted build of the graphics tests:
agc_driver_graphicsand theagc_heap_mirror_*tests, 27 tests. The libc and libkernel suites pass.mainstops attests/execution/ImageArrayWindowPastLayerLimit.cpp:33("requested alignment '65536' exceeds object file maximum 8192", MinGW), so the runs build the tested targets only.Resident Evil Village (PPSA01556) on Windows (RTX 3070), on main
1ff5c8ac5cplus 63d5414338 (this commit's code; the head differs only in its test), warm shader cache,APS5_TRACE_HOST_IMPORT=1: no copy-cap FATAL and no "outside the write-watched arena" copy in 43 minutes.1ff5c8ac5c, same build setup and shader cache, untraced: the copy-cap FATAL at 1:16, "an address-based build copies 121 MiB of 1943 registered ranges, past 64 MiB (APS5_ADDRESS_COPY_MAX_MIB); the largest: 0x2099d00000+0x10000 (0.1 MiB committed, outside the write-watched arena) …". On main6696def6e6it aborted between 0:43 and 6:37 in every run.SILENT HILL: Townfall (PPSA33286), by @keravyn-ops (comment), with #8622 (not ours).
-nothreadtimeout.APS5_PROFILE_DRAW=1,APS5_ADDRESS_COPY_MAX_MIB=8192, the default import budget (1056 MiB) unless stated, warm shader cache, no input, 360 s per run, one run per row.maincecb540a63, with #8622 atbf66eeccfdand this PR at acc7b1792e (the same code asa356b6a75a), each merged onto thatmain. GPU clocks weren't reported.mainand 1.17–1.32 with #8622, with 6.19 M and 5.53 M CPU-copy operations. The rows with this PR:unwatched heapsmain+ this PRmain+ #8622 + this PRmain+ #8622 + this PR,APS5_HOST_IMPORT_MIB=1536main+ this PR row "is a single run that hit the intermittent #7017 abort before the first frame, so it says nothing about #8926 alone".APS5_HOST_IMPORT_MIB=2600runs on #7047 did: avkAllocateMemoryof a 256 MiB device buffer fails (initialResult=-2), with heap 1 at 6221 of 2949 MiB.Checklist
main1ff5c8ac5c, and merges cleanly withmain0aa55ef293; no other open PR implements the same functions (see Overlap)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)