GPU: cache the error of a container that does not translate #1094

Closed
github-bot wants to merge 5 commits from gh-pr/1094/head into gh-pr/1094/base
Owner

@⁠adamdotpy on GitHub · 2026-11-24 15:42 UTC · original
adamdotpy:gpu/cache-translation-failures → main · +260 −14 · 2 files · 5 commits · closed without merging

Carries @⁠lines9686-rgb's commit from #1089, verified here; AI-assisted.

The change is lines9686-rgb@1c2b2d6, pushed unchanged with its authorship, because external PR creation is still restricted and the issue proposes the branch for cherry-pick.

What it does

shader_cache stored only successful translations, so every run re-translated every container that does not translate — measured in #1089 at ~400 programs per run, the large compute ones 2-3 s each, with the creation workers spending about 1.5 minutes after world entry failing the same programs again while their draws were dropped.

  • Translate::convert now stores a refusal as a VSF1 entry (the error's text) under the same key instead of returning Err, so it is written like a translation.
  • cached reads either magic: VSH1 gives the shader, VSF1 gives the error back. A damaged VSF1 entry is a miss, like a damaged shader entry, and is tried again.
  • A cached refusal counts as a hit, since no translation ran.

The key is build(): the BLAKE3 of our executable plus the loop limit. A rebuilt translator, or another VICTORY_SHADER_LOOP_LIMIT, is a different key and tries again, so a fix is not hidden by a cached refusal. Translation itself is pure over the container, so the same key cannot succeed after failing.

Verification here

Windows 11, Rust 1.98.1, on ffe310e with this commit applied:

  • cargo test -p victory-gpu: 52 passed, 1 ignored (50 before; the two new tests are failures_come_back_from_the_cache_too and failure_entries_round_trip_and_are_no_shader).
  • cargo clippy -p victory-gpu --all-targets --all-features -- -D warnings: clean.
  • cargo build --release -p victory: builds.
  • rustfmt --edition 2024 --check crates/victory-gpu/src/shader_cache.rs: clean (the other fmt differences in the tree are on main already).

I read the change for the three things that could go wrong and all three hold: a refusal cannot become a stale success (the key holds the build), a truncated entry is retried rather than trusted (the decode returns None and the file is removed), and nothing outside host_shader reads the entry (only pipeline.rs does, and it drops the draws as before).

Two things worth knowing

  • The per-frame log at queue.rs:270 says "shaders from the cache and translated so far"; a cached refusal is counted in the first number now, so a run with many refusals shows a higher hit rate than it has translations. Not wrong, but the wording could say "from the cache (refusals included)".
  • This removes the need for the dedupe I suggested in #638's VICTORY_DUMP_FAILED review point: a refused container is translated once per build now, so the dump is written once per hash rather than per retry.

Fixes #1089.

**@⁠adamdotpy** on GitHub · 2026-11-24 15:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/1094) `adamdotpy:gpu/cache-translation-failures` → `main` · +260 −14 · 2 files · 5 commits · closed without merging *Carries @⁠lines9686-rgb's commit from #1089, verified here; AI-assisted.* The change is [`lines9686-rgb@1c2b2d6`](https://github.com/lines9686-rgb/VIctory/tree/fail-cache), pushed unchanged with its authorship, because external PR creation is still restricted and the issue proposes the branch for cherry-pick. ## What it does `shader_cache` stored only successful translations, so every run re-translated every container that does not translate — measured in #1089 at ~400 programs per run, the large compute ones 2-3 s each, with the creation workers spending about 1.5 minutes after world entry failing the same programs again while their draws were dropped. - `Translate::convert` now stores a refusal as a `VSF1` entry (the error's text) under the same key instead of returning `Err`, so it is written like a translation. - `cached` reads either magic: `VSH1` gives the shader, `VSF1` gives the error back. A damaged `VSF1` entry is a miss, like a damaged shader entry, and is tried again. - A cached refusal counts as a hit, since no translation ran. The key is `build()`: the BLAKE3 of our executable plus the loop limit. A rebuilt translator, or another `VICTORY_SHADER_LOOP_LIMIT`, is a different key and tries again, so a fix is not hidden by a cached refusal. Translation itself is pure over the container, so the same key cannot succeed after failing. ## Verification here Windows 11, Rust 1.98.1, on `ffe310e` with this commit applied: - `cargo test -p victory-gpu`: 52 passed, 1 ignored (50 before; the two new tests are `failures_come_back_from_the_cache_too` and `failure_entries_round_trip_and_are_no_shader`). - `cargo clippy -p victory-gpu --all-targets --all-features -- -D warnings`: clean. - `cargo build --release -p victory`: builds. - `rustfmt --edition 2024 --check crates/victory-gpu/src/shader_cache.rs`: clean (the other `fmt` differences in the tree are on `main` already). I read the change for the three things that could go wrong and all three hold: a refusal cannot become a stale success (the key holds the build), a truncated entry is retried rather than trusted (the decode returns `None` and the file is removed), and nothing outside `host_shader` reads the entry (only `pipeline.rs` does, and it drops the draws as before). ## Two things worth knowing - The per-frame log at `queue.rs:270` says "shaders from the cache and translated so far"; a cached refusal is counted in the first number now, so a run with many refusals shows a higher hit rate than it has translations. Not wrong, but the wording could say "from the cache (refusals included)". - This removes the need for the dedupe I suggested in #638's `VICTORY_DUMP_FAILED` review point: a refused container is translated once per build now, so the dump is written once per hash rather than per retry. Fixes #1089.
Translation depends only on the container and on what the cache key
already hashes (our executable and the loop limit), so a container
that fails fails the same way again. Failures were not stored, so every
run translated the same few hundred refused programs again - seconds
each for the large compute ones - while the title waited at world
entry. Store the error text under the same key (a VSF1 entry); a new
build tries again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A VSF1 entry was the marker and then the text, so a file cut short after
the marker decoded as an empty reason, and one cut inside the text decoded
as the prefix that survived. Both are valid UTF-8 often enough that they
were served as cache hits: the refusal held, but its reason was empty or
truncated, in the one place that reason is read.

