fix(shader): map retained SPIR-V from shader cache entries #4806

Merged
eljackjoestar-cmd merged 3 commits from upstream-pr/4806 into main 2026-10-14 09:18:29 +00:00
eljackjoestar-cmd commented 2026-10-12 22:26:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eljackjoestar-cmd on 2026-10-12T22:26:44Z.


What

Replace this PR's opt-in temporary-file backing with read-only mappings of the shader disk-cache entries themselves. APS5_FILE_BACKED_SPIRV and the extra temporary files are removed from the implementation.

This adopts ThatsLeo's perf/shader-spirv-on-disk implementation (0bc9120bb), preserving its authorship, and adds the Windows mapping path. Cache-loaded variants retain a shared mapping owner; newly compiled variants are persisted to the normal cache and mapped back before retention. Reading or copying a module shares that storage; mutation detaches into a private vector. Words() returns a const span, and explicit vector consumers use Copy().

Windows mappings share read, write and delete access, so atomic replacement/removal of a cache file does not invalidate its existing readers. Failed cache persistence/mapping and disabled caches retain the existing vector path. No dedicated backing-enable switch, temporary-volume dependency, memory-budget knob or cache-version bypass is introduced. This does not add cache eviction; normal cache files still use disk space.

The cache payload is aligned and its format advances from 30 to 31. Length, key and payload validation remain in force.

Tested

Windows 11 Pro 10.0.26300, GCC 15.2, Release, SPIRV-Tools OFF, current main f87799aa3 plus this PR alone.

The cache regression verifies actual Windows MEM_MAPPED storage, round-trip words/metadata, copy-on-write isolation, and retained word access after the original cache pathname is atomically replaced and removed. Existing cross-process, corruption, cache-invalidation, binding, vertex specialization and invocation-isolation cases also pass.

Full Windows build passed on the final rebased branch. Four focused cache/shader/rendering checks passed on NVIDIA RTX 5070 / driver 617.14 in 6.81 s; graphics and prepared-shader checks passed on AMD Radeon integrated gfx1036 / driver 32.0.21036.18 in 5.26 s. The cache regression also exercises loading while a published writer retains write/rename access. Conventions and whitespace checks pass. Linux/macOS execution and full-suite CI are not claimed for this revised head.

The previous opt-in implementation's memory measurements are superseded and are not evidence for this implementation. The independent Demon's Souls report in https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6160926186 applies to ThatsLeo's original POSIX branch: it reached the tutorial where its comparison run exhausted the memory cap. That report used a warm cache and test-only format/source-version overrides, which are not included here. It is external Linux title evidence, not a Windows title validation of this revised head. No new Windows title-memory or speed improvement is claimed yet.

Checklist

  • Based on current main; no equivalent open cache-mapping PR found
  • One topic per PR; replaces the earlier implementation
  • No new code comments
  • Unimplemented paths throw; no silent stubs
  • No investigation artifacts committed
  • No third-party code added
  • Generic shader-cache storage behaviour
  • Depends on: none
  • Unblocks: none (addresses reported memory/storage failures; revised Windows title outcome pending)
  • GPUs tested: NVIDIA RTX 5070 / 617.14 and AMD Radeon integrated gfx1036 / 32.0.21036.18 on Windows 11 Pro 10.0.26300
  • AI-assisted: yes, OpenAI Codex

