test(shader): skip open-entry cache replacements where SMB has no POSIX rename #11434

Merged
LeandroLP23 merged 1 commit from upstream-pr/11434 into main 2026-10-27 05:38:46 +00:00
LeandroLP23 commented 2026-10-26 13:17:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-26T13:17:23Z.


What

Fixes #10833 the way agreed there (option 1): replacement stays atomic, and the tests skip only what an SMB share cannot do.

On Windows WriteFileAtomically replaces a cache entry with a POSIX-semantics rename (SetFileInformationByHandle class 22, FileRenameInfoEx), so readers and mappings of the old entry keep working. Through an SMB share that rename fails with ERROR_INVALID_PARAMETER, and the std::filesystem::rename fallback is refused while the destination is open or mapped. The issue's NAS and \\localhost\C$ (Windows' own SMB server, over NTFS) behave the same; the error codes are in https://github.com/boykopovar/AnyPS5/issues/10833#issuecomment-6411899172.

With the first skip in place, the tests reached three more places that need the same operations:

  • verifyStore and verifyPersist replace an entry that ShaderDiskCache itself has mapped with MapViewOfFile after loading it. A mapping blocks the plain rename just like an open reader.
  • The cleanup removeCacheDirectory deletes with FileDispositionInfoEx and FILE_DISPOSITION_FLAG_POSIX_SEMANTICS, which SMB also rejects with ERROR_INVALID_PARAMETER, and the entries the cache still maps can't be deleted there.
  • shader_cache_file_read built the \\?\ alias of a UNC path as \\?\\\server\share\…; the extended form of a UNC path is \\?\UNC\server\share\….

Changes:

  • ShaderCacheDirectory.hpp: the POSIX rename moves unchanged into PosixReplaceByHandle, which WriteFileAtomically calls as before, so production behaviour does not change. PosixReplaceUnsupported(directory) probes that rename on two scratch files in a directory and reports only ERROR_INVALID_PARAMETER.
  • agc_shader_disk_cache: where the probe reports it, verifyAtomicReplacement skips the retained-reader replacement, verifyStore skips the truncated- and damaged-entry checks, and verifyPersist skips replacing the mapped persisted entry, each printing why. Any other replacement failure still fails. The cleanup falls back to a plain delete only when the POSIX delete returns ERROR_INVALID_PARAMETER, and then leaves the directory behind with a note instead of failing.
  • shader_cache_file_read: the UNC alias fix, and the retained-reader replacement is skipped under the same probe. A plain replacement without a reader is still checked there.
  • docs/dev/debt/shader.md: a "Shader cache directories on SMB shares" entry records that such a cache directory cannot update an open or mapped entry, including one this process's cache has mapped, and why replacement stays atomic.

Tested

Rebased onto main 9656d366be (head 8259ecb26d); on the RTX 5060 Ti the whole table below and the validation run were repeated on the rebased head and on 9656d366be, with the same results. The first runs, on both machines, were on base 7b415520b6.

Same commands on two machines, TEMP/TMP set to a local NTFS directory or to \\localhost\C$\aps5-smbtmp, each test 3 times, on this head and on its base main 7b415520b6:

  • Windows 11 10.0.26300, AMD Ryzen AI 7 350 / Radeon 860M, AMD 24.30.58.08 (32.0.13058.8001), WinLibs GCC 15.2.0 r7, Release.
  • Windows 11 10.0.26300, Intel i5-10600K / NVIDIA GeForce RTX 5060 Ti, NVIDIA 621.01, same toolchain, Release.
