perf(agc): write a pipeline cache save after six in a row were put off #28375
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28375"
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 oneandonlydean on 2026-11-30T10:26:16Z.
What
On Windows a periodic or requested pipeline cache save of 64 MiB or more is put off while the free memory would go under a reserve (
APS5_PIPELINE_CACHE_SAVE_FREE_MB, by default a sixteenth of the installed memory, at most 4096 MiB). The rule came withd655729836(28 Nov): a save from a buffer raises private memory by the size of the cache for the length of the save. A save that is put off is tried again 10 s later against the same rule, and only the save at teardown is exempt. So on a host that stays under the reserve no save happens until a clean exit, and a boot that ends on an abort or a kill loses every pipeline built after the last save.In #27759 anova44 measured that on a 32 GB host (reserve 2,043 MiB, 1 to 2 GB free through the wait, cache of 119 to 230 MiB): 3 saves, then 31 put off, and the boots never reach a teardown. With the reserve set to 256 MiB the same boot made 76 saves and the next boot replayed 649 pipelines in 6.4 s.
This bounds the starvation. After 6 saves put off in a row (one minute at the 10 s interval) the next save is written when the free memory covers what the save would hold, whatever the reserve. The count starts again after any save that goes through. A save the free memory does not cover is still put off, however long that lasts. The saver only reaches this check when the cache has changed since the last settled save, so a forced save always has something to write.
The cost in the worst case is one buffer of the cache's size for the length of a save, once a minute, on a host under the reserve. That is what every save cost before 28 Nov. The mapped save (
APS5_PIPELINE_CACHE_MAPPED_SAVE_MB) goes through the same check with four windows as what it holds.The decision is now one function,
PipelineCache::AffordsSave, so it is tested on every platform. A forced save prints one[pipeline-cache] saving ... saves in a row were put offline.zeezey, the reserve is yours: if a forced save once a minute is wrong for the hosts you had in mind, say so here.Refs #27759
Tested
Linux, NVIDIA.
agc_pipeline_cache_put_off(new): under the reserve the save is refused for 0 to 5 put-offs in a row and allowed from 6; never allowed when the free memory is under what the save holds; no reserve or no memory report allows it as before.agc_pipeline_cache*tests pass. With the put-off count taken out ofAffordsSavethe new test fails:a save the free memory covers was still put off after enough saves in a row were.agc_pipeline_cache_mapped_starved(new, Windows only, not run here): with the reserve out of reach, 6 saves of a 70 MiB cache leave the file as it was, the 7th writes it, and the next save after the cache grows is put off again. It needs the Windows run of this head.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T10:27:14Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the Windows-only behavior still needs its platform-specific test run before it is fully verified.
What I ran
Reviewed head
cbe945a6c4fc74b7279552587f0a3a362da95125usingrepo_read.pyto inspect the prepared diff and relevant code ranges. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
Not verified
No test execution, build, title run, or Windows host behavior was verified. The prepared review materials did not include
files.json; the manifest lists five changed files and all five were read:PipelineCache.hpp,PipelineCache.cpp,PipelineCacheFailures.cpp,agc_pipeline_cache_allocation_tests.cmake, andENVIRONMENT.md. No excluded-file listing was available.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T10:33:21Z.
Review: COMMENTED
Actionable comments posted: 1
Architecture findings (2)
Advisory architecture findings (2)
7c77933e-87a6-4879-ba9a-1eba65046d40Reviewing files that changed from the base of the PR and between
81ad4d40c5andcbe945a6c4.core/libs/prx/libSceAgcDriver/Graphics/include/PipelineCache.hppcore/libs/prx/libSceAgcDriver/Graphics/src/PipelineCache.cppcore/libs/prx/libSceAgcDriver/tests/PipelineCacheFailures.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_pipeline_cache_allocation_tests.cmakedocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.