perf(agc): patch the cached address space after an import change instead of rebuilding it #15919
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15919"
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 QRMOE on 2026-11-05T00:08:28Z.
What
Every import retire or join moves the host imports epoch, and the cached address space keys on it, so the next address-based build after any import change rebuilt the whole space: one
importAllocationper readable registered range, under the imports lock. In RESIDENT EVIL requiem that is about 35,000 ranges and 23 ms per rebuild, and with imports changing all the time it rebuilt about 100 times per 10 s ([address]line: imports pass 2,300–2,900 µs per build, epoch rebuilds 80–113 per 10 s). That was most of the "other" share of the draw resource builds, on the committer's critical path.When only the epoch moved and the registry generation is unchanged, the space's lease is still the one a build would acquire, so a build now copies the space and re-resolves each in-place region to the import that covers it now (
peekImport). It recomputes the BDA ranges and the mirror plan and keeps the heap runs' verified generations. If any region has lost its import, it rebuilds as before. The heap and sparse mirrors are checked as on a plain hit. The patched space is published with a compare-exchange against the space it replaced, so a pin waiter's drop in between keeps it unpublished.APS5_NO_SPACE_PATCH=1restores the rebuild, and the[address]line counts the patched hits.Tested
Windows 11 (10.0.26200), AMD Radeon RX 9070 XT, AMD proprietary driver 26.6.2.
spacePatchedAfterImportChangeTestsinagc_driver_graphics: a budget eviction of an import outside the space moves the epoch, and the next build must take a patched space (hit,patchedEpoch+ 1, no epoch rebuild) whose BDA ranges point into the blocks' current imports. WithAPS5_NO_SPACE_PATCH=1it fails, as expected.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R "^agc_driver_graphics$|^agc_driver_recorder$|bda|address|host_import|address_draw_space_reuse" -Vonmainand on this PR, same machine: the same results on both, 0VUID-lines on both, and neither log has the layer-not-found line.agc_driver_address_draw_space_reuse(all 5 modes) passes on both.agc_driver_host_import_failure_handlesandagc_driver_bda_deviceexit 0xc0000409 onmainas well.APS5_TRACE_SUMMARY_EVERY=30.mainyet to reach this scene. The baseline is my test tree f4a3b64a6f (mainplus those fixes). The PR build is the same tree plus this PR's two commits (03e4e8025d). The summaries saydirtybecause two submodules (freetype, vorbis) have local changes; the libraries come from those commits.registered image range changed after resource capture, which #15971 fixes; that fix is merged but not in this tree. Two of each are left.[address]counters: per 10 s, over the windows after the first 150 s with at least 20 epoch rebuilds (median, then range):APS5_NO_SPACE_PATCH=1.sceAgcCreateShader(sh_registers missing), which I hadn't seen in any earlier run, so I left them out.APS5_NO_PROFILE, so the summaries carry an emptytrace.Summary lines from the street scene, interval 20 of sb2 (baseline) and sp2 (this PR):
Full digests
sb1, baseline26 intervals, 0.0 to 819.3 s, 1276 presents
AMD Radeon RX 9070 XT, AMD proprietary driver 26.6.2 (LLPC), Windows 10.0.26200, 3840x2160, commit f4a3b64a6f5a (dirty)
sb2, baseline26 intervals, 0.0 to 820.2 s, 1012 presents
AMD Radeon RX 9070 XT, AMD proprietary driver 26.6.2 (LLPC), Windows 10.0.26200, 3840x2160, commit f4a3b64a6f5a (dirty)
sp2, this PR26 intervals, 0.0 to 826.1 s, 1211 presents
AMD Radeon RX 9070 XT, AMD proprietary driver 26.6.2 (LLPC), Windows 10.0.26200, 3840x2160, commit 03e4e8025d0b (dirty)
sp3, this PR26 intervals, 0.0 to 820.1 s, 1380 presents
AMD Radeon RX 9070 XT, AMD proprietary driver 26.6.2 (LLPC), Windows 10.0.26200, 3840x2160, commit 03e4e8025d0b (dirty)
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