perf(shader): size the result memo from host memory #12828
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12828"
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-10-29T11:48:18Z.
What
The shader result memo kept at most 256 MiB of results unless
APS5_RESULT_MEMO_MBsaid otherwise. A title whose stages patch many result variants keeps that memo full: every insert past the budget trims it back to three quarters, and the trimmed results come back as full materializations.In RESIDENT EVIL requiem (PPSA31246), the
[recompile] result memoline (APS5_PROFILE_DRAW) in the first level shows this, per 10 s:APS5_RESULT_MEMO_MB=2048): 101, then 17, then 1 miss; materialization near 0; nothing trimmed; about 2 GiB held.With this change, when
APS5_RESULT_MEMO_MBis unset the device sets the budget to a sixteenth of the host's memory, between 256 MiB and 4 GiB (ShaderRecompiler::ResultMemoBudgetFor). That is 2 GiB on a 32 GiB host and 512 MiB on 8 GiB. An explicitAPS5_RESULT_MEMO_MBstill wins.memoryMiBinPerformanceTrace.cpp, exported asHostMemoryMiB). It returns 0 when the query fails, which keeps the 256 MiB floor, so device creation does not depend on it.HostMemoryLimitBytes) is cgroup v2memory.maxor v1memory.limit_in_byteson Linux (maxmeans none), and the job object's job or process memory limit on Windows.ResultMemoBudgetForandSetResultMemoBudgetare added toshaderCacheReviewedNames. They only decide how many results are kept in memory, never what a recompile produces, so the disk cache key is unchanged.Tested
Windows 11 (26200), Ryzen 7 9800X3D, 32 GiB, RX 9070 XT (AMD 26.6.2 / 32.0.31021.1015), MinGW GCC 15.2, Release. The base is
main578b8311ac.agc_shader_result_memo_budget_sizing(verifyResultMemoBudgetSizingintests/ShaderMemory.cpp):agc_shader_result_memo*tests pass 4 of 4 oncd4d01c, and the rest ofagc_shader_memorypassed on the first head.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R "agc_shader_memory|agc_driver_sampled_cache_budget|agc_driver_resource_cache" -V, same machine and GPU:main: 10 of 10 pass, 0VUID-, no "was not found but was requested by env var VK_INSTANCE_LAYERS".VUID-, no such line.APS5_PROFILE_DRAW; the memo counters are above. This PR makes no frame-time claim: atools/trace_digest.pycomparison ofmainand this PR from the same machine and scene, and a sweep of 256, 512, 1024 and 2048 MiB, are still to be done.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 CnRJay on 2026-11-01T19:50:57Z.
Review: COMMENTED
APS5_PROFILE_DRAWoutput. The miss and materialization counts (674-869 misses at about 2 ms per 10 s, then 101/17/1) come from the profile line, and the frame time is "15.5-16.3 s to 14.2-15.8 s, one run each", flagged as "not a clean A/B yet". The ranges overlap. Please providetools/trace_digest.pysummaries ofmainand of this change from the same machine and scene, or drop the speed claim and keep the memory-budget argument.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T06:57:43Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the remaining performance comparison is still pending.
What I ran
Reviewed head
cd4d01c4429b7939dd4aabedced22e37b6766857. I read the prepared description, commits, manifest, diff, and the full text of the changed files listed as included. I read the excludedShaderMemory.cpphunks throughrepo_read.py.No commands or tests were run. The reported test and hardware results are author supplied.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
PerformanceTrace.cpp; behavior with nested cgroup mount layouts was not verified.core/libs/prx/libSceAgcDriver/CMakeLists.txt,core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTrace.hpp,core/libs/prx/libSceAgcDriver/Execution/src/PerformanceTrace.cpp,core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp,core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp,core/shader/recompiler/CMakeLists.txt,core/shader/recompiler/Recompiler.cpp, andcore/shader/recompiler/Recompiler.hpp.files.jsonwas not available in the review folder, so no additional excluded files could be checked against it.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:54:38Z.
Review: COMMENTED
HostMemoryLimitBytesreads only the two fixed root cgroup files. A process can belong to a nested cgroup whose effective limit is lower than those files describe. The memo can then size itself from host memory and exceed the container's actual limit. Please resolve the process membership and mounted hierarchy, then apply the tightest applicable limit. A test with an unlimited parent and a limited child would cover the missed limit. The trial merge conflicts in the shader CMake, device setup and shader-memory code. Linux cgroup v2 hierarchy documentationAI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.