The entry now carries the text's length, and a decode whose text is not
exactly that long is damage: no entry, so the container is translated
again and the reason comes back whole. Reported by @DrDarkDK, who cut
entries short after writing them and saw both cases counted as hits.

The test cuts a real entry at the marker, four bytes past it, and one byte
before its end, and also checks the marker followed by non-UTF-8 and a
shader entry's magic with a reason after it.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
Two defects reported on #1094 by TG0000, both reproduced here first:

- Damage that keeps the entry's length (a torn write, some changed bytes)
  was served as a refusal with a wrong reason: the length check passed.
  The entry now carries the first four bytes of the text's BLAKE3 next to
  the length, and `decode_failure` rejects a mismatch. The marker moves to
  VSF2, so entries of the old layout are misses and are translated again
  rather than read with their text's first bytes as a checksum.
  `a_damaged_failure_entry_is_no_entry` now flips a byte in the text with
  the length intact; without the checksum it returns
  `Some("aascalar memory read as data")`.

- A cache folder that cannot be written made `cached` return the OS error
  instead of the reason, so the log no longer said why the shader was
  refused. A failed write now logs a warning and falls through to the
  translation itself. `a_cache_that_cannot_be_written_still_says_why`
  blocks the entry's path with a directory; without the fix it returns
  `Err("Access is denied. (os error 5)")`.

`cargo test -p victory-gpu` 54 passed / 1 ignored, clippy
`--all-targets --all-features -D warnings` clean, release build fine,
rustfmt clean on the changed file.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
The 'shaders from the cache and translated so far' line counted a
refusal served from a VSF2 entry as a hit and a fresh refusal as a
translation, so with hundreds of refused shaders the line overstated
both. Only a successful entry moves its counter now.