Related: #5552 changes the fallback file reader. Its head f2b86928 merges cleanly with this branch in a pairwise merge simulation; that simulation is not a combined build/test claim.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4835711563 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806). Originally posted by [eljackjoestar-cmd](https://github.com/eljackjoestar-cmd) on 2026-10-12T22:26:44Z. --- ### What Replace this PR's opt-in temporary-file backing with read-only mappings of the shader disk-cache entries themselves. `APS5_FILE_BACKED_SPIRV` and the extra temporary files are removed from the implementation. This adopts ThatsLeo's `perf/shader-spirv-on-disk` implementation (`0bc9120bb`), preserving its authorship, and adds the Windows mapping path. Cache-loaded variants retain a shared mapping owner; newly compiled variants are persisted to the normal cache and mapped back before retention. Reading or copying a module shares that storage; mutation detaches into a private vector. `Words()` returns a const span, and explicit vector consumers use `Copy()`. Windows mappings share read, write and delete access, so atomic replacement/removal of a cache file does not invalidate its existing readers. Failed cache persistence/mapping and disabled caches retain the existing vector path. No dedicated backing-enable switch, temporary-volume dependency, memory-budget knob or cache-version bypass is introduced. This does not add cache eviction; normal cache files still use disk space. The cache payload is aligned and its format advances from 30 to 31. Length, key and payload validation remain in force. ### Tested Windows 11 Pro 10.0.26300, GCC 15.2, Release, SPIRV-Tools OFF, current main `f87799aa3` plus this PR alone. The cache regression verifies actual Windows `MEM_MAPPED` storage, round-trip words/metadata, copy-on-write isolation, and retained word access after the original cache pathname is atomically replaced and removed. Existing cross-process, corruption, cache-invalidation, binding, vertex specialization and invocation-isolation cases also pass. Full Windows build passed on the final rebased branch. Four focused cache/shader/rendering checks passed on NVIDIA RTX 5070 / driver 617.14 in 6.81 s; graphics and prepared-shader checks passed on AMD Radeon integrated gfx1036 / driver 32.0.21036.18 in 5.26 s. The cache regression also exercises loading while a published writer retains write/rename access. Conventions and whitespace checks pass. Linux/macOS execution and full-suite CI are not claimed for this revised head. The previous opt-in implementation's memory measurements are superseded and are not evidence for this implementation. The independent Demon's Souls report in https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6160926186 applies to ThatsLeo's original POSIX branch: it reached the tutorial where its comparison run exhausted the memory cap. That report used a warm cache and test-only format/source-version overrides, which are not included here. It is external Linux title evidence, not a Windows title validation of this revised head. No new Windows title-memory or speed improvement is claimed yet. ### Checklist - [x] Based on current `main`; no equivalent open cache-mapping PR found - [x] One topic per PR; replaces the earlier implementation - [x] No new code comments - [x] Unimplemented paths throw; no silent stubs - [x] No investigation artifacts committed - [x] No third-party code added - [x] Generic shader-cache storage behaviour - [x] Depends on: none - [x] Unblocks: none (addresses reported memory/storage failures; revised Windows title outcome pending) - [x] GPUs tested: NVIDIA RTX 5070 / 617.14 and AMD Radeon integrated gfx1036 / 32.0.21036.18 on Windows 11 Pro 10.0.26300 - [x] AI-assisted: yes, OpenAI Codex Related: #5552 changes the fallback file reader. Its head f2b86928 merges cleanly with this branch in a pairwise merge simulation; that simulation is not a combined build/test claim.
kr4y4 commented 2026-10-13 06:48:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-13T06:48:01Z.


In a plain build the two new tests don't run. cmake --build build followed by --target libs leaves agc_shared_spirv_tests unbuilt, so ctest reports agc_shared_spirv_heap and agc_shared_spirv_file as Not Run.

Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 501f19776 merged into main 495bf91a0. It now conflicts with main ea2bbefb2 in docs/dev/debt/shader.md.

  • add_test_executable(agc_shared_spirv_tests EXCLUDE_FROM_ALL ...) has no set_target_properties(agc_shared_spirv_tests PROPERTIES EXCLUDE_FROM_ALL OFF). The other registered tests in this file set that inside if(BUILD_TESTING), and the two add_test lines here are outside that block.
  • After the CI build steps the executable doesn't exist. The full suite (ctest --timeout 120 --parallel 4) then passes 1023 of 1025 on both GPUs, and the two failures are these Not Run entries. tools/check_test_registration.py still passes, because it only checks executables that were built.
  • With the target built by hand (--target agc_shared_spirv_tests), both tests pass on both GPUs with --repeat until-fail:3. With APS5_FILE_BACKED_SPIRV=1 it prints sharing, write isolation, lifetime and reads passed, with a private-bytes delta of 163840.

