perf(agc): answer a write-watch collect from a per-block observation table #17766
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17766"
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 chitters2004 on 2026-11-09T15:07:22Z.
What
One owner now answers "has this guest memory been observed since collect epoch e" for every write-watch collect. A per-64 KiB block tick table (coarse minimum per 4 MiB) records the epoch at which each block was last walked. A collect whose blocks all carry a tick at or after its epoch returns
stablewithout an OS query, whichever thread made the earlier walk; stale blocks merge into runs, one OS call per run. Only a Complete walk publishes; refused, uncovered and failed walks publish nothing. The unwatch serial and mapping generation stay conditions of a hit. The per-thread ring, the epoch collect map and the shared ring are retired (APS5_NO_EPOCH_COLLECT_MAP,APS5_SHARED_COLLECT_MEMOremoved, with the two tests that ran those modes,agc_collect_mapping_history_ringandagc_collect_mapping_history_shared). Uncached collects stay uncached and publish.Overlaps: #9508 and #17697 touch a few lines of the same test file and
docs/dev/ENVIRONMENT.md. Whichever lands second, I rebase this one.Tested
Windows (RTX 3080, driver 621.14), head
cb1632e7ffon main6773f91a7e.agc_collect_memo_generation,agc_collect_coverage_*(#17542's tests, unchanged),agc_collect_mapping_history_*,agc_shared_write*andagc_write_tracking*pass; the new tests are red on main (two owners in one epoch cause one OS walk) and have a negative control. Seven mutants each turned the Windows test red on the earlier head (hit returns raw generation, publish on Refused, publish before stamps, ignore the unwatch serial, accept an older epoch, partial 4 MiB group answered whole, two forms); not rerun on this head, not run on Linux. Linux (WSL) tests not run on this head.Gate on
cb1632e7ff(ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, same machine and GPU), pattern covering the touched tests,agc_driver_frame_replay*and the write-tracking tests: plain main 279/279, change 277/277 (two removed variant tests); withAPS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1main 277/279, change 275/277 with the same two failures on both sides (agc_driver_draw_recapture_on_change,agc_driver_draw_unsupported_buffer_type_skip_refused). NoVUID-in any ctest log or subprocess.log, no missing-layer line.rk4 replay (7,745 draws per pass), A = replay kit (main + replay PRs), B = A plus this commit,
--repeat 5 --no-pace, the three pipeline variables, passes 2-5, A B B A A B B A A B, run twice (parent head 882d1414b4, thencb1632e7ff):commit_us_per_draw42.79 -> 41.30, delta -1.49 +/- 0.66 us, and 42.74 -> 41.29, delta -1.45 +/- 0.72 us (95% CI, 5 runs each, sd 0.2-0.7); committer CPU per draw and the timed window are within noise. Pixels identical, max channel diff 0, in all 20 runs. A profiled run per side: walking collects 39,214 -> 38,656, memo hits 260,959 -> 262,486 (cumulative over the run). Remaining repeat walks come from uncached callers, which this PR leaves alone.Live GTA V (PPSA04263, save
play1-first-autosave, 3840x2160, RTX 3080, driver 621.14, Windows 11, Ryzen 7 5800X,APS5_TRACE_SECONDS=235:30with the three pipeline variables): main6773f91a7e(A) against this headcb1632e7ff(B), one discarded warm-up boot per side, then pairs A B, B A, A B (fresh boot each, preflight, one timing claim; every linedirty: false; trace events dropped in every capture). Mean ms per frame A 125.63, 130.16, 129.87 (sd 2.54); B 126.86, 124.18, 130.48 (sd 3.16). Pair deltas B-A +1.23, -5.98, +0.61, mean -1.38 ms/frame (-1.1 %), inside the noise of both sides; at about 3,040 draws per frame (assumed, the summary has no draw count) that is -0.45 us per draw (-1.97 to +0.40).Driver.Draw.preparemean delta -0.21 ms,Driver.Draw-0.19,Graphics.Draw-0.92;CopyDrawInputis not in the top-8 phases. No frame-time claim. Traces and summaries: https://github.com/chitters2004/AnyPS5/releases/tag/pr-obs-t7Summary line, main
6773f91a7e(first timed A):Summary line,
cb1632e7ff(first timed B):Sub-block collects that cannot widen are kept exactly in a 16-entry ring under the tracker lock, so they walk once per epoch as under #17542's interval map.
agc_collect_memo_generationhas a case for it (fake write watch that refuses ranges above 16 KiB: red on the parent head, "a sub-block collect that could not widen reached the write watch again in one epoch"; Linux only, the Windows case needs an uncommitted neighbour page). Fork CI (Linux, run 42628752351): the collect, shared-write and write-tracking tests pass, no new VUID, and four mutants of the new lines (no record, ignore tick, accept a partial overlap, ignore the floor) are killed. The Windows gate below was rerun oncb1632e7ff.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)Known gap (not fixed here): a depth retirement can see a cached hit where an uncached observation is needed (
DepthSurface.cppWrittenUnitsbeforeretireStoringStale). It exists on main for one thread and is fixed at the caller by #16368; this PR does not change the caller.Overlaps in
GuestMemory.cpp: #12745, #16897, #16368 (caller-side depth retirement).🤖 Generated with Claude Code