fix(agc): roll back failed snapshot cache insertions #7919
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7919"
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 Zenodeon on 2026-10-19T14:01:30Z.
What
A failed snapshot-cache insertion can leave an LRU key without a matching entry. A later eviction then dereferences a missing entry. Roll back the newly added recency key when snapshot-byte or map-node allocation throws, and propagate the original exception. Extract the internal cache metadata so the regression exercises the same insertion used by the runtime. Cache budgets, snapshot bytes, queued buffer ownership and guest APIs are unchanged.
Found while investigating memory pressure in Astro's Playroom (PPSA01325). This does not fix its separate 6.39 GiB heap-mirror allocation failure, establish a memory reduction or claim an FPS gain.
Related work, not dependencies: #7800 concerns image-cache reclamation, #6553 host-placement budget checks, and #7119 allocation-failure diagnostics. Also related: merged #3785 handles shader cache-file allocation failures, and open #6937 guards snapshot reuse around pending writes. Neither edits this insertion path. Existing contributions #6367, #6718, #6759, #6820 and #7307 remain separate; this fix needs none of them.
Tested
Windows 11 build 26200, Intel Core i7-13700, RTX 4070 / NVIDIA 610.88; WinLibs GCC 15.2.0, Release, SPIR-V Tools enabled.
Pre-fix main behavior with the cache metadata exposed for fault injection: the new regression fails with "failed snapshot insertion left inconsistent eviction metadata"; buffer-pool, descriptor-cache failure and graphics tests pass (3/4 overall, expected regression failure). Fixed source: the same four cases pass, longest 10.82 seconds on the rebased pre-publication rerun. The new case injects failure at all three insertion allocations, checks accounting/reference ownership, then retries, evicts and clears the cache.
Both focused runs used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. Neither log reports a missing requested layer; both contain zero VUID identifiers. Conventions and diff checks pass against upstream/main. Baseline behavior was checked at
4b462ef60; the final branch is rebased onto upstream85029a00f. The same four cases pass again on rebased commit12bc5b14a, with no missing requested validation layer or VUID identifiers. The fork-base conventions invocation was also run; its outdated 4,364-commit comparison reports inherited findings, while the actual upstream PR diff passes.The standalone snapshot insertion regression also compiles and passes under WSL/Ubuntu with g++ -std=c++20 -O2. This is a CPU-only cache-metadata test, not a Linux Vulkan/runtime validation.
Not a gameplay or performance comparison. New-game, five-minute stability and cross-title runs for this change have not been performed. No evidence bundle uploaded. Ran tools/pr_overlap.py --repo boykopovar/AnyPS5 --branch astro-small-resource-fixes. It reported shared files in 67 PRs whose base conflicts prevented automatic hunk comparison. Manually inspected those shared-file patches and compared the snapshot-cache blocks against each PR's merge base. No matching insertion rollback was found. #6292 and #6615 change this cache's mutex from std::mutex to AgcDriver::Mutex; this extraction will need to carry that mutex change into the internal header if either lands first. These are related edits, not dependencies.
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)