Also, the new block sits between add_test_executable(agc_shader_disk_cache_tests ...) and that target's own target_include_directories and target_link_libraries lines.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6139967585 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6139967585). Originally posted by [kr4y4](https://github.com/kr4y4) on 2026-10-13T06:48:01Z. --- In a plain build the two new tests don't run. `cmake --build build` followed by `--target libs` leaves `agc_shared_spirv_tests` unbuilt, so `ctest` reports `agc_shared_spirv_heap` and `agc_shared_spirv_file` as Not Run. Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 501f19776 merged into `main` 495bf91a0. It now conflicts with `main` ea2bbefb2 in `docs/dev/debt/shader.md`. - `add_test_executable(agc_shared_spirv_tests EXCLUDE_FROM_ALL ...)` has no `set_target_properties(agc_shared_spirv_tests PROPERTIES EXCLUDE_FROM_ALL OFF)`. The other registered tests in this file set that inside `if(BUILD_TESTING)`, and the two `add_test` lines here are outside that block. - After the CI build steps the executable doesn't exist. The full suite (`ctest --timeout 120 --parallel 4`) then passes 1023 of 1025 on both GPUs, and the two failures are these Not Run entries. `tools/check_test_registration.py` still passes, because it only checks executables that were built. - With the target built by hand (`--target agc_shared_spirv_tests`), both tests pass on both GPUs with `--repeat until-fail:3`. With `APS5_FILE_BACKED_SPIRV=1` it prints `sharing, write isolation, lifetime and reads passed`, with a private-bytes delta of 163840. Also, the new block sits between `add_test_executable(agc_shader_disk_cache_tests ...)` and that target's own `target_include_directories` and `target_link_libraries` lines. Written with AI assistance.
eljackjoestar-cmd commented 2026-10-13 08:17:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eljackjoestar-cmd on 2026-10-13T08:17:01Z.


Rebased onto main fc1f063f5, preserving the newer shader-debt entries. Also corrected the reported registration defect: the shared-SPIR-V test target is included in the normal build when BUILD_TESTING=ON, its two add_test calls are guarded by that option, and its block is separate from the disk-cache target setup.

