Count a shader-cache hit from this call's flag, not the shared miss counter (#32) #175

Open
github-bot wants to merge 1 commit from github-bot/gh-175 into main AGit
Owner

@⁠ri995410-art on GitHub · 2026-11-26 10:24 UTC · original
ri995410-art:cursor/shader-cache-precompile-hit-count-8436 → main · +110 −24 · 1 files · 1 commits · open

Fixes #32.

victory translate --warm classifies each shader as "translated now" vs. "in the cache already" from victory_gpu::shader_cache::precompile's returned bool. Previously, precompile computed that bool by checking whether the process-wide MISSES counter changed around the call, so with the default four workers a miss on another thread between the two loads turned this thread's cache hit into "translated now".

Changes

  • crates/victory-gpu/src/shader_cache.rs:
    • cached and cached_by now return Result<(HostShader, bool), String>, exposing the converter's existing per-call ran flag.
    • precompile returns !ran when a cache is open, and false when no cache is open (where this call translated), removing the global MISSES diff and stale comment.
    • host_shader discards the flag so existing callers are unchanged.
    • Added a_cache_hit_is_not_a_miss_when_another_thread_misses, which verifies a cached lookup still reports a hit while another thread concurrently triggers misses and increments MISSES.

Verification

  • cargo clippy --target x86_64-pc-windows-msvc -p victory-gpu --all-targets --locked -- -D warnings (both default and --all-features) passed.
  • Cross-compiled victory-gpu tests with x86_64-pc-windows-gnu and ran shader_cache::tests:: under Wine: 4 passed, 0 failed (including the new concurrency test).
  • cargo xtask policy: 262 files ok.
  • No game run; no game files touched.

Closes #32

**@⁠ri995410-art** on GitHub · 2026-11-26 10:24 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/175) `ri995410-art:cursor/shader-cache-precompile-hit-count-8436` → `main` · +110 −24 · 1 files · 1 commits · open Fixes #32. `victory translate --warm` classifies each shader as "translated now" vs. "in the cache already" from `victory_gpu::shader_cache::precompile`'s returned `bool`. Previously, `precompile` computed that `bool` by checking whether the process-wide `MISSES` counter changed around the call, so with the default four workers a miss on another thread between the two loads turned this thread's cache hit into "translated now". ## Changes - `crates/victory-gpu/src/shader_cache.rs`: - `cached` and `cached_by` now return `Result<(HostShader, bool), String>`, exposing the converter's existing per-call `ran` flag. - `precompile` returns `!ran` when a cache is open, and `false` when no cache is open (where this call translated), removing the global `MISSES` diff and stale comment. - `host_shader` discards the flag so existing callers are unchanged. - Added `a_cache_hit_is_not_a_miss_when_another_thread_misses`, which verifies a cached lookup still reports a hit while another thread concurrently triggers misses and increments `MISSES`. ## Verification - `cargo clippy --target x86_64-pc-windows-msvc -p victory-gpu --all-targets --locked -- -D warnings` (both default and `--all-features`) passed. - Cross-compiled `victory-gpu` tests with `x86_64-pc-windows-gnu` and ran `shader_cache::tests::` under Wine: 4 passed, 0 failed (including the new concurrency test). - `cargo xtask policy`: `262 files ok`. - No game run; no game files touched. Closes #32
victory translate --warm reports "translated now" against "in the cache
already" from precompile's bool. That bool was whether the process-wide
MISSES counter changed around the call, so with the default four workers
another thread's miss was counted as this shader translating. The
converter already records whether it ran; precompile returns that.

Co-authored-by: ri995410-art <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:21:45 +00:00
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-26 10:40 UTC · original

Independent confirmation from the other side of the same bug: a warm run here logs "shader translated" 3,332 times while the pipeline library at the same moment reports made=0 loaded=2,287 - every cache hit was counted as a translation. That made the number useless exactly where it matters, deciding whether a first run was cold (a cold run is 2-3x slower until victory warm has run). The per-call flag is the right source.

**@⁠Calvix2k** on GitHub · 2026-11-26 10:40 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/175#issuecomment-7189672692) Independent confirmation from the other side of the same bug: a warm run here logs "shader translated" 3,332 times while the pipeline library at the same moment reports `made=0 loaded=2,287` - every cache hit was counted as a translation. That made the number useless exactly where it matters, deciding whether a first run was cold (a cold run is 2-3x slower until `victory warm` has run). The per-call flag is the right source.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/175/head:github-bot/gh-175'
git switch 'github-bot/gh-175'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-175'
git switch 'github-bot/gh-175'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-175'
git switch 'github-bot/gh-175'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-175'
git switch 'main'
git merge --squash 'github-bot/gh-175'
git switch 'main'
git merge --ff-only 'github-bot/gh-175'
git switch 'main'
git merge 'github-bot/gh-175'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.