Test TEMP this head (both machines) main (both machines)
agc_shader_disk_cache NTFS 3/3 3/3
shader_cache_file_read NTFS 3/3 3/3
agc_shader_disk_cache SMB 3/3, prints the skips 0/3, cannot replace cache entry with a retained reader
shader_cache_file_read SMB 3/3, prints the skips 0/3
  • Before the verifyStore/verifyPersist/cleanup changes, a local build that ran every verify* case under try/catch listed the failing SMB cases: only verifyStore (cannot truncate the entry) and verifyPersist (cannot replace the persisted entry), then the cleanup's POSIX delete. The other 31 cases pass on the share unchanged.
  • Validation layer: ctest -V -R "shader_disk_cache|shader_cache|pipeline_cache|pipeline_journal" with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan SDK 1.4.363.0): 27/27 on this head and on main, on both GPUs, with no VUID- lines and no was not found but was requested by env var VK_INSTANCE_LAYERS. With VK_LOADER_DEBUG=layer, four of these create a device and show Insert instance layer "VK_LAYER_KHRONOS_validation": agc_pipeline_cache_header, agc_pipeline_cache, agc_pipeline_cache_file and agc_driver_pipeline_journal; the disk cache tests themselves are CPU-only.
  • A real NAS was not available; \\localhost\C$ reproduces the issue's failure and error codes.
  • check_conventions.py --base origin/main passes. pr_overlap.py finds no conflicting comparison; PRs that already conflict with main (#6235, #6280, #6412, #6488, #6924, #7484, #7684, #8004, #9387, #9748, #10049, #10233) share ShaderDiskCache.cpp or the shader debt file and were not compared.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: Fixes #10833
  • Unblocks: none
  • GPUs tested: AMD Radeon 860M (integrated), AMD 24.30.58.08, Windows 11 10.0.26300; NVIDIA GeForce RTX 5060 Ti, NVIDIA 621.01, Windows 11 10.0.26300
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5018080530 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11434). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-26T13:17:23Z. --- ### What Fixes #10833 the way agreed there (option 1): replacement stays atomic, and the tests skip only what an SMB share cannot do. On Windows `WriteFileAtomically` replaces a cache entry with a POSIX-semantics rename (`SetFileInformationByHandle` class 22, `FileRenameInfoEx`), so readers and mappings of the old entry keep working. Through an SMB share that rename fails with `ERROR_INVALID_PARAMETER`, and the `std::filesystem::rename` fallback is refused while the destination is open or mapped. The issue's NAS and `\\localhost\C$` (Windows' own SMB server, over NTFS) behave the same; the error codes are in https://github.com/boykopovar/AnyPS5/issues/10833#issuecomment-6411899172. With the first skip in place, the tests reached three more places that need the same operations: - `verifyStore` and `verifyPersist` replace an entry that `ShaderDiskCache` itself has mapped with `MapViewOfFile` after loading it. A mapping blocks the plain rename just like an open reader. - The cleanup `removeCacheDirectory` deletes with `FileDispositionInfoEx` and `FILE_DISPOSITION_FLAG_POSIX_SEMANTICS`, which SMB also rejects with `ERROR_INVALID_PARAMETER`, and the entries the cache still maps can't be deleted there. - `shader_cache_file_read` built the `\\?\` alias of a UNC path as `\\?\\\server\share\…`; the extended form of a UNC path is `\\?\UNC\server\share\…`. Changes: - `ShaderCacheDirectory.hpp`: the POSIX rename moves unchanged into `PosixReplaceByHandle`, which `WriteFileAtomically` calls as before, so production behaviour does not change. `PosixReplaceUnsupported(directory)` probes that rename on two scratch files in a directory and reports only `ERROR_INVALID_PARAMETER`. - `agc_shader_disk_cache`: where the probe reports it, `verifyAtomicReplacement` skips the retained-reader replacement, `verifyStore` skips the truncated- and damaged-entry checks, and `verifyPersist` skips replacing the mapped persisted entry, each printing why. Any other replacement failure still fails. The cleanup falls back to a plain delete only when the POSIX delete returns `ERROR_INVALID_PARAMETER`, and then leaves the directory behind with a note instead of failing. - `shader_cache_file_read`: the UNC alias fix, and the retained-reader replacement is skipped under the same probe. A plain replacement without a reader is still checked there. - `docs/dev/debt/shader.md`: a "Shader cache directories on SMB shares" entry records that such a cache directory cannot update an open or mapped entry, including one this process's cache has mapped, and why replacement stays atomic. ### Tested Rebased onto `main` `9656d366be` (head `8259ecb26d`); on the RTX 5060 Ti the whole table below and the validation run were repeated on the rebased head and on `9656d366be`, with the same results. The first runs, on both machines, were on base `7b415520b6`. Same commands on two machines, `TEMP`/`TMP` set to a local NTFS directory or to `\\localhost\C$\aps5-smbtmp`, each test 3 times, on this head and on its base `main` `7b415520b6`: - Windows 11 10.0.26300, AMD Ryzen AI 7 350 / Radeon 860M, AMD 24.30.58.08 (32.0.13058.8001), WinLibs GCC 15.2.0 r7, Release. - Windows 11 10.0.26300, Intel i5-10600K / NVIDIA GeForce RTX 5060 Ti, NVIDIA 621.01, same toolchain, Release. | Test | `TEMP` | this head (both machines) | `main` (both machines) | |---|---|---|---| | `agc_shader_disk_cache` | NTFS | 3/3 | 3/3 | | `shader_cache_file_read` | NTFS | 3/3 | 3/3 | | `agc_shader_disk_cache` | SMB | 3/3, prints the skips | 0/3, `cannot replace cache entry with a retained reader` | | `shader_cache_file_read` | SMB | 3/3, prints the skips | 0/3 | - Before the `verifyStore`/`verifyPersist`/cleanup changes, a local build that ran every `verify*` case under `try`/`catch` listed the failing SMB cases: only `verifyStore` (`cannot truncate the entry`) and `verifyPersist` (`cannot replace the persisted entry`), then the cleanup's POSIX delete. The other 31 cases pass on the share unchanged. - Validation layer: `ctest -V -R "shader_disk_cache|shader_cache|pipeline_cache|pipeline_journal"` with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Vulkan SDK 1.4.363.0): 27/27 on this head and on `main`, on both GPUs, with no `VUID-` lines and no `was not found but was requested by env var VK_INSTANCE_LAYERS`. With `VK_LOADER_DEBUG=layer`, four of these create a device and show `Insert instance layer "VK_LAYER_KHRONOS_validation"`: `agc_pipeline_cache_header`, `agc_pipeline_cache`, `agc_pipeline_cache_file` and `agc_driver_pipeline_journal`; the disk cache tests themselves are CPU-only. - A real NAS was not available; `\\localhost\C$` reproduces the issue's failure and error codes. - `check_conventions.py --base origin/main` passes. `pr_overlap.py` finds no conflicting comparison; PRs that already conflict with `main` (#6235, #6280, #6412, #6488, #6924, #7484, #7684, #8004, #9387, #9748, #10049, #10233) share `ShaderDiskCache.cpp` or the shader debt file and were not compared. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: Fixes #10833 - [x] Unblocks: none - [x] GPUs tested: AMD Radeon 860M (integrated), AMD 24.30.58.08, Windows 11 10.0.26300; NVIDIA GeForce RTX 5060 Ti, NVIDIA 621.01, Windows 11 10.0.26300 - [x] AI-assisted: yes (Claude Code)
MarcZX10 commented 2026-10-26 15:43:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T15:43:50Z.

