Shader cache: translation failures are not cached, so every run re-translates the same refused programs (fix on a fork) #1089
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#1089
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@lines9686-rgb on GitHub · 2026-11-24 15:38 UTC · original
Shaders that fail translation are translated again in every run.
shader_cache.rsstores only successful translations:Translate::convertreturns the error andvictory-pipeline's cache keeps onlyOkresults. A program that fails therefore fails again on the next start, with the same input and the same result.Measured on an RTX 3060 Ti, own 1.0.2.1 copy, five warm runs of one build:
Why caching the error is safe: translation is a pure function of the container and of what
build()already hashes (our executable and the loop limit). The same key gives the same error. A new build changes the key, so it tries again, and so does a new loop limit.Change (one file,
crates/victory-gpu/src/shader_cache.rs):convertstores a failed translation as aVSF1entry (magic, then the error text) under the same key.cachedreturnsErr(text)for such an entry and counts it as a hit.VSF1entry is treated like a damaged shader entry: it is a miss and is tried again.failures_come_back_from_the_cache_too: a second lookup comes from disk, another build tries again, a damaged entry is retried;failure_entries_round_trip_and_are_no_shader.Branch:
lines9686-rgb/VIctory@fail-cache(commit1c2b2d6), one commit onmainffe310e.cargo test -p victory-gpu --lib shader_cachepasses 4/4, andcargo clippy -p victory-gpu --all-targets -- -D warningsis clean. The changed file isrustfmt-clean. Other files onmainshow existingcargo fmt --checkdifferences, which I left alone.AI-assisted (Claude Code); measured on my machine with my own copy, nothing from the game attached.
@adamdotpy on GitHub · 2026-11-24 15:42 UTC · original
Carried this to #1094, with @lines9686-rgb's commit
1c2b2d6unchanged and its authorship kept, since the issue says external PR creation is still restricted.Verified on
ffe310ewith the commit applied (Windows 11, Rust 1.98.1):cargo test -p victory-gpu52 passed / 1 ignored (50 before),cargo clippy -p victory-gpu --all-targets --all-features -D warningsclean,cargo build --release -p victorybuilds, and the changed file isrustfmt-clean.I checked the three ways this could go wrong and none does: the key holds the build fingerprint, so a rebuilt translator retries rather than trusting a cached refusal; a truncated
VSF1entry decodes to nothing and is retried as a miss; and nothing outsidehost_shaderreads the entry.One thing that follows from it: the per-frame line
queue.rs:270reports hits and misses, and a cached refusal lands in hits now, so a run full of refusals shows a higher hit rate than it has translations. Fine, but the wording could say so. It also removes the need for the dedupe I raised on #638'sVICTORY_DUMP_FAILED: the container is translated once per build now, so the dump is written once per hash.@pickles976 on GitHub · 2026-11-24 15:42 UTC · original
Cross-check from ivall/xcl: we have this gap twice over, and your issue is the trigger to write it up on our side. (1) Your exact case:
compile_cached_in_withon failure only bumps acounters.failure— no negative artifact — so a deterministically failing DXC compile re-pays the full compile every run (your measured per-run cost is our cold-boot tail too). (2) A worse upstream variant on us: translator refusals (the "X is not supported" errors — e.g. your #1062 log's 64-bit image atomic / untracked-mask select) occur before the DXIL cache exists, so refused programs are re-emitted from scratch every single launch, forever — our cold-boot time on mesh-storm titles is dominated by re-translating an unchanging refusal set.The one trap your design (and ours) has to survive: negative-cache invalidation. A refusal is only as durable as the capability set that produced it — a translator update (your #1068 trio landing, our BCPack merge turning 512 refusals into successes) must not be poisoned by yesterday's marker. So the negative key must include everything the positive key includes plus anything capability-shaped: our positive key already folds toolchain identity; a negative entry additionally needs translator/spec revision and any config knob that changes lowering (wave mode, post-#1398: GVN-retry state) — or the strictly safer design: key the marker by the refusal reason string plus lowering-revision digest and refuse to trust markers whose digest drifted. If your measurements land per-program refusal timings, share them — on our side the same numbers would justify an xcl issue + a cache-version bump scheme, and both projects should converge on one invalidation story rather than invent two incompatible ones.
@lines9686-rgb on GitHub · 2026-11-24 15:46 UTC · original
Thanks @adamdotpy for carrying it to #1094 and for checking it.
Hit-rate wording: agreed. A second commit on the same branch,
lines9686-rgb/VIctory@fail-cache(HEAD), counts refusals found in the cache in their own counter.counts()now returns(hits, misses, refusals), and the per-frame line inqueue.rsreports all three. Hits are only real translations now.cargo test -p victory-gpu --lib shader_cachepasses 4/4 and clippy-D warningsis clean. If you want it in #1094, cherry-pick it as it is.@pickles976, on invalidation: here the key isn't a version number. It's the BLAKE3 of the whole executable plus the loop limit (
build()). On stacks with #439 it is also keyed by the host's wave-lane range (key(build(), target)). Any change to the translator, or to a constant that changes lowering, produces a new executable and a new key, so every refusal is retried once per build. No marker can outlive the translator that wrote it. The one caveat is run-time switches that change lowering without changing the binary. Such a switch has to go intobuild()'s hash, as the loop limit already does. A diagnostics-only switch that changes translation (wave-mode experiments, for example) needs to be added there too.Numbers, from the same machine (RTX 3060 Ti, Ryzen 5 5600, 6 creation workers):
AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 10:02 UTC · original
Automated triage for the maintainers.
This is fixed in
main. Sincec47b529("Shader warm-up (translate --cache), a cache keyed by the translator, pipeline queue fixes"),crates/victory-gpu/src/shader_cache.rskeeps a container that does not translate:encodewrites a refusal entry (REFUSEDmagic plus the reason) anddecodereturns it asErr(reason), under the same key built bybuild()(translator source hash, the entry encoding and the loop limit). The file's header comment says so too. PR #1094, which carried this branch, has been closed.Proposed close as fixed in
main. The issue will be closed in 48 hours unless the reporter replies or a maintainer removes the label. If you see refused programs being translated again on currentmainwith the cache enabled, please say so here.Generated by Claude Code