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

Open
amine23012004 wants to merge 1 commit from upstream-pr/171 into main
amine23012004 commented 2026-11-26 09:53:02 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by amine23012004 on 2026-11-26T09:53:02Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6624016533 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/171). Originally posted by [amine23012004](https://github.com/amine23012004) on 2026-11-26T09:53:02Z. --- 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)
amine23012004 commented 2026-11-26 11:23:20 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by amine23012004 on 2026-11-26T11:23:20Z.


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.

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7190661988 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/171#issuecomment-7190661988). Originally posted by [amine23012004](https://github.com/amine23012004) on 2026-11-26T11:23:20Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/171:upstream-pr/171'
git switch 'upstream-pr/171'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/171'
git switch 'upstream-pr/171'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/171'
git switch 'upstream-pr/171'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/171'
git switch 'main'
git merge --squash 'upstream-pr/171'
git switch 'main'
git merge --ff-only 'upstream-pr/171'
git switch 'main'
git merge 'upstream-pr/171'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
avatarmanz/VIctory-7900XTX!171
No description provided.