Repository navigation
Conversation
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 <noreply@anthropic.com>
|
On 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. |
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 <vibe@mistral.ai>
|
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 Verified on Windows 11, Rust 1.98.1: |
DoubleD17
left a comment
There was a problem hiding this comment.
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.
|
Tested the
Reference commit with synthetic unit tests covering all three points (feel free to cherry-pick or fold in any pieces): fuzeofficlal@46b2878 |
|
Measured
In game, one warm launch on plain 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:
A test that a different loop limit or exe makes a different key would also pin the retry. AI-assisted (Claude Code). |
…not be written keeps the reason Two defects reported on Marvisak#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 <vibe@mistral.ai>
|
Both of your cases are fixed in 1. Damage that keeps the length. 2. Unwritable cache folder. Verified on Windows 11 / Rust 1.98.1: Your third suggestion — a test that a different loop limit or exe makes a different key — is already covered by the existing 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. |
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 <vibe@mistral.ai>
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 <vibe@mistral.ai>
|
Point by point on the three edge cases, checked against this branch at 1. Counter distortion — real, fixed in 2a. 2b. No disk cache — main's behavior, not this PR's. The 3. Sibling Verification on |
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. Ported from Marvisak/VIctory#1094 (head 097a790) by adamdotpy Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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. Ported from Marvisak/VIctory#1094 (head 097a790) by adamdotpy Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Two defects reported on Marvisak/VIctory#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. Ported from Marvisak/VIctory#1094 (head 097a790) by adamdotpy Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
From the review of the port (the three commits before this): - The module notes say what keys a refusal: the build and the target, as for a translation (the upstream text names the build only; XTP keys its entries by target since the wave64 wiring). And why nothing transient is kept: the translator's errors (ShaderError) are all refusals of the container itself; out of memory and a removed device happen in the driver's compile, after this cache. `kept` says that its `translate` must fail only that way. - An entry that cannot be written is answered from the translation convert() already made, not by translating a second time (upstream's test asked for at least one run). That holds for a translation that succeeds too, which before the port came back as the OS error, the shader refused. The warning is told once, then at debug level: a full disk would log it for every shader of a world. - Tests: refusals_are_kept_by_build_and_target (translated once per build and target, then from the cache; a rebuilt translator or another target translates again and may take it), the translator's own refusal of a non-DXBC container kept with its text, and an unwritable cache translating once, for a refusal and for a translation. Ported from Marvisak/VIctory#1094 (head 097a790) by adamdotpy, reviewed
…ice at most Review points on the #1094 port (pipe-cache): - The frame line "shaders from the cache and translated so far" counted a refusal served from its entry as a hit and a fresh one as a translation. Only a shader moves a counter now. Ported from Marvisak/VIctory#1094 (commit e090242) by adamdotpy, with its test; every test that goes through `cached` holds one lock, so the test that reads the process-wide counters sees only its own. - An entry that did not read back after its second write made a third translation; the one made for that entry is the answer now. (Not tested: the cache writes the entry itself, so no test can tear it between the write and the read.) - The damaged-entry test also cuts right after the header (no text).
|
Automated triage for the maintainers. Closing because this change is already in Already in main: a container that does not translate is cached with its reason (shader_cache.rs REFUSED entries, c47b529), 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. |
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_cachestored 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::convertnow stores a refusal as aVSF1entry (the error's text) under the same key instead of returningErr, so it is written like a translation.cachedreads either magic:VSH1gives the shader,VSF1gives the error back. A damagedVSF1entry is a miss, like a damaged shader entry, and is tried again.The key is
build(): the BLAKE3 of our executable plus the loop limit. A rebuilt translator, or anotherVICTORY_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
ffe310ewith this commit applied:cargo test -p victory-gpu: 52 passed, 1 ignored (50 before; the two new tests arefailures_come_back_from_the_cache_tooandfailure_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 otherfmtdifferences in the tree are onmainalready).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
Noneand the file is removed), and nothing outsidehost_shaderreads the entry (onlypipeline.rsdoes, and it drops the draws as before).Two things worth knowing
queue.rs:270says "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)".VICTORY_DUMP_FAILEDreview point: a refused container is translated once per build now, so the dump is written once per hash rather than per retry.Fixes #1089.