The default full Windows Release build now builds the executable without naming its target. Heap/file storage, shader memory and shader disk cache all pass without skips (four tests, 0.78 s). The 64 MiB private-byte deltas are 67,244,032 bytes for heap storage and 159,744 bytes for file backing. Separate cache-disabled heap/file replay processes emit identical 134,780-word SPIR-V for the captured title shader. Conventions and whitespace checks pass. No new game-runtime claim is made for this rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141327481 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6141327481). Originally posted by [eljackjoestar-cmd](https://github.com/eljackjoestar-cmd) on 2026-10-13T08:17:01Z. --- Rebased onto main `fc1f063f5`, preserving the newer shader-debt entries. Also corrected the reported registration defect: the shared-SPIR-V test target is included in the normal build when `BUILD_TESTING=ON`, its two `add_test` calls are guarded by that option, and its block is separate from the disk-cache target setup. The default full Windows Release build now builds the executable without naming its target. Heap/file storage, shader memory and shader disk cache all pass without skips (four tests, 0.78 s). The 64 MiB private-byte deltas are 67,244,032 bytes for heap storage and 159,744 bytes for file backing. Separate cache-disabled heap/file replay processes emit identical 134,780-word SPIR-V for the captured title shader. Conventions and whitespace checks pass. No new game-runtime claim is made for this rebase.
adriadam10 commented 2026-10-13 15:47:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T15:47:10Z.


Rebased onto current main; the only conflict was the adjacent line in docs/dev/debt/shader.md (kept both, SharedSpirv entry before the BDA span reads one). Checked the shared-SPIR-V heap/file tests on Linux (pass, and they don't build without the change), the rest of the libSceAgc/libSceAgcDriver/libc/libkernel ctest scope (only agc_driver_tessellation segfaults inside RADV, unrelated to this code, default storage unchanged). Merging once the Windows build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6149441361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6149441361). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T15:47:10Z. --- Rebased onto current `main`; the only conflict was the adjacent line in `docs/dev/debt/shader.md` (kept both, SharedSpirv entry before the BDA span reads one). Checked the shared-SPIR-V heap/file tests on Linux (pass, and they don't build without the change), the rest of the libSceAgc/libSceAgcDriver/libc/libkernel ctest scope (only `agc_driver_tessellation` segfaults inside RADV, unrelated to this code, default storage unchanged). Merging once the Windows build is green.
ThatsLeo commented 2026-10-13 16:16:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-13T16:16:23Z.


Data from Linux, and a follow-up for after this merges.

Stray (PPSA02101) registers about 3,400 shaders, with a median of 520 KB of SPIR-V each and 3.1 GB on disk. heaptrack puts 3.3 GB of the driver's heap in ShaderDiskCache::decodeArtifact, kept for the whole run. On an Intel Meteor Lake laptop with 14 GB shared between CPU and GPU, Stray goes out of memory on main 5a76fd71 with a cold cache, 50 s in.

I tried the same idea a different way, on ThatsLeo/AnyPS5:perf/shader-spirv-on-disk (f320698e):

  • The cache entry file the words already come from is mapped, instead of a temporary file. Format 29 aligns the payload to 8 bytes, so the SPIR-V in the file is word-aligned and SharedSpirv holds a view into the mapping, with the mapping as its owner.
  • A freshly compiled variant is written synchronously and mapped back (ShaderDiskCache::Persist). A cold first run, the one after every update, is covered too.
  • No extra disk space and no switch, so it's on by default. Cache entries are replaced by atomic rename, so a mapped file stays valid even if it is rewritten or removed; agc_shader_disk_cache checks that.
  • POSIX only. On Windows, Persist returns null and loads read the file as before, since I can't test whether a mapped entry can be replaced there.

Stray, main 5a76fd71 against that branch, 150 s on the brightness calibration screen: anonymous memory 5.3 GB plus 4.4 GB swapped with 0.2 GB available, against 2.6 GB plus 4.2 GB with 3.3 GB available. The cold main run went out of memory; the branch didn't. One caveat: main's cache was still partly cold in that run, so the frame rates (0.1 to 0.7 fps against 1.1 to 1.6) aren't comparable.

Full ctest on Intel Arc and lavapipe: 1053 of 1054 pass. guest_ampr_cpp_error doesn't link with Fedora's toolchain, on main as well.

It touches the same SharedSpirv as this PR, so I won't open it alongside. Once this merges, I can rebase it on top: the cache's own entries become one more backing for your storage, and the temporary-file path stays for when the disk cache is disabled. If you'd rather fold the cache-file mapping in here, the branch is yours to take.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150003117 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6150003117). Originally posted by [ThatsLeo](https://github.com/ThatsLeo) on 2026-10-13T16:16:23Z. --- Data from Linux, and a follow-up for after this merges. Stray (PPSA02101) registers about 3,400 shaders, with a median of 520 KB of SPIR-V each and 3.1 GB on disk. `heaptrack` puts 3.3 GB of the driver's heap in `ShaderDiskCache::decodeArtifact`, kept for the whole run. On an Intel Meteor Lake laptop with 14 GB shared between CPU and GPU, Stray goes out of memory on `main` `5a76fd71` with a cold cache, 50 s in. I tried the same idea a different way, on [`ThatsLeo/AnyPS5:perf/shader-spirv-on-disk`](https://github.com/ThatsLeo/AnyPS5/compare/main...ThatsLeo:AnyPS5:perf/shader-spirv-on-disk) (`f320698e`): - The cache entry file the words already come from is mapped, instead of a temporary file. Format 29 aligns the payload to 8 bytes, so the SPIR-V in the file is word-aligned and `SharedSpirv` holds a view into the mapping, with the mapping as its owner. - A freshly compiled variant is written synchronously and mapped back (`ShaderDiskCache::Persist`). A cold first run, the one after every update, is covered too. - No extra disk space and no switch, so it's on by default. Cache entries are replaced by atomic rename, so a mapped file stays valid even if it is rewritten or removed; `agc_shader_disk_cache` checks that. - POSIX only. On Windows, `Persist` returns null and loads read the file as before, since I can't test whether a mapped entry can be replaced there. Stray, `main` `5a76fd71` against that branch, 150 s on the brightness calibration screen: anonymous memory 5.3 GB plus 4.4 GB swapped with 0.2 GB available, against 2.6 GB plus 4.2 GB with 3.3 GB available. The cold `main` run went out of memory; the branch didn't. One caveat: `main`'s cache was still partly cold in that run, so the frame rates (0.1 to 0.7 fps against 1.1 to 1.6) aren't comparable. Full `ctest` on Intel Arc and lavapipe: 1053 of 1054 pass. `guest_ampr_cpp_error` doesn't link with Fedora's toolchain, on `main` as well. It touches the same `SharedSpirv` as this PR, so I won't open it alongside. Once this merges, I can rebase it on top: the cache's own entries become one more backing for your storage, and the temporary-file path stays for when the disk cache is disabled. If you'd rather fold the cache-file mapping in here, the branch is yours to take. AI-assisted: yes.
blawesom commented 2026-10-13 18:07:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-13T18:07:09Z.


Rebase handoff — rebased onto current main (staleness only, applied cleanly), authorship unchanged.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 1072/1073 — the only failure is the known main regression (agc_driver_tessellation segfault, #4727)

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/4806
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is ee727ce4a.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6152003149 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6152003149). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-13T18:07:09Z. --- **Rebase handoff** — rebased onto current `main` (staleness only, applied cleanly), authorship unchanged. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **full suite: 1072/1073** — the only failure is the known `main` regression (`agc_driver_tessellation` segfault, #4727) **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/4806 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `ee727ce4a`.
fdfawef324 commented 2026-10-13 19:34:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-13T19:34:05Z.


I encountered the documented backing-write failure policy while testing Demon's Souls with APS5_FILE_BACKED_SPIRV=1: retained modules filled the temporary volume after about three minutes. I prepared a bounded-storage and heap-fallback correction at fdfawef324:codex/shared-spirv-bounded-offer, directly on this PR's current head cebe922c17. It contains only the correction above your original implementation, preserving authorship.

The default live backing limit is 1 GiB per recompiler library, configurable with APS5_FILE_BACKED_SPIRV_MAX_BYTES. Concurrent reservations follow the shared mapping's lifetime, so copies and moves consume no extra capacity, and detaching or releasing the last owner returns it. Budget exhaustion or a backing I/O/allocation failure clears partial resources and moves the original vector to heap storage. Failed-open names and failed POSIX unlink names are retained for cleanup retry; successful Windows delete-on-close handles immediately discard their pathname, avoiding a later pathname-deletion race. Unrecoverable temporary-file cleanup disables further backing in that library.

This trades additional private memory for bounded temporary disk use and continuity on storage failure. Retained module count remains unbounded, and this does not replace cache eviction. Shader words and cache semantics are unchanged. The correction has not been tested in another game run.

CPU-tested platform: Windows Server 2025 10.0.26100 x64, WinLibs GCC 15.2, Release. Both added regressions fail on the prior implementation: it ignores a 64 KiB limit, and a real invalid temporary-directory resource path throws. All four heap/file/budget/I/O tests pass with the correction, without skips, in 1.92 s. Coverage includes shared and moved owners, last-owner release, detached writes, concurrent reservations, preserved vector storage, copy-on-write after fallback and preservation of the existing blocked path. Conventions and diff checks pass; Linux/macOS execution remains unverified.

GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100 (original failure run; the correction received CPU storage tests with no GPU execution).

AI-assisted: yes.

Co-Authored-By: Codex [email protected]

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6153578641 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6153578641). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-13T19:34:05Z. --- I encountered the documented backing-write failure policy while testing Demon's Souls with `APS5_FILE_BACKED_SPIRV=1`: retained modules filled the temporary volume after about three minutes. I prepared a bounded-storage and heap-fallback correction at `fdfawef324:codex/shared-spirv-bounded-offer`, directly on this PR's current head `cebe922c17`. It contains only the correction above your original implementation, preserving authorship. The default live backing limit is 1 GiB per recompiler library, configurable with `APS5_FILE_BACKED_SPIRV_MAX_BYTES`. Concurrent reservations follow the shared mapping's lifetime, so copies and moves consume no extra capacity, and detaching or releasing the last owner returns it. Budget exhaustion or a backing I/O/allocation failure clears partial resources and moves the original vector to heap storage. Failed-open names and failed POSIX unlink names are retained for cleanup retry; successful Windows delete-on-close handles immediately discard their pathname, avoiding a later pathname-deletion race. Unrecoverable temporary-file cleanup disables further backing in that library. This trades additional private memory for bounded temporary disk use and continuity on storage failure. Retained module count remains unbounded, and this does not replace cache eviction. Shader words and cache semantics are unchanged. The correction has not been tested in another game run. CPU-tested platform: Windows Server 2025 10.0.26100 x64, WinLibs GCC 15.2, Release. Both added regressions fail on the prior implementation: it ignores a 64 KiB limit, and a real invalid temporary-directory resource path throws. All four heap/file/budget/I/O tests pass with the correction, without skips, in 1.92 s. Coverage includes shared and moved owners, last-owner release, detached writes, concurrent reservations, preserved vector storage, copy-on-write after fallback and preservation of the existing blocked path. Conventions and diff checks pass; Linux/macOS execution remains unverified. GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100 (original failure run; the correction received CPU storage tests with no GPU execution). AI-assisted: yes. Co-Authored-By: Codex <[email protected]>
oneandonlydean commented 2026-10-14 03:06:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T03:06:00Z.


APS5_FILE_BACKED_SPIRV is an opt-in environment switch; a change like this goes in as the one path, not behind a knob. With it on, the temporary volume filled after about three minutes in the run reported above. Mapping the disk-cache entry itself, as in ThatsLeo's branch, needs neither the switch nor extra disk space; could you take that route instead?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159963709 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6159963709). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T03:06:00Z. --- `APS5_FILE_BACKED_SPIRV` is an opt-in environment switch; a change like this goes in as the one path, not behind a knob. With it on, the temporary volume filled after about three minutes in the run reported above. Mapping the disk-cache entry itself, as in ThatsLeo's branch, needs neither the switch nor extra disk space; could you take that route instead?
fisherjoey commented 2026-10-14 04:30:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-14T04:30:46Z.


A Demon's Souls (PPSA01341 v1.07) data point for the route @oneandonlydean suggested. @ThatsLeo, your perf/shader-spirv-on-disk (0bc9120bb) gets the title into its tutorial level on Linux. Without it, the title runs out of memory while the level loads.

Setup: Linux, RTX 5070 Ti, NVIDIA 595.91, 30 GiB RAM, ANYPS5_ENABLE_SPIRV_TOOLS=OFF. Base main 7a0c838ca with local merges of #758, #5181 (ceda63b9c, b130903c8) and a local stencil-export workaround for #4276. The run is capped at 22 GiB RAM plus 12 GiB swap. Warm shader cache, which needed two test-only tweaks to stay valid across the builds (I kept the cache format at 30 and overrode the source version). Neither is part of your change.

without the branch with 0bc9120bb
outcome OOM-killed at the cap at about t+337, still loading the level no OOM in 1200 s, reaches the level (HUD, first tunnel)
memory 12.2 GiB anon + 12 GiB swap at the kill peak ~14 GiB anon + swap (anon 3.5-6.3 GiB, swap levels off near 8.7 GiB), plus 3-6 GiB of reclaimable file-backed pages
shader variants 5.0k at the title, 8.3k at the kill 9614 disk-cache hits, 250 misses

A heap profile of the run without it puts the growth in SPIR-V decoded from the disk cache and kept in SourceEntry::variants: 3.1 GiB live at t+40 and 10.0 GiB at t+340, about 1.2 MiB per cache hit.

This PR's file-backed storage doesn't help on this machine, because /tmp is tmpfs and the spilled modules stay in RAM.

If you open the branch as a PR, I can rerun it there.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6160926186 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6160926186). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-14T04:30:46Z. --- A Demon's Souls (PPSA01341 v1.07) data point for the route @oneandonlydean suggested. @ThatsLeo, your `perf/shader-spirv-on-disk` (0bc9120bb) gets the title into its tutorial level on Linux. Without it, the title runs out of memory while the level loads. Setup: Linux, RTX 5070 Ti, NVIDIA 595.91, 30 GiB RAM, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`. Base `main` 7a0c838ca with local merges of #758, #5181 (ceda63b9c, b130903c8) and a local stencil-export workaround for #4276. The run is capped at 22 GiB RAM plus 12 GiB swap. Warm shader cache, which needed two test-only tweaks to stay valid across the builds (I kept the cache format at 30 and overrode the source version). Neither is part of your change. | | without the branch | with 0bc9120bb | |---|---|---| | outcome | OOM-killed at the cap at about t+337, still loading the level | no OOM in 1200 s, reaches the level (HUD, first tunnel) | | memory | 12.2 GiB anon + 12 GiB swap at the kill | peak ~14 GiB anon + swap (anon 3.5-6.3 GiB, swap levels off near 8.7 GiB), plus 3-6 GiB of reclaimable file-backed pages | | shader variants | 5.0k at the title, 8.3k at the kill | 9614 disk-cache hits, 250 misses | A heap profile of the run without it puts the growth in SPIR-V decoded from the disk cache and kept in `SourceEntry::variants`: 3.1 GiB live at t+40 and 10.0 GiB at t+340, about 1.2 MiB per cache hit. This PR's file-backed storage doesn't help on this machine, because `/tmp` is tmpfs and the spilled modules stay in RAM. If you open the branch as a PR, I can rerun it there. AI-assisted: yes
eljackjoestar-cmd commented 2026-10-14 07:51:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by eljackjoestar-cmd on 2026-10-14T07:51:45Z.


Replaced the opt-in temporary-file implementation with the suggested cache-entry mapping route. The branch now carries ThatsLeo's original change with its authorship preserved, plus Windows mapping support at 4a0489a7a. There is no APS5_FILE_BACKED_SPIRV switch or separate temporary backing file. Cache-loaded and freshly persisted variants retain their cache mapping; mutation detaches a private copy.

Rebased onto f87799aa3. Full Windows Release build passed. Four cache/shader/rendering checks passed on RTX 5070 (617.14), and the two rendering/prepared-shader checks passed on AMD integrated gfx1036 (32.0.21036.18). The regression verifies mapped storage, copy isolation, a retained writer's write/rename access, and reader survival after replacement/removal of the pathname. Conventions pass. The body records the Demon's Souls result above as external evidence for the original POSIX branch; its test-only format/source-version overrides are not included, and no revised Windows title-memory result is claimed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6163601231 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6163601231). Originally posted by [eljackjoestar-cmd](https://github.com/eljackjoestar-cmd) on 2026-10-14T07:51:45Z. --- Replaced the opt-in temporary-file implementation with the suggested cache-entry mapping route. The branch now carries ThatsLeo's original change with its authorship preserved, plus Windows mapping support at `4a0489a7a`. There is no `APS5_FILE_BACKED_SPIRV` switch or separate temporary backing file. Cache-loaded and freshly persisted variants retain their cache mapping; mutation detaches a private copy. Rebased onto `f87799aa3`. Full Windows Release build passed. Four cache/shader/rendering checks passed on RTX 5070 (617.14), and the two rendering/prepared-shader checks passed on AMD integrated gfx1036 (32.0.21036.18). The regression verifies mapped storage, copy isolation, a retained writer's write/rename access, and reader survival after replacement/removal of the pathname. Conventions pass. The body records the Demon's Souls result above as external evidence for the original POSIX branch; its test-only format/source-version overrides are not included, and no revised Windows title-memory result is claimed.
github-actions[bot] commented 2026-10-14 07:54:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T07:54:51Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#757 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L726-792, L812-862
core/shader/recompiler/ShaderDiskCache.cpp L80-83
#758 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp L726-792, L817-862
core/shader/recompiler/ShaderDiskCache.cpp L80-83
core/shader/recompiler/ShaderDiskCache.hpp L16
#4732 core/shader/recompiler/ShaderDiskCache.cpp L16-17
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6163649142 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6163649142). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T07:54:51Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #757 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` [L726-792](https://github.com/boykopovar/AnyPS5/blob/66f894761b90f8179166d0f526411f8b2af508d7/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L726-L792), [L812-862](https://github.com/boykopovar/AnyPS5/blob/66f894761b90f8179166d0f526411f8b2af508d7/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L812-L862)<br>`core/shader/recompiler/ShaderDiskCache.cpp` [L80-83](https://github.com/boykopovar/AnyPS5/blob/66f894761b90f8179166d0f526411f8b2af508d7/core/shader/recompiler/ShaderDiskCache.cpp#L80-L83) | | | | #758 | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` [L726-792](https://github.com/boykopovar/AnyPS5/blob/66f894761b90f8179166d0f526411f8b2af508d7/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L726-L792), [L817-862](https://github.com/boykopovar/AnyPS5/blob/66f894761b90f8179166d0f526411f8b2af508d7/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp#L817-L862)<br>`core/shader/recompiler/ShaderDiskCache.cpp` [L80-83](https://github.com/boykopovar/AnyPS5/blob/66f894761b90f8179166d0f526411f8b2af508d7/core/shader/recompiler/ShaderDiskCache.cpp#L80-L83)<br>`core/shader/recompiler/ShaderDiskCache.hpp` [L16](https://github.com/boykopovar/AnyPS5/blob/66f894761b90f8179166d0f526411f8b2af508d7/core/shader/recompiler/ShaderDiskCache.hpp#L16) | | | | #4732 | `core/shader/recompiler/ShaderDiskCache.cpp` [L16-17](https://github.com/boykopovar/AnyPS5/blob/66f894761b90f8179166d0f526411f8b2af508d7/core/shader/recompiler/ShaderDiskCache.cpp#L16-L17) | | |
oneandonlydean commented 2026-10-14 08:56:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T08:56:50Z.


