Shader cache: a cache that cannot write still translates #389
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/389"
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 Marvisak/VIctory. Originally posted by Kaairim on 2026-11-24T02:52:12Z.
What
When the shader cache cannot store an entry,
host_shadernow returns the translation it just made instead of the cache's error. A warning is logged once. A translation that itself fails still fails, once, with the same message as before.Why
Cache::get_or_converttranslates, then creates the entry's folder, writes a temporary file and renames it. If any of those three fail (a full disk, a cache folder we may not write, a file held by a scanner), it returns an error andcachedpassed it on with?: the translation had been made and was dropped, so the shader – and the pipeline and draws using it – were lost for the whole run, every time.The converter now keeps its last output (and whether the translation itself failed), so
cachedcan tell the two errors apart and use the output when only the cache failed.Tested
Windows 11 (build 26300), Rust 1.98.1 (pinned toolchain), x86_64-pc-windows-msvc:
shader_cache::tests::a_cache_that_cannot_write_still_translates: a file where the cache folder was, so no entry can be written. Without the fix the first assert fails (Err); with it the shader comes back from the one translation made, and a failing translation is still an error, run once.cargo test --workspace --no-fail-fast: 265 passed, 0 failed, 4 ignored (main: 264 / 0 / 4).cargo clippy --workspace --all-targets: the same two warnings as main, none in this file.rustfmt --check --edition 2024 crates/victory-gpu/src/shader_cache.rs: clean.cargo xtask policy: ok.Not run: the title (I have no copy of it). The changed path only runs when the cache cannot write.
Improvements by William "kaairim" Deivid (wdcore). AI-assisted: Claude Code with Claude Opus 5.5 wrote the change, the test and this description; a second Claude Opus 5.5 agent reviewed the diff.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-24T04:25:45Z.
Thanks @Kaairim for preserving translation when cache writes fail. I tested head
c84e0e60bfc13de5e603c445ebaaf827690ae6cdwith:Result: 1 passed, 0 failed (44 filtered out). The test exercises shader translation with a cache configured so writes are unavailable, checking that the cache failure does not prevent translation. It does not exercise a game launch or persistent cache across processes.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-24T11:54:47Z.
I checked the shader-cache pair from #813 at a later failure point than the existing shard-folder tests. In a temporary cache, the entry path was a directory. The shader translated, the temporary file could be written, and renaming it into place failed.
ffe310e369dc32c84e0e6All three cleaned up the temporary entry. After removing the obstruction, the next call wrote a valid entry and the following call hit it.
The incremental change below keeps the original
HostShaderin #389's converter. That removes the encoded-buffer clone and returns the original on a fresh miss, whether publication succeeded or failed. A cache hit still decodes the stored entry. The tests confirmed the original translator output was retained in both miss cases and that a subsequent hit did not invoke the translator.AI-assisted. Verified on Windows with synthetic cache entries.
Incremental patch on
c84e0e6Pull request closed