Repository navigation
GPU: a shader cache miss hands back its translation, not the entry read back - #2055
Conversation
…ad back On a miss, `shader_cache::cached` had the cache write the new entry and then read and decoded that file to return it. The first read of a file just written is slow where a virus scanner looks at new files: measured here (Windows Defender on) at about 0.5 ms for an 8 KB entry and 3.3 ms for 60 KB, against 70-85 us for a later read, which is on the order of a 1-12 ms translation. `translate --cache` misses on every container the first time (some 25,000), and a run misses on every shader not cached. The converter now keeps the translation it encoded, and a miss returns it; entries are read only on hits. A translation whose entry could not be written is returned as made too, where it was translated a second time before. The new test makes the cache folder unusable and checks the translation is made once (twice before).
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Shader-cache miss hands back its translation, not the entry read — cache race fix; subtle and important if the read raced with eviction.
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):
cargo test -p victory-gpu --lib shader_cache::— 4 passed, 0 failed (includinga_translation_is_made_once_when_its_entry_cannot_be_written)cargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)
Clean fix returning the in-memory translation on cache miss instead of re-reading from disk when the cache entry cannot be written. Looks good.
AI-assisted (Gemini 4 Neon).
|
Automated triage for the maintainers.
Recommending a look, not approving. CI: not run (no check runs on the head commit). Generated by Claude Code |
Xvania7
left a comment
There was a problem hiding this comment.
Verified 6d13eff on Windows 10 + NVIDIA GeForce RTX 5060:
shader_cache::tests::(4 passed, includinga_translation_is_made_once_when_its_entry_cannot_be_written)cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warningscargo xtask policy: 182 files ok
Approving.
…not the entry read bac) into demo
The problem
A shader cache miss paid for a slow file read on top of the translation.
On a miss,
shader_cache::cachedhad the cache write the new entry, then read and decoded that file to return it. The first read of a file just written is slow where a virus scanner looks at new files. Measured here (Windows Defender on):That is on the order of a 1-12 ms translation.
translate --cachemisses on every container the first time (some 25,000), and a run misses on every shader not cached.A second, smaller waste: when the entry could not be written, the shader was translated a second time.
The fix
Translate) now keeps the translation it encoded, and a miss returns it. Entries are read only on hits.Testing
shader_cache::tests::a_translation_is_made_once_when_its_entry_cannot_be_written: makes the cache folder unusable and checks the translation is made once. Passes; with the old fallback it fails (the translation runs twice). The existingtranslations_come_back_from_the_cache(hits, misses, damaged entries, refusals) still passes.cargo test -p victory-gpuon an RTX 5070 Ti (driver 621.24): all pass exceptdescriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views, which fail the same way onmain(the NVIDIA 1,000,000-descriptor heap cap, NVIDIA D3D12 (70564ae): stride_tests & synthetic_tests fail due to HEAP_VIEWS (2M > 1M NVIDIA limit) and Stride::Structured with rawBufferLoad #1835).cargo clippy -p victory-gpu --all-targets, with and without--features diagnostics: clean.Not covered / Related
translate --cache(no game data here); the per-entry read cost is from timings on this machine.