Red first: refusals_are_not_counted_as_translated saw (hits, misses)
move by (1, 1) for one fresh plus one cached refusal; now (0, 0),
while a translating shader still moves misses then hits.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
ready() queued every not-yet-made Pending onto the worker channel and
waited for it within the frame budget, even when one of its stage
shaders had already failed to translate and HostPipeline::new could
only refuse it. Sibling pipelines sharing that shader then sat in the
queue behind slow driver compiles, each costing the render thread wait
time. ready() now answers at once and records the refusal in made, so
diagnostics still name the shader.

Red first: a_refused_shader_skips_the_worker_queue failed on
'not sent to a worker' (queued was true); now ready returns None with
queued false and made Some(None).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:19:38 +00:00
github-bot closed this pull request 2026-11-26 04:19:38 +00:00
Author
Owner

@⁠DrDarkDK on GitHub · 2026-11-24 15:45 UTC · original

On 1c2b2d6, I populated a disposable cache with a synthetic translation refusal, then shortened the saved entry. VSF1 by itself returned an empty error. VSF1 followed by a valid UTF-8 prefix returned just that prefix. Both counted as cache hits and skipped translation. The short-marker and invalid-UTF-8 controls both retried and recovered the full error.

I simulated truncation after the write completed. If truncated entries are meant to be cache misses, storing and checking the payload length would cover both cases.

AI-assisted with Codex.

**@⁠DrDarkDK** on GitHub · 2026-11-24 15:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7136561103) On `1c2b2d6`, I populated a disposable cache with a synthetic translation refusal, then shortened the saved entry. `VSF1` by itself returned an empty error. `VSF1` followed by a valid UTF-8 prefix returned just that prefix. Both counted as cache hits and skipped translation. The short-marker and invalid-UTF-8 controls both retried and recovered the full error. I simulated truncation after the write completed. If truncated entries are meant to be cache misses, storing and checking the payload length would cover both cases. *AI-assisted with Codex.*
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 15:52 UTC · original

Good catch, and you are right about both cases: the entry was marker-then-text, so a file cut after the marker decoded as an empty reason and one cut inside the text decoded as the prefix that survived. Both are usually valid UTF-8, so both were served as hits — the refusal held, but its reason was empty or truncated, in the one place that reason is read.

Fixed in 0061ed8 as you suggested: the entry carries the text's length (VSF1, 4 bytes little endian, then the text), and a decode whose text is not exactly that long is damage, so the container is translated again and the reason comes back whole. Your short-marker and prefix cases are now the test a_damaged_failure_entry_is_no_entry, which cuts a real entry at the marker, four bytes past it and one byte before its end, and also checks the marker followed by non-UTF-8 and a shader entry's magic with a reason after it.

Verified on Windows 11, Rust 1.98.1: cargo test -p victory-gpu 53 passed / 1 ignored (51 before; the cache tests are 5), cargo clippy -p victory-gpu --all-targets --all-features -D warnings clean, cargo build --release -p victory builds, and the file is rustfmt-clean. Before the fix the new test failed exactly as your repro says (cut to 4 bytes: Some("") vs None).

**@⁠adamdotpy** on GitHub · 2026-11-24 15:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7136747942) Good catch, and you are right about both cases: the entry was marker-then-text, so a file cut after the marker decoded as an empty reason and one cut inside the text decoded as the prefix that survived. Both are usually valid UTF-8, so both were served as hits — the refusal held, but its reason was empty or truncated, in the one place that reason is read. Fixed in `0061ed8` as you suggested: the entry carries the text's length (`VSF1`, 4 bytes little endian, then the text), and a decode whose text is not exactly that long is damage, so the container is translated again and the reason comes back whole. Your short-marker and prefix cases are now the test `a_damaged_failure_entry_is_no_entry`, which cuts a real entry at the marker, four bytes past it and one byte before its end, and also checks the marker followed by non-UTF-8 and a shader entry's magic with a reason after it. Verified on Windows 11, Rust 1.98.1: `cargo test -p victory-gpu` 53 passed / 1 ignored (51 before; the cache tests are 5), `cargo clippy -p victory-gpu --all-targets --all-features -D warnings` clean, `cargo build --release -p victory` builds, and the file is `rustfmt`-clean. Before the fix the new test failed exactly as your repro says (`cut to 4 bytes`: `Some("")` vs `None`).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-24 16:29 UTC · original

