perf(agc): stores beside a range in its 64 KiB block leave the range unchanged #6346
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6346"
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 SleglJan on 2026-10-15T12:43:45Z.
What
UnchangedSinceandUnchangedSinceAllanswered from the generations of the 64 KiB blocks a range touches. A CPU or driver store anywhere in a block failed every unchanged proof over any range in it. Among them are the proofs that let a draw keep its sampled textures (fastRevalidate), a reused image table (TableCurrent) and a storage image's upload (StorageTexture::refreshProved). Every caller of the two functions and ofStoredOvergets the finer answer. In some runs of 007 First Light (PPSA11386) the CPU writes other pages of the blocks that hold sampled textures in nearly every frame, and most fast revalidations fail and take the full walk.When a block's generation is newer than the query's, the two functions now look at what wrote the block: the CPU page generations over the range and the block's driver-store pieces, as
StoredOverdoes.StoredOverwas already used for this at the shared edge blocks of a surface's write-back (#441).So that this answer sees every driver stamp:
storeOwn) stamps the pages it finds dirty in a page map of their own.StoredOvercounts them only in a block without driver pieces; where pieces exist it answers as before.StoredAllSinceproves (#5554).A block without pieces or walked pages has therefore had no driver store. Forgotten pieces still count as a store over the whole block. One answer of
StoredOverchanges: a block whose newer stamp comes only from CPU stores to other pages no longer reads as stored over.Related:
noteDriverStorecreate a block's entry for a whole-block store; this change relies on that.Tested
agc_write_tracking:CheckSharedBlockProofs(new): CPU and driver stores beside a range leave it unchanged, alone and in a batch. These are seen:StoredAllSincekeeps an own store's exact coverage, is not proven by its dirty pages, and survives own stores elsewhere in the block; a neighbour in an own store's page is not stored over but reads as changed.CheckVersionRanges: the exact expectation was block-wide. It now checks three things:It also adds whole-block stores to the random history.
ctest -R '^agc'on this branch (onmain0e4ea13a0): 593 tests, 1 failure.agc_driver_store_over_untrackedfails the same way onmain3ee537191(reported on #5671).agc_driver_stencil_ref_exportskips itself on this machine.0e4ea13a0:ctest -R '^agc', 589 tests, 8 failures, the same 8 as onmain4e9a2a871built the same way. The container has no write watching, so the write-tracking tests skip there,agc_write_trackingincluded.d92a8dad3stops at frame 38 (the 2D-biased volume sampling check of #5461), so the runs use one tree:d92a8dad3plus 12 local commits.APS5_PROFILE_DRAW=1in every run, for the revalidation counters. Both arms of these runs also setAPS5_HOST_IMPORT_MIB=12288,APS5_RESOURCE_CACHE_ENTRIES=64andAPS5_NO_DRAW_SRT_ENTRIES=1.The counters are cumulative at the end of the run (frames 252–259). B4's menu started later than the others' (frame ~210 instead of ~175–185), so its window starts with the menu and it has fewer revalidations. In every 10 s interval that started after frame 150, the share of revalidations that took the full walk was:
APS5_TRACE_FRAMES=200:40set, warm caches, the same tree; the sandbox writes the log to a file. 2 of the 5 A captures ran at about 0.45 FPS over frames 215–255 (one of them while a build ran on the machine), none of the 6 B captures did. 6 are attached, the ones with a saved trace that ran without another load on the machine: 3 per arm (the trace files are the assets aps5-trace-A1–A3 and B1–B3 of https://github.com/SleglJan/AnyPS5/releases/tag/perf-traces-unchanged-shared-block, in the order of the lines below). Commit 7141b56717d8 is the A build and 91e399694be4 the B build (both local). Frame p50, base (A): 2,240, 1,547 and 1,561 ms; with the change (B): 1,554, 1,641 and 1,553 ms. The first A capture had 327 ms of GPU work per present against 158–166 in the others and 11,028 ms ofDriver.Packetper frame against 7,636–8,083.Checklist
main; 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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-15T12:47:58Z.
aps5-trace-A1.json.gz
aps5-trace-A2.json.gz
aps5-trace-A3.json.gz
aps5-trace-B1.json.gz
aps5-trace-B2.json.gz
aps5-trace-B3.json.gz
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:49:25Z.
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/Execution/src/GuestMemory.cppL1146-1147core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppL1661-1687core/libs/prx/libSceAgcDriver/tests/WriteTracking.cppL200, L1106core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppL1661-1687core/libs/prx/libSceAgcDriver/tests/WriteTracking.cppL200, L1106Some 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/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppImported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-15T14:24:30Z.
Independent CPU correctness check at exact head
c128308d4053faa60b6eaa617e5ea314841980de, Ubuntu 24.04 / kernel 7.0.0-38 / GCC 13.3 / Ryzen 9 9950X, with real Linux write watching.The unchanged
WriteTracking.cpp, linked directly with the productionGuestMemory.cpp,GuestAllocations.cpp,GuestArena.cppandGuestWriteWatch.cpp, passes 3/3. Replacing onlyGuestMemory.cppwithHEAD^makes that same test fail 3/3 atstores beside the range in its 64 KiB block count for it. No tracker or write-watch implementation was mocked. Standalone build: C++20,-O2 -pthread -msse4.2, function/data sections and linker garbage collection; this bypasses our unrelated SDL/XRandR configure blocker.I also ran an external history oracle to vary the offsets beyond the fixed offsets in
CheckVersionRanges:CollectWritesUncached(modeled at page granularity), whole-blockMarkWritten, variable-lengthMarkWrittenspanning up to two blocks, and actualStoreOwnByteswrites up to 8,193 bytes. Starts and queries vary across page/block boundaries.6346,1,0xdeadbeef,0x61387a29,0xffffffffffffffff: 368,640 single queries and 122,880 batches pass. There were 22,147 unchanged answers, so this did not pass by returning changed for everything. Write-watch availability and nonzero collection results are hard requirements, not skips.entry.whole = 0) is caught at step 1; forgetting overwritten pieces (entry.dropped = 0) is caught at step 33, both with seed 6346 andunsafe unchangeddiagnostics. The untouched PR stock test and oracle pass again afterward; the worktree stays clean.Scope: sequential CPU tracker correctness after dirty-page collection. This does not check concurrent renderer interactions, Windows private mappings, GPU execution, or the reported title performance; no FPS claim.
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-15T15:07:56Z.
Rebased onto
main0e4ea13a0after #5554 merged, and force-pushed as5532d51fb.#5554 added
StoredAllSince, a proof that driver stores covered every byte of a range. To keep it exact, the walk after an own store no longer records its dirty runs as driver pieces. It stamps them in a page map of its own:StoredOvercounts them only in a block without driver pieces; where pieces exist it answers as onmain;StoredAllSince.On Windows, a private mapping made over a block with driver pieces marks them as forgotten instead of dropping them; a block without pieces gets no entry.
New checks in
CheckSharedBlockProofscoverStoredAllSinceafter own stores and a neighbour in the page of an own store. #5554'sCheckStoredAllSincepasses unchanged.RTX 3080 (NVIDIA 615.78.08), on
0e4ea13a0:ctest -R '^agc', 593 tests, 1 failure,agc_driver_store_over_untracked, which fails the same way onmain3ee537191(see #5671).agc_write_trackingfails without the GuestMemory.cpp change and passes with it.@simonbbby, thanks for the check at c128308d4. New since that head: the page map, and on Windows existing pieces are marked forgotten instead of every block being marked stored whole. The merge of touching same-generation pieces is gone, and the whole-block entry now comes from #5554.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-15T16:23:50Z.
Retested the changed page-map semantics at
5532d51fb80902de94501f3e0f360c94f5553ca1; my earlier result remains pinned toc128308d4.Same Ubuntu 24.04 / kernel 7.0.0-38 / GCC 13.3 / Ryzen 9 9950X setup, standalone production CPU objects and real Linux write watching:
WriteTracking.cpp: 3/3 pass, includingCheckStoredAllSinceand the new own-store/neighbor checks. Substituting only currentHEAD^'sGuestMemory.cppfails 3/3 at the shared-block proof assertion.StoredAllSinceanswer against a separately sorted union of newer driver intervals. CPU-only page events are excluded from that union. Conservative false answers remain allowed when history has been discarded.one dword store proves complete surface coverage; the independent oracle also rejects it at step 8 with anunsafe complete coveragediagnostic. Omitting the newnoteWalkStorecall fails the stock test ata guest store beside a driver store in its page during the store is not seen. That neighbor-write case is covered by the stock fixture; the external oracle's own-store events model the declared store spans.This covers the important separation: dirty pages can invalidate an unchanged proof without claiming that the driver stored every byte on those pages. No repository source was changed. Scope remains sequential Linux CPU tracking after collection; Windows private mappings, concurrent renderer interactions, GPU execution and title performance were not tested.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-16T18:03:14Z.
Windows/RTX5070Ti617.42 combined cross-test is ready at51b148e100509891c9b194da360e6dd80bdeb16b: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-watch-proof-current . Includes #6346
5532d51fband #6273 fdcbb838d, on main93e54cedd plus our explicitly listed007/shared-table/level prerequisites. Both author commits applied cleanly; no replacement implementation.30/30 selected native CPU/Vulkan checks PASS14.19s, no skips, including write_tracking's new cases, repeated-neighbour stores, image-table reuse/bounds, shared-table vouches, draw reuse/verify/inline, storage flush ordering, tessellation, serializer/cache and prebuild unset/0/1. Conventions clean. After final revision-string rebuild,5/5 related controlsPASS1.46s. Combined native evidence, not standalone each-PR evidence; no title FPS result yet.
Integration test adjustment: the
a driver store over an entrycase now counts2reuse/1resolution across its two dispatches, instead of1/1. With the finer range proof, clean siblings are reused even on the dispatch that rebuilds the changed entry. Both texel checks retained; no production proof weakened. #6273's CpuWriteResolutions=1 is retained. All other current #6340 expectations pass unchanged.There is also an opt-in bounded copied-buffer ownership sampler in this test branch (maximum25small records per process, no game contents). Its initial asynchronous output triggered a native process-exit timeout; sampler-off control passed, and switching it to the existing direct trace sink made all3prebuild policies pass with sampling on. That defect was mine, not attributed to either PR. The full native result above has sampling enabled after the correction. Starting a guarded007 cross-test next. AI-assisted: Codex; raw title data local.