feat(agc): seed a new recompiler folder's pipeline cache from the newest older one #27932
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/27932"
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 superSniper4576154 on 2026-11-27T20:37:26Z.
What
The shader cache folder is keyed by a hash of the recompiler's sources (
ShaderDiskCache::SourceVersion), and since #6771 the Vulkan pipeline cache file (vk-pipelines-<vendor>-<device>-<driver>-<uuid>.bin) lives in that folder. Any recompiler change therefore starts the pipeline cache empty, and every pipeline of the title goes through the driver compiler again. For PPSA38500's compute pipelines of about 1M SPIR-V words that is 40-100 s each on NVIDIA. The driver keys what it stores by the SPIR-V and the pipeline state, so the entries of the old folder are still the right ones for every shader the recompiler change did not touch.Why: a recompiler change that alters a few shaders should cost the pipelines of those shaders, not the whole title. No new instruction semantics and no change to what a pipeline is built from.
How: in the
PipelineCacheconstructor, once per folder, the file of the same name (same vendor, device, driver and cache UUID) in the sibling folder whose file was written last is merged into the live cache withvkMergePipelineCaches.<file>.seedednext to the cache file records the outcome (the sibling's folder name,refused <folder>ornone) and stops the merge from repeating. The sibling file is only read.refusedmarker. A file that cannot be read at all leaves no marker, so the next start tries again. Only the newest sibling is looked at, so a refused newest sibling does not fall back to an older one.loadFromFile), soagc_frame_replay --cold-pipelinesand a windowless device withoutAPS5_HEADLESS_PIPELINE_CACHEstay cold.APS5_NO_PIPELINE_CACHE_SEED=1skips it (ENVIRONMENT.md row added).USAGE.md's shader cache paragraph says what the first start of a new folder does.NativeCachePath_nid_no_patchon Windows, like the cache file itself, so a cache path past MAX_PATH is handled the same way.std::bad_allocpropagates, as the startup allocation test requires. Any other exception skips seeding with a log line.Recorder.cpp'sagc_pipeline_cache_fileandagc_pipeline_cache_headercounted every file of the version folder to find the cache file; the marker is a second file there, so both now count.binfiles.Risks:
APS5_NO_PIPELINE_CACHE_SEED=1is the way out, and the debt fragment records the gap.Tested
Windows 11 Pro (build 26300), NVIDIA GeForce RTX 3090 (driver 621.40), MinGW-w64 GCC 16.2.0, Ninja, Release,
-DBUILD_TESTING=ON, onmainea49f32e89. Every GPU test log showsSelected GPU name=NVIDIA GeForce RTX 3090.Tests. Ten new modes of
agc_pipeline_cache_allocation_tests(tests/PipelineCacheFailures.cpp, registered in its cmake fragment asagc_pipeline_cache_own_fileandagc_pipeline_cache_seed_*) run against the test's fake Vulkan device, each in its own temporary cache folder:seed_merge: a sibling folder's valid file is merged exactly once, the live cache holds its entries, the marker names the sibling, the folder's own file is written only by the saver and then holds the merged cache, and the sibling file is byte-identical afterwards.seed_newest: with two siblings, the one whose file was written last is merged.seed_once: a second start of a seeded folder does not merge again even when another sibling became newer, and the folder's own file loads as saved.seed_invalid,seed_foreign,seed_truncated: a sibling with a wrong magic, one written for another device (valid checksum, other device ID in its Vulkan header) and one cut to 100 bytes are not merged, leaverefused <folder>as the marker, and are not looked at again on the next start, though an older valid sibling exists.seed_optout:APS5_NO_PIPELINE_CACHE_SEEDstops the merge and writes no marker, and the folder still seeds once the variable is gone.seed_unloaded: a cache created withloadFromFile = falseneither merges nor writes a marker.seed_alloc: an allocation failure right after the merge propagates asstd::bad_alloc, leaves no Vulkan cache and no marker behind, and a retry seeds.own_file: a folder with no sibling gets thenonemarker, saves its own file, and loads it as saved on the next start.The existing five allocation modes (
startup,now,busy,destructor,worker) set the opt-out switch, so they test what they tested before;startupwould otherwise have spent its injected failure in the seeding code instead of the saver start.agc_pipeline_cache_file(real device) gains a block: two pipelines saved by one cache are moved to a sibling folder, a new cache of the real folder holds both pipelines without compiling them, and with the opt-out set it holds neither.agc_driver_recorder_tests(among themagc_pipeline_cache,agc_pipeline_cache_fileandagc_pipeline_cache_header),agc_tessellation_pipeline_cache, and the 16 of the allocation executable: the 5 existing modes,agc_pipeline_cache_read_retry(Windows only) and the 10 new ones..binfilter inRecorder.cpp,agc_pipeline_cache_fileandagc_pipeline_cache_headerfailed with "does not hold exactly one pipeline cache file" (the marker); with it they pass.mainbuild here, so there is no side-by-side log; the new tests do not exist onmain.python tools/check_conventions.pyandpython tools/debt_fold.py --check: clean. The change adds no code comments; the gaps are in the debt fragmentdocs/dev/debt/changes/feat-agc-pipeline-cache-seed.md.Measurements. In game on PPSA38500, same machine, with an earlier local build of this change. That build differs from this branch in three ways: it also seeded a cache created with
loadFromFile = false, it wrote the marker when the sibling could not be read, and it used plain paths on Windows. The title was not run from this branch's build, and it was run on a local tree that also carries other open PRs.This is a start-up cost, not a frame time, so it is titled
featrather thanperf: theaps5-summary.jsonllines of amainand a change capture of one scene would not show it, because both captures run after the pipelines are warm.Overlap: #18082 (re-land of pipeline cache persistence with pipeline binaries) also edits
PipelineCache.cpp,PipelineCache.hpp,PipelineCacheFailures.cppand the allocation cmake fragment: the constructor,readFileand the region fromreadHeadertoload. It conflicts withmainalready, so whichever merges second rebases. It stores pipeline binaries, not the driver cache, and does not seed from another folder. No open or closed PR or issue I found merges one folder's pipeline cache file into another's; #6771 (merged) made the file per version, #4915 (merged) merged the file instead of overwriting it, and #11106 is the NVIDIA report above.tools/pr_overlap.py --branch feat/pipeline-cache-seed --base mainstopped after fetching 1,099 of 2,102 pull request heads (it cannot fetch the head of #24048), so the overlap list above is from a manual search.Not run yet with
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: no Khronos validation layer is installed on this machine. That run (main and this PR, comparingVUID-lines) is still owed.PPSA38500: the title where the cost was measured. This PR fixes no stop; it removes the pipeline rebuild that every recompiler change added to its start-up.
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
APS5_NO_PIPELINE_CACHE_SEED=1to disable cache seeding and use only the new folder’s own cache.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T20:46:32Z.
Review: COMMENTED
Actionable comments posted: 1
df0cad69-6b70-4e8c-a4c7-60a63be73b05Reviewing files that changed from the base of the PR and between
fdf873a7d2and6ef9eb2876.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/Recorder.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_pipeline_cache_allocation_tests.cmakedocs/dev/ENVIRONMENT.mddocs/dev/debt/changes/feat-agc-pipeline-cache-seed.mddocs/user/USAGE.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T21:04:47Z.
Review: COMMENTED
Reviewed — comments
This review covers head
6ef9eb2876446091eedf69948862f5180f7358d1; one non-blocking edge case should be considered before relying on the seeding marker across filesystem errors.What I ran
No build or tests were run. I inspected the prepared diff and relevant source context through
repo_read.py.Results
Findings
Blocking
None.
Non-blocking
seedFromSibling()can recordnoneafter an incomplete directory scan. The loop exits whendirectory_iteratorreports an error, but the function does not check that error before treatingnewest.empty()as a completed scan and writing the marker. A transient listing error can therefore prevent later starts from discovering an available sibling. Consider returning without a marker when iteration or an entry query fails. (core/libs/prx/libSceAgcDriver/Graphics/src/PipelineCache.cpp:214,core/libs/prx/libSceAgcDriver/Graphics/src/PipelineCache.cpp:233)Sources
Not verified
Build and runtime behavior were not run.
Recorder.cppwas read only at its changed regions; no other repository files were inspected beyond the targeted context. All changed paths in the manifest were reviewed, thoughRecorder.cppwas inspected only at its changed hunks. No files were excluded by rule in the manifest.To get this to a good state
Nothing is required. Optional: avoid writing the
nonemarker when sibling enumeration fails, so a later start can retry.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-28T02:33:06Z.
Review: COMMENTED
Actionable comments posted: 2
d40af027-170f-4c35-87dd-94954ffb54b7Reviewing files that changed from the base of the PR and between
6ef9eb2876andf7594123aa.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/debt/changes/feat-agc-pipeline-cache-seed.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Pull request closed