Tested the VSF1 disk failure entry format (with the 4-byte length prefix in 0061ed8) on Windows across RTX 5090 and WARP (VICTORY_D3D12_DEBUG=1). A few behavioral edge cases worth tightening here:

  1. HITS / MISSES counter distortion: Incrementing MISSES on initial failure and HITS on VSF1 hits causes queue.rs to count refused shaders under "translated so far". Gating both counters on result.is_ok() keeps the frame translation stats accurate.
  2. Retry loop & no-disk-cache fallback: converter.ran stays true across the 2-iteration corruption retry loop unless reset at the top of each iteration, and host_shader() still re-runs translate() when disk caching is disabled or unavailable unless backed by a small build-keyed in-memory negative map.
  3. Sibling Pending pipeline stalls in pipeline/make.rs: Even once a Shader has failed in memory (translated.get() == Some(None)), hundreds of sibling Pending PSOs sharing that Arc<Shader> still get pushed onto the worker channel in make::ready and stall the render thread up to the 500 ms frame wait budget behind slow driver PSOs. Short-circuiting Pending::ready when any active stage shader has already failed avoids queueing and waiting altogether.

Reference commit with synthetic unit tests covering all three points (feel free to cherry-pick or fold in any pieces): github.com/fuzeofficlal/VIctory@46b28785d9

**@⁠fuzeofficlal** on GitHub · 2026-11-24 16:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7137744383) Tested the `VSF1` disk failure entry format (with the 4-byte length prefix in `0061ed8`) on Windows across RTX 5090 and WARP (`VICTORY_D3D12_DEBUG=1`). A few behavioral edge cases worth tightening here: 1. **`HITS` / `MISSES` counter distortion**: Incrementing `MISSES` on initial failure and `HITS` on `VSF1` hits causes `queue.rs` to count refused shaders under `"translated so far"`. Gating both counters on `result.is_ok()` keeps the frame translation stats accurate. 2. **Retry loop & no-disk-cache fallback**: `converter.ran` stays `true` across the 2-iteration corruption retry loop unless reset at the top of each iteration, and `host_shader()` still re-runs `translate()` when disk caching is disabled or unavailable unless backed by a small build-keyed in-memory negative map. 3. **Sibling `Pending` pipeline stalls in `pipeline/make.rs`**: Even once a `Shader` has failed in memory (`translated.get() == Some(None)`), hundreds of sibling `Pending` PSOs sharing that `Arc<Shader>` still get pushed onto the worker channel in `make::ready` and stall the render thread up to the 500 ms frame wait budget behind slow driver PSOs. Short-circuiting `Pending::ready` when any active stage shader has already failed avoids queueing and waiting altogether. Reference commit with synthetic unit tests covering all three points (feel free to cherry-pick or fold in any pieces): https://github.com/fuzeofficlal/VIctory/commit/46b28785d949514fecded4bce057030a56e0e52a
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 16:29 UTC · original

Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 1c2b2d6: cargo test -p victory-gpu passes, 52 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).

Tested with AI assistance (Claude).

**@⁠Zipettte** on GitHub · 2026-11-24 16:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7137751159) Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 1c2b2d6: `cargo test -p victory-gpu` passes, 52 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed). _Tested with AI assistance (Claude)._
Author
Owner

@⁠TG0000 on GitHub · 2026-11-24 16:32 UTC · original