The Linux build with SPIRV-Tools failed in SpirvNarrowConstantStore.cpp: SpirvTools::Validate has no overload for a span, so I pushed a one-line fix that passes the word pointer and count. It builds with ANYPS5_ENABLE_SPIRV_TOOLS=ON and the shader tests pass; running the full build again.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6164682579 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6164682579). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T08:56:50Z. --- The Linux build with SPIRV-Tools failed in `SpirvNarrowConstantStore.cpp`: `SpirvTools::Validate` has no overload for a span, so I pushed a one-line fix that passes the word pointer and count. It builds with `ANYPS5_ENABLE_SPIRV_TOOLS=ON` and the shader tests pass; running the full build again.
fisherjoey commented 2026-10-14 09:46:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-14T09:46:53Z.


Demon's Souls (PPSA01341 v1.07) on Linux with this head (4a0489a7a), as offered above. With it, the title loads the tutorial level and stays in it, where it was OOM-killed without it.

Setup: Linux, RTX 5070 Ti, NVIDIA 595.91, ANYPS5_ENABLE_SPIRV_TOOLS=OFF. Base main 6546a3394 with local merges of #758, #5181 (three commits) and #5747, plus a local stencil-export workaround for #4276. The run is capped at 22 GiB RAM and 12 GiB swap. Warm shader cache: 9067 hits, 757 misses.

