Warm-up: each shader's "translated now" comes from its own call (#32) #171

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

@⁠amine23012004 on GitHub · 2026-11-26 09:53 UTC · original
amine23012004:fix/warm-cache-hit-count → main · +53 −15 · 1 files · 1 commits · open

Fixes #32.

What and why

victory translate --warm reports "N translated now, M in the cache already". Each shader is classified by shader_cache::precompile, which read the process-wide MISSES counter before and after its own call. With the default four workers, a miss on another thread between the two loads turned this shader's cache hit into "translated now", so the split in the warm-up line depended on scheduling (details in #32).

cached_by already tracks, per call, whether its converter ran (Translate::ran), and uses it to bump HITS/MISSES. It now also returns it: Result<(HostShader, bool), String>. precompile takes the bool from there instead of from MISSES, and the comment that said the caller only adds the counts up is gone. cached (used by host_shader in runs) still returns the shader alone, so runs are unchanged. Without a cache, precompile now reports "translated" rather than "was there"; both callers open the cache first, so this path is not taken today.

Tested

  • cargo clippy -p victory-gpu -p victory-hle -p victory --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings, with and without --all-features: clean.
  • cargo xtask policy --staged: ok.
  • New test each_call_tells_its_own_hit_from_its_miss: one container already cached is asked 64 times while 64 other threads translate new containers; every hit must come back as not translated, every miss as translated. entries_of_an_earlier_translator_are_served_or_refreshed now also checks the flag at each step.
  • In my fork, all CI jobs pass with this commit together with the CI fix (https://github.com/amine23012004/VIctory-7900XTX/pull/1): shader_cache::tests::each_call_tells_its_own_hit_from_its_miss ... ok, entries_of_an_earlier_translator_are_served_or_refreshed ... ok. On this branch alone the CI stays red for the two reasons fixed in the CI pull request.
  • Not run: victory translate --warm itself (no game files, no GPU used).

AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

**@⁠amine23012004** on GitHub · 2026-11-26 09:53 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/171) `amine23012004:fix/warm-cache-hit-count` → `main` · +53 −15 · 1 files · 1 commits · open Fixes #32. ### What and why `victory translate --warm` reports "N translated now, M in the cache already". Each shader is classified by `shader_cache::precompile`, which read the process-wide `MISSES` counter before and after its own call. With the default four workers, a miss on another thread between the two loads turned this shader's cache hit into "translated now", so the split in the warm-up line depended on scheduling (details in #32). `cached_by` already tracks, per call, whether its converter ran (`Translate::ran`), and uses it to bump `HITS`/`MISSES`. It now also returns it: `Result<(HostShader, bool), String>`. `precompile` takes the bool from there instead of from `MISSES`, and the comment that said the caller only adds the counts up is gone. `cached` (used by `host_shader` in runs) still returns the shader alone, so runs are unchanged. Without a cache, `precompile` now reports "translated" rather than "was there"; both callers open the cache first, so this path is not taken today. ### Tested - `cargo clippy -p victory-gpu -p victory-hle -p victory --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings`, with and without `--all-features`: clean. - `cargo xtask policy --staged`: ok. - New test `each_call_tells_its_own_hit_from_its_miss`: one container already cached is asked 64 times while 64 other threads translate new containers; every hit must come back as not translated, every miss as translated. `entries_of_an_earlier_translator_are_served_or_refreshed` now also checks the flag at each step. - In my fork, all CI jobs pass with this commit together with the CI fix (https://github.com/amine23012004/VIctory-7900XTX/pull/1): `shader_cache::tests::each_call_tells_its_own_hit_from_its_miss ... ok`, `entries_of_an_earlier_translator_are_served_or_refreshed ... ok`. On this branch alone the CI stays red for the two reasons fixed in the CI pull request. - Not run: `victory translate --warm` itself (no game files, no GPU used). AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`precompile` told a hit from a miss by reading the process-wide MISSES
counter before and after the call. `victory translate --warm` runs four
workers by default and classifies every shader from that bool, so a miss
on another thread between the two loads turned this shader's cache hit
into "translated now". `cached_by` already knows per call whether its
converter ran; it now returns that, and `precompile` uses it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:21:42 +00:00
Author
Owner

@⁠amine23012004 on GitHub · 2026-11-26 11:23 UTC · original

Heads-up: #175 (opened ~30 min after this one) fixes the same #32 counter. It threads the "did this call run the translator" flag back out of cached() instead of comparing the global miss counter — a cleaner shape than mine. Only one of the two is needed; happy for this one to be closed in favour of #175 if you prefer it.

**@⁠amine23012004** on GitHub · 2026-11-26 11:23 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/171#issuecomment-7190661988) Heads-up: #175 (opened ~30 min after this one) fixes the same #32 counter. It threads the "did this call run the translator" flag back out of `cached()` instead of comparing the global miss counter — a cleaner shape than mine. Only one of the two is needed; happy for this one to be closed in favour of #175 if you prefer it.
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/171/head:github-bot/gh-171'
git switch 'github-bot/gh-171'

Merge

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