Review: CHANGES_REQUESTED


I reviewed the Windows SMB probing/fallback and its test changes on exact head 8259ecb26dac1890717b823dd42f9558eb4fa9a4. I found no implementation defect in the bounded FILE_RENAME_INFO_EX buffer construction or the fallback behavior. The author reports repeated Windows runs on two GPUs and local NTFS plus \\localhost\C$, including the cache test matrix and validation-layer comparison. I did not independently run those Windows tests. Current conventions, git diff --check, and the merge-tree preview pass; hosted Linux/Windows product jobs are path-skipped.

Before merge, please sync this branch to current main (b0f1183ca12b). Its tested base is 9656d366be; the intervening commits do not touch this PR's implementation, tests, or debt entry, and the preview merges cleanly. This is the remaining branch-freshness requirement from CONTRIBUTING.md.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5654791428 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11434#pullrequestreview-5654791428). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T15:43:50Z. **Review:** CHANGES_REQUESTED --- I reviewed the Windows SMB probing/fallback and its test changes on exact head `8259ecb26dac1890717b823dd42f9558eb4fa9a4`. I found no implementation defect in the bounded `FILE_RENAME_INFO_EX` buffer construction or the fallback behavior. The author reports repeated Windows runs on two GPUs and local NTFS plus `\\localhost\C$`, including the cache test matrix and validation-layer comparison. I did not independently run those Windows tests. Current conventions, `git diff --check`, and the merge-tree preview pass; hosted Linux/Windows product jobs are path-skipped. Before merge, please sync this branch to current `main` (`b0f1183ca12b`). Its tested base is `9656d366be`; the intervening commits do not touch this PR's implementation, tests, or debt entry, and the preview merges cleanly. This is the remaining branch-freshness requirement from `CONTRIBUTING.md`.
MarcZX10 commented 2026-10-26 15:52:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T15:52:22Z.

Review: APPROVED


Re-reviewed exact head b95b22cf1622, now based on live main da89f18ea7c1. The rebase preserves the reviewed one-commit implementation and reported Windows SMB/NTFS regression coverage; no source or test files changed between the tested base and this main. The current-main merge preview, conventions and whitespace checks pass. Linux and Windows relinker plus ASan checks pass; macOS relinker jobs are still running/queued, and runtime product tests are skipped by path policy. I did not independently run the Windows/GPU tests. The earlier branch-freshness request is resolved. Approved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5654918590 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11434#pullrequestreview-5654918590). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-26T15:52:22Z. **Review:** APPROVED --- Re-reviewed exact head `b95b22cf1622`, now based on live `main` `da89f18ea7c1`. The rebase preserves the reviewed one-commit implementation and reported Windows SMB/NTFS regression coverage; no source or test files changed between the tested base and this `main`. The current-main merge preview, conventions and whitespace checks pass. Linux and Windows relinker plus ASan checks pass; macOS relinker jobs are still running/queued, and runtime product tests are skipped by path policy. I did not independently run the Windows/GPU tests. The earlier branch-freshness request is resolved. Approved.
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!11434
No description provided.