GPU: a shader cache miss hands back its translation, not the entry read back #2055
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2055
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2055/head"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 04:12 UTC · original
0xkn0wh3r3:gpu/shader-cache-miss-keeps-translation→main· +49 −4 · 1 files · 1 commits · merged 2026-11-25 21:53 UTCThe 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, #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.@Marvisak on GitHub · 2026-11-25 09:23 UTC · original
Automated triage for the maintainers.
Merge candidate.
shader_cache::cached(crates/victory-gpu/src/shader_cache.rs) now returns the translation thatTranslate::convertjust made on a miss. Main writes the entry and then reads and decodes the new file. When the entry cannot be written, the kept translation is returned instead of translating a second time. Checked against main:encodedestructures everyHostShaderfield anddecodemirrors it, so an in-memory result matches what a later hit decodes. The existing round-trip test covers this.breakfallback.cached, and all three conflict with main. This PR merges cleanly and is smaller.Recommending a look, not approving.
CI: not run (no check runs on the head commit).
Generated by Claude Code