Measured 0061ed8, it does what it says. I replayed offline the shaders one warm launch asked for (1,918 of them, 8 threads, Ryzen 9 5900X), on main plus a set of open shader PRs plus this one:

wall time refused thread time on refusals
no refusal kept 10.3 to 11.1 s 339 80 to 87 s
refusals kept (this PR) 0.05 to 0.06 s 339 about 0.08 s

In game, one warm launch on plain main spent 277 thread-seconds on 401 refusals. Load time and frame time were not measured.

I had written the same thing separately and dropped it in favour of this PR. Two cases my tests had that fail here, for a follow-up or this one:

  1. Cache folder not writable: the translator's reason is replaced by an OS error, so the log no longer says why the shader is refused. main keeps the reason. (My version had the same defect.) #358 and #389 edit the same function.
  2. Damage that keeps the length (some bytes changed): the entry is served with a wrong reason. A checksum of the text in the header, next to the length, makes it a miss.

A test that a different loop limit or exe makes a different key would also pin the retry.

AI-assisted (Claude Code).

**@⁠TG0000** on GitHub · 2026-11-24 16:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7137826894) Measured `0061ed8`, it does what it says. I replayed offline the shaders one warm launch asked for (1,918 of them, 8 threads, Ryzen 9 5900X), on `main` plus a set of open shader PRs plus this one: | | wall time | refused | thread time on refusals | |---|---|---|---| | no refusal kept | 10.3 to 11.1 s | 339 | 80 to 87 s | | refusals kept (this PR) | 0.05 to 0.06 s | 339 | about 0.08 s | In game, one warm launch on plain `main` spent 277 thread-seconds on 401 refusals. Load time and frame time were not measured. I had written the same thing separately and dropped it in favour of this PR. Two cases my tests had that fail here, for a follow-up or this one: 1. **Cache folder not writable**: the translator's reason is replaced by an OS error, so the log no longer says why the shader is refused. `main` keeps the reason. (My version had the same defect.) #358 and #389 edit the same function. 2. **Damage that keeps the length** (some bytes changed): the entry is served with a wrong reason. A checksum of the text in the header, next to the length, makes it a miss. A test that a different loop limit or exe makes a different key would also pin the retry. _AI-assisted (Claude Code)._
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 16:39 UTC · original

Both of your cases are fixed in 097a790 on this branch, and each was reproduced here before the fix, with the failing assertion quoted in the commit message.

1. Damage that keeps the length. decode_failure only compared lengths, so a torn write with the right length was served as a refusal with a wrong reason. The entry now carries the first four bytes of the text's BLAKE3 between the length and the text, and a mismatch is a miss. The marker moves VSF1 → VSF2, so entries written by the previous revision are clean misses and get translated again rather than parsed with their text's first bytes as a checksum. Red test: a_damaged_failure_entry_is_no_entry now flips one byte in the text with the length intact — without the checksum it returns Some("aascalar memory read as data"), with it None.

2. Unwritable cache folder. cached propagated get_or_convert's error with ?, so the answer became the OS error and the log lost the reason. A failed write now logs shader cache entry not written; translating without it and falls through to the translation itself, which returns the real reason. Red test: a_cache_that_cannot_be_written_still_says_why blocks the entry's own path with a directory so the rename onto it fails — without the fix the result is Err("Access is denied. (os error 5)"), with it Err("a scalar memory read as data").

Verified on Windows 11 / Rust 1.98.1: cargo test -p victory-gpu 54 passed / 1 ignored (6 in shader_cache, both new ones included), cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings clean, cargo build --release -p victory builds, rustfmt --edition 2024 --check clean on the changed file. Pushed as a fast-forward to gpu/cache-translation-failures, no force.

Your third suggestion — a test that a different loop limit or exe makes a different key — is already covered by the existing translations_come_back_from_the_cache ("another build translates again") plus build() hashing the exe and VICTORY_SHADER_LOOP_LIMIT together, so I did not add a duplicate.

