fix(agc): repeat a periodic pipeline cache save that a pipeline creation skipped #28002
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28002"
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 muhmuhkuh on 2026-11-28T03:09:11Z.
What
The periodic pipeline cache save runs every 10 s on the saver thread and takes the cache's snapshot lock with
TryLockForSnapshot. Since #6958 it returns without saving while a pipeline creation holds the cache, so that a long creation never waits behind a save and the save never blocks creations. The next attempt then comes only at the next 10 s tick. Pipelines built after the last successful save are lost when the process ends before that tick without a teardown save, for example when the title is stopped by its own watchdog or a crash.Seen in PPSA38500: one run saved the driver cache (17,558.7 KiB) before a group of large compute pipelines was built; the next periodic save was skipped because one of those creations held the cache, and the process ended a few seconds later. The pipeline journal had recorded the new pipelines, so the next run replayed them at startup against a driver cache that did not contain them: the journal had 11 more compute pipelines than before, five of them took 0.6–7.0 s each (one 6,988 ms), and the replay took 8,317 ms instead of 907 ms. That run then saved 18,958.7 KiB right after the replay.
Change (driver only,
Graphics/src/PipelineCache.cppand.hpp):TryLockForSnapshotpoints), it setsskippedSaveunder the saver mutex and wakes the saver thread.skippedSaveis set, the saver thread retries every 100 ms (SkippedSaveRetryMilliseconds) instead of every 10 s. Each retry is still a non-blockingTryLockForSnapshot, so a running creation is never waited for and new creations are never blocked. The first save that gets the lock clears the flag, and the 10 s rhythm resumes.LockForPipelineUseon their own threads (Execution/src/VulkanDevice.cpp,Graphics/include/Context.hpp,Graphics/src/PipelineLibrary.cpp); nothing new runs there.[pipeline-cache] saved after a skipped save: <KiB> to <path> in <ms> ms.SaveNowand the teardown save still wait for creations (LockForSnapshot) and never set the flag.Tested
Windows 11, NVIDIA GeForce RTX 3080 Ti, driver 610.88; built and run on
main4814cae8551and on this branch on the same machine.tests/Recorder.cpp, next to the #6958 case): a cache saves pipeline 0; a thread takesLockForPipelineUse, builds pipeline 1 and holds the lock;SaveUnlessBusyis skipped and the file is unchanged; the thread releases the lock; within 3 s (shorter than the 10 s interval) the file grows, and a cache reloaded from it holds pipeline 1.mainplus the new test):agc_pipeline_cache_filefails with "a periodic pipeline cache save skipped for a pipeline creation was not repeated after the creation finished".agc_pipeline_cache_filepasses.ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest --test-dir build -R '^agc_pipeline_(cache|link_optimization|queue_failure|library$|library_off$|library_fast_only$|library_wide$|library_lto_info)' -V:main19/19 passed, this branch 19/19 passed; the validation layer was loaded, neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS;VUID-lines: 0 onmain, 0 on this branch.saved after a skipped save: 21148.3 KiBright as the build finished. An earlier run with the change skipped no save.tools/check_conventions.py --base origin/main:All conventions checks passed.tools/pr_overlap.py --branch fix/agc-pipeline-cache-save-after-skip: #27932 (open, seeds a new cache folder from an older one) conflicts with this branch inGraphics/src/PipelineCache.cpparound lines 297–298 ofmain; it is a different change, and whichever merges second rebases. The tool cannot compare 33 open pull requests that conflict withmainthemselves; checked by hand withgit diffagainst their merge bases: none adds a retry of a skipped save; #18082 changes other parts ofPipelineCache::save.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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-28T07:01:33Z.
Review: APPROVED
Checked head
c11d52b473. All on Windows 11 with WinLibs GCC 15.2 (Release), applied tomain4c7578e0a4together with #28006, #27985, #28001, #27991, #27987, #28007, #27994.tools/check_conventions.py --headandtools/debt_fold.py --checkpassed and the full build succeeded. In the full CPU suite (5,135 tests) the only failure iswindows_read_trap_unknown, which fails onmaintoo (fixed in #28028). The full GPU suite (2,249 tests) on both GPUs, withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layerand the 1.4.363 layer inserted, matchesmainon the same machine. The GPUs were an NVIDIA RTX 5080 (621.24) and an AMD Radeon gfx1036 iGPU (26.11.2). Onlyagc_driver_linear_target_import_creationfails, as onmain(fixed in #28029), and neither log has aVUID-orSYNC-HAZARDline.agc_driver_recorderand theagc_pipeline_cache_allocation*tests pass on both GPUs. I checked thatskipped()cannot deadlock againstrun():run()releasesmutexbefore it callssave(), so the lambda never takes a lock its caller holds.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T07:43:58Z.
Review: COMMENTED
Reviewed — no blocking findings
The change looks consistent with the stated retry behavior, but I could not run its tests, so a formal approval is not justified.
What I ran
Reviewed head
c11d52b4739c582cd573db0cce6c2db2427f47ausingrepo_read.py; no commands or tests were run in this environment.Results
Negative control
Not run here. The description reports that the new test fails on
mainwithout the fix.Findings
Blocking
None.
Non-blocking
None.
Sources
Reviewed
description.md,commits.md,manifest.json, anddiff.patch; inspectedPipelineCache.hppandPipelineCache.cpp, plus the changed test block inRecorder.cppat the pinned head.Not verified
The reported test runs and convention check were not independently verified.
Recorder.cppis too large to be included in the review bundle; only the changed test region was read. Other parts of that file and unmodified repository code were not reviewed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T17:55:33Z.
Review: APPROVED
Reviewed — looks good
The retry logic and regression case appear sound at the reviewed head; no checks were run in this review session.
What I ran
33cc1120f7ae018841eea5a5dae3209efa7a5323.repo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
tests/Recorder.cppis excluded from the prepared review files because it is too large; its changed test hunk and relevant surrounding test code were read throughrepo_read.py.description.md,commits.md,manifest.json,diff.patch,PipelineCache.hpp,PipelineCache.cpp(targeted ranges), andRecorder.cpp(targeted ranges).files.jsonwas unavailable in the review folder; the manifest identifies the excluded test file. No other changed repository files were excluded.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-11-29T18:02:08Z.
Review: APPROVED
Re-checked the rebased head
33cc1120f7onmain6f6f6c8e6b. Against the head I approved,c11d52b473, the change is the same apart from the save line, which keeps #28121's "(written through a mapped file)" field in the line that a non-retried save prints.Windows 11, WinLibs GCC 15.2, Release, RTX 5080, with
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_LAYER_KHRONOS_validation(inserted in every run, noVUID-):agc_pipeline_cache,agc_pipeline_cache_fileandagc_pipeline_cache_headerpass onmainand pass 3/3 at this head.main'sPipelineCache.cppandPipelineCache.hppand this head's test,agc_pipeline_cache_filefails with "a periodic pipeline cache save skipped for a pipeline creation was not repeated after the creation finished".AI-assisted: yes (Claude Code)