perf(agc): share unchanged shader registry chunks between published versions #7288
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7288"
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 milescoviello on 2026-10-17T21:26:27Z.
What
PublishRegisteredShaderpublishes each registration as a new immutable registry. In-flight submissions keep the version they were enqueued with. To do that it copies the wholestd::mapof code addresses, every node, every header vector and every snapshot reference, under the driver mutex. The old version is freed node by node once its last reader drops it. So registrationncosts O(n), and a title that registers its shaders while it loads pays O(n²) overall.ShaderRegistrybecomes a small class with the same interface the driver and tests use (find,upper_bound,contains,at, bidirectionalconst_iterator,operator[],emplace,erase,clear). It keeps its entries in address-ordered chunks of at most 64 entries, held byshared_ptr. Copying a registry copies only the vector of chunk pointers. A write clones only the chunk it changes, and only when another version still shares that chunk. A chunk that grows past 64 entries splits in half.PublishRegisteredShaderitself is unchanged: it still copies the registry and edits the copy, so earlier versions stay as they were.Lookup order and results are those of the map.
RegisteredProgramand the draw keys still find the greatest code address at or below an address throughupper_boundand--.Tested
Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99.02;
main6447ed1ed7.agc_driver_prepared_publication, newRegistryVersions:upper_bound,findandcontainsmust match astd::mapat and around every address.With
main'sShaderRegistry.hpp/.cppit fails 3 of 3 withpublishing a shader copied the registry's entries for other code addresses. With this change it passes 3 of 3.ctest
^agc_(671 tests): all pass.A local benchmark (not in the PR) publishes N shaders at random addresses through
PublishRegisteredShader, holding a few earlier versions as submissions do:mainmain82cad6b5fcand this PR on it. A local print (not in the PR) logged the registry's size at every 1,000 code addresses, timed from the first registration. The title registers about 2,000 shaders at start-up and the rest in a burst starting about 60 s after the first registration.mainunsupported registered shader type 8lines, distinct addresses)The difference in presents is in the first 10 s, the loading screen (0.2 ms of GPU work per present): 53 and 54 on
main, 19 and 18 with this PR. I haven't looked at why.Shader.Registeris aPerformanceTimerscope, but the trace records only the threads that bind a trace buffer (AnyPS5, the queue workers,shader prepare,presenter). Forspoken registers from its own threads, so no trace window has that scope:APS5_TRACE_SECONDS=0:60and45:40held none on either build. That's why the registration timing above comes from a local print. The summary lines of a45:40window (45 to 85 s after the first present) from two interleaved rounds of 100 s (main922dc8999e, this PR's code on it at 0b1f9c6d9e, noAPS5_PROFILE_*switch):The type 8 headers registered within those 100 s runs were 1,826 and 2,294 on
mainand 2,726 in both runs with this PR.check_conventions.pypasses.pr_overlap.pycouldn't compare five conflicting PRs that edit the same two files (#5115, #5431, #5958, #6134, #6188). Of the open PRs it could compare, none changes the registry type. A PR that calls astd::mapmember this class doesn't have would need that member added.Not checked on Windows, macOS, AMD or Intel.
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 github-actions[bot] on 2026-10-17T21:43:53Z.
Some 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/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp