perf(agc): skip an address space's pending CPU write scan when none are pending #8895
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8895"
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 teepean on 2026-10-21T04:59:23Z.
What
An address-based build that reuses the cached address space runs
GuestBufferMemory::completeSpaceWritesinUploadFinish. It copies every pending write range of the open and in-flight batches (Recorder::PendingWriteRanges), searches each in the space's sorted regions (OverlappedRanges), sorts and deduplicates the hits, and asksCompletePendingCpuWritesabout each overlapped region. That call returns false at once when no copied writer (the context's orDrawCopiedWriters) and no completion label is pending, so in that case the scan finds nothing, however many pending writes and regions there are.The scan now starts only when one of them is pending:
AnyPendingCpuWrites(new, next toCompletePendingCpuWrites) makes the same test, once per build. When something is pending, the scan runs as before. Nothing else changes: the loop's only other work is the search, which records nothing.On Stray (PPSA02100) every address-based build in gameplay skipped it (18,758 of 18,758 per 10 s in a profiled run of my stack, where I timed the scan). On that stack, where the draw committer bounds the frame,
OverlappedRangesundercompleteSpaceWriteswas about 5 % of the committer's samples, and this change, with a one-line early return for an empty map elsewhere, was worth +2.4 % FPS there (16.57 to 16.98, four balanced rounds, all four won).Tested
Linux (CachyOS, kernel 7.2.10, scx_lavd), Ryzen 9 9950X, RTX 3090 (NVIDIA 615.78.08), GCC 16.2.1, Release.
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1, these pass with no VUIDs:agc_driver_bda_device_tests,agc_driver_bda_span_reads_tests,agc_driver_bda_anchor_reads_tests,agc_driver_copied_writer_copy_tests,agc_driver_address_passes_testsandagc_host_import_retire_tests. No test is added: with nothing pending the scan found nothing, so the change has no other effect.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchfinds no overlap. Of the pull requests it could not compare (they conflict withmain), none changescompleteSpaceWritesorCompletePendingCpuWrites; #6340 adds calls to the latter.Stray at the start of Dead City, stock
engine.ini, glibc, one run at a time, four rounds ofmain7e95bde794and this change in alternating order, with onlyAPS5_TRACE_SECONDS=185:20set:main7e95bde794mainfirst)mainfirst)Each cell is frame p50 / GPU busy per present / the draw committer's busy time per frame, in ms, from
tools/trace_digest.py. Round 4'smainrun stayed at 1.0 FPS for its whole window (frame p50 962 ms, the committer 83 % busy). That state is not from this change: it shows up on plainmainnow and then, and a run of another candidate fell into it the same night.On
main, Stray in this scene is bound by queue worker 0 (97-98 % busy), and the committer is busy about 48 ms of a ~168 ms frame. So the change can't show in the frame time here, and the committer's time stays within the spread between runs. It pays where the committer bounds the frame.Traces, summaries and digests: https://github.com/teepean/AnyPS5/releases/tag/perf-space-scan-skip-20261021 (every run's
aps5-summary.jsonlanddigest.md, and three traces: one run of each build close to the means and the 1.0 FPSmainrun).Summary lines of two runs close to the means
main7e95bde794:this change:
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