Thanks for the measurement table, by the way: 0.05 s against 10.3 s for 339 refusals is the number that justifies this whole branch.

**@⁠adamdotpy** on GitHub · 2026-11-24 16:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7137994895) Both of your cases are fixed in `097a790` on this branch, and each was reproduced here before the fix, with the failing assertion quoted in the commit message. **1. Damage that keeps the length.** `decode_failure` only compared lengths, so a torn write with the right length was served as a refusal with a wrong reason. The entry now carries the first four bytes of the text's BLAKE3 between the length and the text, and a mismatch is a miss. The marker moves `VSF1` → `VSF2`, so entries written by the previous revision are clean misses and get translated again rather than parsed with their text's first bytes as a checksum. Red test: `a_damaged_failure_entry_is_no_entry` now flips one byte in the text with the length intact — without the checksum it returns `Some("aascalar memory read as data")`, with it `None`. **2. Unwritable cache folder.** `cached` propagated `get_or_convert`'s error with `?`, so the answer became the OS error and the log lost the reason. A failed write now logs `shader cache entry not written; translating without it` and falls through to the translation itself, which returns the real reason. Red test: `a_cache_that_cannot_be_written_still_says_why` blocks the entry's own path with a directory so the rename onto it fails — without the fix the result is `Err("Access is denied. (os error 5)")`, with it `Err("a scalar memory read as data")`. Verified on Windows 11 / Rust 1.98.1: `cargo test -p victory-gpu` 54 passed / 1 ignored (6 in `shader_cache`, both new ones included), `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings` clean, `cargo build --release -p victory` builds, `rustfmt --edition 2024 --check` clean on the changed file. Pushed as a fast-forward to `gpu/cache-translation-failures`, no force. Your third suggestion — a test that a different loop limit or exe makes a different key — is already covered by the existing `translations_come_back_from_the_cache` ("another build translates again") plus `build()` hashing the exe and `VICTORY_SHADER_LOOP_LIMIT` together, so I did not add a duplicate. Thanks for the measurement table, by the way: 0.05 s against 10.3 s for 339 refusals is the number that justifies this whole branch.
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 17:10 UTC · original

Point by point on the three edge cases, checked against this branch at d03d93c (Windows 11 / Rust 1.98.1, isolated target dir):

1. Counter distortion — real, fixed in e090242. Reproduced first: the new test refusals_are_not_counted_as_translated saw (hits, misses) move by (1, 1) for one fresh refusal plus one served from a VSF2 entry — a cached refusal incremented HITS, a fresh one MISSES, both under the "shaders from the cache and translated so far" frame line. Now only a successful entry moves its counter (the refusal is still logged with ok=false); the test passes with (0, 0) for the refusals and (0, 1) then (1, 0) for a shader that translates and is then cached. The cache tests now share a mutex so the process-wide counters can't race between them.

2a. ran across the retry loop — not a defect, no reset needed. ran is only read after an entry decodes. In iteration 2 an entry can only be served if the file exists, and after a damaged entry the code removes it first — so either convert re-ran in iteration 2 (ran true, correctly a miss) or the removal failed and the file is iteration 1's own convert output (ran still true, also correctly a miss: it was translated in this call). A pre-existing file would have been served in iteration 1, so a true hit never sees ran == true.

