Repository navigation
fix(agc): serialize pipeline cache snapshots - #4795
oneandonlydean merged 1 commit into
Conversation
|
Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on current main
Not tested: no game run. The batch was built once, not per PR; it had no failures, so no bisect was needed. AI-assisted (Claude Code). |
cecaa48 to
dfff45d
Compare
|
Rebased onto current |
51c9e5b to
1eeb2c6
Compare
|
Tested on an Intel Arc 140T on Windows, where Setup
Results
I did not symbolize the crash frames; the timing and the AI-assisted: yes (Claude). |
|
Rebase handoff — rebased onto current Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
To pick it up: Head is |
|
I checked the current head |
1eeb2c6 to
87d831f
Compare
|
Thanks for preparing and validating the rebase handoff. I picked up the original topic and rebased it directly onto the newer upstream |
87d831f to
4307e3c
Compare
|
Rebased onto main to resolve the conflict in |
|
Fresh Linux validation for the current PR tree: published head |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
… bounded wait A save that does not wait for pipelines takes the cache's snapshot lock with a try-lock and, after a skip, tries again every 100 ms until one attempt gets it. No attempt gets it while pipeline creations overlap, and in a cold start they can overlap throughout: PPSA38500 built 394 compute pipelines of over 100,000 SPIR-V words in about 27 minutes while the try-lock saves of a local branch, tried again every second after a skip, never got the lock, so a process that ended in that time without a teardown save would have lost them all. Vulkan does not need the lock. The cache is created without VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT, so vkGetPipelineCacheData and vkCreate*Pipelines on it synchronize inside the driver, and vkMergePipelineCaches needs external synchronization only for its destination, which here is a cache the save alone holds. The lock was added (boykopovar#4795) because Intel's Windows driver faulted in vkGetPipelineCacheData while pipelines were being created (boykopovar#4781). A pipeline added between the size query and the copy makes vkGetPipelineCacheData return VK_INCOMPLETE with a shorter cache that is still valid initial data, and the save already writes that. - Once saves have been skipped for APS5_PIPELINE_CACHE_SAVE_BUSY_SECONDS, counted from the first skip after the last save that wrote the file, found nothing new or kept a file that held more, a save that still cannot take the lock goes ahead without it. The default is 60, and 0 on Intel GPUs (vendor 0x8086), whose Windows driver faulted there; 0 keeps the old behaviour. SaveNow and the teardown save still wait for the lock. The setting is read like the other pipeline cache settings: a value that is not a whole number is reported once and the default is used. The bound is compared in whole seconds, so a value too large for the clock's nanoseconds cannot wrap into a bound already past. - The first save in a process made without the lock prints a line before it calls the driver, and every such save that is written prints its saved line, with the skips before it and whether the driver returned only part of the cache. The line after a skipped save also says when the save merged the file or went through a mapped file. A partial copy too small to write says so instead of naming a merged cache. - The debt entry on skipped periodic saves is cut to what stays open. Test: agc_pipeline_cache_busy_bounded checks the default (60, 0 on Intel) and keeps pipeline use locked on another thread. A cache whose file another writer changed skips inside the bound, merges the file past it without the lock, and the next save skips again. A cache loaded from its file saves past the bound straight from the live cache, which a pipeline creation grows between the size query and the copy; the part the driver returned is saved and loads. A save that finds nothing new starts the bound again. With the bound at 0, or at the largest value, no save goes ahead until pipeline use is released. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
Serialize the periodic persistent pipeline-cache snapshot against pipeline creation that uses that cache. Pipeline creation paths take shared locks, so they can continue concurrently with each other.
PipelineCache::save()takes the exclusive lock only around its twovkGetPipelineCacheDatacalls, then releases it before hashing or writing the cache file.The guard covers graphics, compute, pipeline-library and asynchronous LTO creation paths using the persistent cache. Capture replay uses a separate temporary cache and remains unchanged. A regression checks that snapshot access cannot acquire while a pipeline-use lock is held and succeeds after that lock is released.
This is an application-side workaround for the Intel driver crash reported in issue #4781. The Vulkan specification describes pipeline-cache use by pipeline creation as internally synchronized across threads; this PR does not claim that the crash is a Vulkan valid-usage violation. See the Vulkan pipeline cache specification and
vkGetPipelineCacheDatareference.Tested
libSceAgcDriverandagc_driver_graphics_testspassed on based379bfd014193cb3dc7b1e559c374b40a6dcdf48;agc_driver_graphicspassed 1/1.main30f961266ade83b41d5c9de7dec1393e7fcecfb7. On the rebased head, configured Linux Release withBUILD_TESTING=ONand SPIR-V tools disabled; Ninja builtagc_driver_graphics_testssuccessfully (706/706 steps).ctest --test-dir /tmp/AnyPS5-4795-rebased-build -R '^agc_driver_graphics$' --output-on-failure: passed (1/1, 7.99 s).python3 tools/check_conventions.py --base upstream/main --head HEADandgit diff --check upstream/main...HEADpassed on the rebased head.Checklist
main; no open PR implements persistent pipeline-cache snapshot serializationNotImplemented_nid_no_patch