without the cache mapping (warm) with this PR (warm)
outcome OOM-killed at the cap at about t+337, during the level load ran the full 1500 s with no fatal error, in the level from about t+180
at about t+335 anon 12.2, file 2.7, shmem 1.0 GiB, swap 12 GiB (the cap) anon 8.0, file-mapped 1.6, shmem 2.3, swap 4.4 GiB
later levels off from about t+830: anon 3.9-4.5, file 1.0-1.1, shmem 0.5-0.7, swap 9.9 GiB. Peak anon + swap 14.4 GiB

One caveat: the run without the mapping was on an older base (main 7a0c838ca with #5181). The newer base also includes #290's larger import budget, so the base differs a little besides this PR.

The Linux side works like ThatsLeo's original branch did here (numbers in my earlier comment).

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6165552913 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4806#issuecomment-6165552913). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-14T09:46:53Z. --- Demon's Souls (PPSA01341 v1.07) on Linux with this head (4a0489a7a), as offered above. With it, the title loads the tutorial level and stays in it, where it was OOM-killed without it. Setup: Linux, RTX 5070 Ti, NVIDIA 595.91, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`. Base `main` 6546a3394 with local merges of #758, #5181 (three commits) and #5747, plus a local stencil-export workaround for #4276. The run is capped at 22 GiB RAM and 12 GiB swap. Warm shader cache: 9067 hits, 757 misses. | | without the cache mapping (warm) | with this PR (warm) | |---|---|---| | outcome | OOM-killed at the cap at about t+337, during the level load | ran the full 1500 s with no fatal error, in the level from about t+180 | | at about t+335 | anon 12.2, file 2.7, shmem 1.0 GiB, swap 12 GiB (the cap) | anon 8.0, file-mapped 1.6, shmem 2.3, swap 4.4 GiB | | later | | levels off from about t+830: anon 3.9-4.5, file 1.0-1.1, shmem 0.5-0.7, swap 9.9 GiB. Peak anon + swap 14.4 GiB | One caveat: the run without the mapping was on an older base (`main` 7a0c838ca with #5181). The newer base also includes #290's larger import budget, so the base differs a little besides this PR. The Linux side works like ThatsLeo's original branch did here (numbers in my earlier comment). AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!4806
No description provided.