2b. No disk cache — main's behavior, not this PR's. The None => translate(container) arm of host_shader is byte-identical on main (git show upstream/main:...shader_cache.rs), and the cache is on by default (run.rs always calls use_shader_cache with the cache subdir; use_shader_cache only leaves CACHE unset when the folder can't be opened). So re-translating refusals with the cache off is exactly what main does. A build-keyed in-memory negative map for that path is a reasonable follow-up, but it's a new feature with a growth/keying decision, not a fix to this branch — happy to take it as its own PR if you want it.

3. Sibling Pending stalls — real, fixed in d03d93c. Confirmed in code: ready() queued any not-yet-made Pending and waited within the 500 ms frame budget even when HostPipeline::new could only refuse it (s.translated()? per stage). ready() now answers None at once when any stage shader has translated == Some(None), and still records the refusal in made so the diagnostics path (missing) keeps naming the shader. Red first: the new a_refused_shader_skips_the_worker_queue failed on "not sent to a worker"; now ready returns None with queued == false and made == Some(None).

Verification on d03d93c: cargo test -p victory-gpu 56 passed / 1 ignored (both new tests included), cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings clean, cargo build --release -p victory builds, rustfmt --edition 2024 --check clean on shader_cache.rs and on the lines changed in make.rs (its three remaining fmt hunks are pre-existing on main). Pushed as a fast-forward to gpu/cache-translation-failures, no force.

**@⁠adamdotpy** on GitHub · 2026-11-24 17:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7138791890) Point by point on the three edge cases, checked against this branch at `d03d93c` (Windows 11 / Rust 1.98.1, isolated target dir): **1. Counter distortion — real, fixed in `e090242`.** Reproduced first: the new test `refusals_are_not_counted_as_translated` saw `(hits, misses)` move by `(1, 1)` for one fresh refusal plus one served from a `VSF2` entry — a cached refusal incremented `HITS`, a fresh one `MISSES`, both under the "shaders from the cache and translated so far" frame line. Now only a successful entry moves its counter (the refusal is still logged with `ok=false`); the test passes with `(0, 0)` for the refusals and `(0, 1)` then `(1, 0)` for a shader that translates and is then cached. The cache tests now share a mutex so the process-wide counters can't race between them. **2a. `ran` across the retry loop — not a defect, no reset needed.** `ran` is only read after an entry decodes. In iteration 2 an entry can only be served if the file exists, and after a damaged entry the code removes it first — so either `convert` re-ran in iteration 2 (`ran` true, correctly a miss) or the removal failed and the file is iteration 1's own `convert` output (`ran` still true, also correctly a miss: it was translated in this call). A pre-existing file would have been served in iteration 1, so a true hit never sees `ran == true`. **2b. No disk cache — main's behavior, not this PR's.** The `None => translate(container)` arm of `host_shader` is byte-identical on `main` (`git show upstream/main:...shader_cache.rs`), and the cache is on by default (`run.rs` always calls `use_shader_cache` with the cache subdir; `use_shader_cache` only leaves `CACHE` unset when the folder can't be opened). So re-translating refusals with the cache off is exactly what main does. A build-keyed in-memory negative map for that path is a reasonable follow-up, but it's a new feature with a growth/keying decision, not a fix to this branch — happy to take it as its own PR if you want it. **3. Sibling `Pending` stalls — real, fixed in `d03d93c`.** Confirmed in code: `ready()` queued any not-yet-made `Pending` and waited within the 500 ms frame budget even when `HostPipeline::new` could only refuse it (`s.translated()?` per stage). `ready()` now answers `None` at once when any stage shader has `translated == Some(None)`, and still records the refusal in `made` so the diagnostics path (`missing`) keeps naming the shader. Red first: the new `a_refused_shader_skips_the_worker_queue` failed on "not sent to a worker"; now `ready` returns `None` with `queued == false` and `made == Some(None)`. Verification on `d03d93c`: `cargo test -p victory-gpu` 56 passed / 1 ignored (both new tests included), `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings` clean, `cargo build --release -p victory` builds, `rustfmt --edition 2024 --check` clean on `shader_cache.rs` and on the lines changed in `make.rs` (its three remaining fmt hunks are pre-existing on main). Pushed as a fast-forward to `gpu/cache-translation-failures`, no force.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:32 UTC · original

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Already in main: a container that does not translate is cached with its reason (shader_cache.rs REFUSED entries, c47b5297), so it is not translated again every run.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7148606345) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Already in main: a container that does not translate is cached with its reason (shader_cache.rs REFUSED entries, c47b5297), so it is not translated again every run. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1094
No description provided.