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

Closed
adamdotpy wants to merge 5 commits from upstream-pr/1094 into main
adamdotpy commented 2026-11-24 15:42:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T15:42:02Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6585603537 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1094). Originally posted by [adamdotpy](https://github.com/adamdotpy) on 2026-11-24T15:42:02Z. --- *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.
DrDarkDK commented 2026-11-24 16:05:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-24T15:45:28Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136561103 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7136561103). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-24T15:45:28Z. --- 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.*
adamdotpy commented 2026-11-24 16:05:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T15:52:07Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7136747942 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7136747942). Originally posted by [adamdotpy](https://github.com/adamdotpy) on 2026-11-24T15:52:07Z. --- 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`).
DoubleD17 commented 2026-11-24 17:03:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DoubleD17 on 2026-11-24T16:12:37Z.

Review: COMMENTED


I compared the shader-cache error path on 0061ed8 with ffe310e by source inspection. On a cache miss, the base returns a translation refusal before it attempts a write. The PR encodes the refusal as a successful VSF1 payload. If persistence then fails, cached returns the cache I/O error to the pipeline caller before it decodes the original reason.

In an independent Windows filesystem model, a directory at the destination made the rename fail on two successive requests. Both requests returned the rename error and reran the stub translator. With a writable destination, both returned the original refusal and the stub ran once. The model exercised the filesystem scenario. The caller behavior follows from inspection of the Rust control flow, and the PR itself was not executed. Could a regression test check that the caller still receives the original translation reason when only persistence fails?

AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:review:6042994829 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1094#pullrequestreview-6042994829). Originally posted by [DoubleD17](https://github.com/DoubleD17) on 2026-11-24T16:12:37Z. **Review:** COMMENTED --- I compared the shader-cache error path on `0061ed8` with `ffe310e` by source inspection. On a cache miss, the base returns a translation refusal before it attempts a write. The PR encodes the refusal as a successful `VSF1` payload. If persistence then fails, `cached` returns the cache I/O error to the pipeline caller before it decodes the original reason. In an independent Windows filesystem model, a directory at the destination made the rename fail on two successive requests. Both requests returned the rename error and reran the stub translator. With a writable destination, both returned the original refusal and the stub ran once. The model exercised the filesystem scenario. The caller behavior follows from inspection of the Rust control flow, and the PR itself was not executed. Could a regression test check that the caller still receives the original translation reason when only persistence fails? AI-assisted.
fuzeofficlal commented 2026-11-24 17:04:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T16:29:21Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137744383 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7137744383). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-24T16:29:21Z. --- 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
Zipettte commented 2026-11-24 17:04:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T16:29:38Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137751159 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7137751159). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T16:29:38Z. --- 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)._
TG0000 commented 2026-11-24 17:04:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by TG0000 on 2026-11-24T16:32:31Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137826894 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7137826894). Originally posted by [TG0000](https://github.com/TG0000) on 2026-11-24T16:32:31Z. --- 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)._
adamdotpy commented 2026-11-24 17:04:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T16:39:00Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7137994895 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7137994895). Originally posted by [adamdotpy](https://github.com/adamdotpy) on 2026-11-24T16:39:00Z. --- 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 commented 2026-11-24 18:05:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by adamdotpy on 2026-11-24T17:10:16Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138791890 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7138791890). Originally posted by [adamdotpy](https://github.com/adamdotpy) on 2026-11-24T17:10:16Z. --- 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.
upstream-sync closed this pull request 2026-11-25 01:05:32 +00:00
Marvisak commented 2026-11-25 01:08:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:32:05Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148606345 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1094#issuecomment-7148606345). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:32:05Z. --- 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

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
Marvisak/VIctory!1094
No description provided.