perf(agc): keep adjacent ranges one import serves as one region of the cached address space #4428
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4428"
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 hypermoist on 2026-10-12T10:53:59Z.
What
GuestBufferMemory::AcquireRegisteredpublishes a cached address space with one region per registered range, while one host import can serve a whole run of adjacent ranges (importRun). A V# that crosses the boundary between two such ranges is then not inside any one region, so the build dissolves the shared space into its own regions: on Killing Floor 3 (PPSA08427) that is about 10k regions copied, sorted and looked up, 700-1,300 times per 10 s at the title screen.When the space is published, adjacent ranges served by the same import (same import, contiguous, same writability, no mirror, not sparse, inside the import) are kept as one region. A V# across them is inside that region and is bound in place from the import, the same binding a V# inside one range already gets.
Tested
Linux (CachyOS, kernel 7.2.9), RTX 3060 (NVIDIA 615.78.08), GCC 16.2.1, Release.
agc_driver_graphicsgets a case (spaceImportRunTestsintests/BdaResources.cpp): two adjacent 64 KiB read-only ranges one import serves, and a V# across their boundary. On currentmainit fails (a V# across one import's ranges dissolved the cached address space); with this change the second build is a space hit and nothing dissolves.mainalone: it stops before its first frame atclip distances, layer, viewport or auxiliary vertex exports is unsupported (register 0x207 = 0x0040000f)(#423).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01Uzy15wqYTt6iWyxYXEzUWo
Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-12T13:27:22Z.
@hypermoist I tested this on Sword of the Sea (PPSA25344) in the opening cutscene. In this scene, partial overlaps used to dissolve the cached address space in about a third of all address-based builds. With this PR the dissolves are gone.
Setup. Windows 11, RTX 5070 Laptop (616.92). Two 900 s in-scene rows, each a lab branch of
mainplus local patches for this title. The before-row has no #4428. The after-row has this PR cherry-picked unchanged, but it also carries other local changes: dispatch template relocation, a draw-path change and several experiments. So only the[address]dissolve counters below are attributable to this PR. One of those changes is a local overlay that also targets partial overlaps. It printed "0 overlays used" in every window of the after-row, so the counters come from this PR, not from it. No FPS claims.[address], per 10 s, last 20 windowsFor context only: the before-row spent 132 s of 247 s of dispatch resource time in "resources: A locked (bda)", the locked stage A of address-based builds, which includes the dissolve and re-merge. The after-row spent 2 s of 78 s there (cumulative
[dispatch]phase totals,APS5_PROFILE_DRAW=1). The other changes in the after-row also shrink resource time, so that ratio is not this PR's alone.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T13:29:48Z.
Rebase handoff — rebased onto current
main, authorship unchanged.One test-file conflict with main's newer BDA tests: both sides add independent test functions at the same spot — kept main's
failedImportRemapTestsand this PR'sspaceImportRunTests, with both called.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV):tools/check_conventions.py --base origin/mainpassesTo pick it up:
Head is
fd7ce3ff2.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T07:28:40Z.
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/tests/BdaResources.cppL177, L1204-1205core/libs/prx/libSceAgcDriver/tests/BdaResources.cppL1204Imported from boykopovar/AnyPS5. Originally posted by TideOPL on 2026-10-13T10:14:54Z.
Tested on Minecraft Dungeons II (PPSA16064) gameplay at the Squid Coast spawn: Windows 11, RTX 5070, trace window 25-40 s after the HUD (#4526 trace,
APS5_TRACE_SECONDS=25:15). Base:main+ #4367 #4515 #4517 + #3816 + #425 + #3763 + local patches MCD2 needs.On MCD2 this removes a run-to-run bimodality. In about half the runs, about 4 address-based dispatches per frame dissolved the cached space (
[address] dissolved: overlap, about 320 per 10 s): a V# crosses the boundary of two adjacent registered ranges that one joined import (#4517) serves. Each dissolved build then sorts and merges about 1,200 regions (sort ~630 us + merge ~730 us + bindings ~650 us). With this PR (together with #4248) there are no dissolves in any run.Together with #4248, #4012 and #4603, interleaved, 3 runs each: p50 118.6 / 130.6 / 129.1 ms -> 110.9 / 110.8 / 111.9 ms, p99 127-141 -> 121-127 ms.
Not run: Linux, AMD, the PR's own tests.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:09:09Z.
Checked the region merge in
AcquireRegistered(same import, contiguous, same writability, no mirror, not sparse, inside the import; order preserved), the newspaceImportRunTestscase (fails without the change, passes with it) and thelibSceAgcDriverctest scope on RADV; also confirmed by @AlxcBTW and @TideOPL on real titles. Merging once the full build is green.