translate --warm counts a cache hit as "translated now" when another worker misses at the same moment (a global MISSES diff around a per-shader call) #32
Labels
No labels
accessibility
already-solved
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
merged
needs-decision
needs-game-run
needs-rebase
not-merged
nvidia
obsolete
question
security
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/avatarmanz--VIctory-7900XTX#32
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?
@itsonewi on GitHub · 2026-11-25 23:55 UTC · original
victory translate --warmreports "N translated now, M in the cache already" by diffing a process-wide miss counter around each shader, so with the default four workers a cache hit is counted as a translation.Where
crates/victory-gpu/src/shader_cache.rs:107-113:crates/victory-hle/src/modules/d3d12x.rs:56-60inverts it into "translated now":and the caller (
apps/victory/src/translate.rs:213-219) classifies each shader from that bool:Why the comment's mitigation does not hold
The comment says the caller "only adds them up", but this caller does not: it reads the bool per shader and increments one of two counters. With more than one worker (the default is
jobs.unwrap_or(4)attranslate.rs:180), any miss on another thread between the two loads turns this shader's hit intoOk(false)→ "translated now". So the split is wrong exactly when it is worth reading, and one shader's real translation can be attributed to another.The information is already available one level down:
cached()(shader_cache.rs:147-177) keeps a per-callran: AtomicBoolin itsTranslateconverter and uses it to incrementHITS/MISSEScorrectly.precompilejust does not return it — it recomputes from the global counter instead.Effect
victory warm --usedis one of the two pre-steps in the README, and its output is the evidence that a cache is warm:With four workers, a partially warm cache reports some of its hits as fresh translations (and the totals per report stop being comparable). Anyone diagnosing a slow first run from these numbers is reading a value that depends on scheduling.
Fix
Have
cached()report whether the converter ran (return it fromhost_shader/precompile, e.g.Result<(HostShader, bool), String>), and build the bool from that instead of fromMISSESaround the call. Then the comment can go.Not checked
Source reading at
0a43566. I did not runtranslate --warmwith more than one worker, so the mis-counting is derived from the code, not observed in a run.AI use
AI-assisted review (source reading). No build, no run, no game files.
github-bot referenced this issue2026-11-26 11:21:42 +00:00
github-bot referenced this issue2026-11-26 11:21:45 +00:00
github-bot referenced this issue2026-11-26 11:22:10 +00:00
@kilolimaVI on GitHub · 2026-11-26 19:25 UTC · original
Tested the three open fixes for this side by side on Windows 11 (Ryzen 7 8845HS / Radeon 780M, pinned toolchain 1.98.1), each branch as-is:
cargo test -p victory-gpu --lib shader_cacheAll three fix it the same way (
precompileuses this call's own "translated" flag instead of the globalMISSESdelta). Differences from reading the diffs:cached_ran,cached_by's signature is unchanged. Its test is single-threaded but deterministic and also covers therefreshcases. It also carries thedescriptor_sites.rsclippy fix.cached_byto return(shader, ran). Its test runs 64 threads, but doesn't check that another thread's miss actually overlapped.cachedtoo (largest diff, touches 9 existing assertions). Its test is the only one that asserts another thread's miss happened during the hit.None of the tests call
precompileitself. Merging one should close the other two.