Shader cache: a staging file a killed process left behind no longer loses the translation #1321

Manually merged
github merged 1 commit from github-bot/gh-1321 into gh-pr/1321/base 2026-11-26 18:09:49 +00:00 AGit
Owner

@⁠CwWwWwW on GitHub · 2026-11-26 15:02 UTC · original
CwWwWwW:fix/shader-cache-stale-temp → main · +58 −7 · 1 files · 1 commits · merged 2026-11-26 18:05 UTC

Problem

victory_pipeline::cache stages a conversion in a file named by <pid>-<counter> and publishes it with a rename. This layer's host can end a run at any point (host_gpu_failed calls TerminateProcess), and Windows reuses process ids: a later process with the same id starts its counter at 0 and meets the old file. create_new then fails, and Cache::get_or_convert returns that error before shader_cache's two-attempt repair loop (crates/victory-gpu/src/shader_cache.rs propagates with ?), so that shader never translates for the run: its host pipeline is never made and its draws are dropped until the cache directory is cleaned.

Change

Treat an existing staging file as what it is - the leftover of a killed writer, which is the only process that could read it: open it with truncate instead of failing on create_new, then write and rename as before. The naming scheme and the published file are unchanged.

Tests

  • cargo test -p victory-pipeline --locked: 5 passed, 0 failed.
  • New a_stale_staging_file_does_not_fail_a_conversion writes the half-finished file a killed process would leave at the next staging name; without the change it fails (create_new: os error 80, file exists), with it the conversion is written and renamed into place.
  • The cache tests now run one at a time: they share the process-wide counter that names staging files.
  • cargo clippy -p victory-pipeline --all-targets --locked -- -D warnings: clean.
  • No game or GPU needed: the defect is in the file layer and the test drives get_or_convert directly.
  • CI note: the check job on main at the time of writing is already failing on the repository's asset-policy test (crates/victory-shader/src/emit/lower.rs is 526,968 bytes against the 524,288-byte limit), unrelated to this branch.
**@⁠CwWwWwW** on GitHub · 2026-11-26 15:02 UTC · [original](https://github.com/fxceless/victory-fork/pull/1321) `CwWwWwW:fix/shader-cache-stale-temp` → `main` · +58 −7 · 1 files · 1 commits · merged 2026-11-26 18:05 UTC ## Problem `victory_pipeline::cache` stages a conversion in a file named by `<pid>-<counter>` and publishes it with a rename. This layer's host can end a run at any point (`host_gpu_failed` calls `TerminateProcess`), and Windows reuses process ids: a later process with the same id starts its counter at 0 and meets the old file. `create_new` then fails, and `Cache::get_or_convert` returns that error before `shader_cache`'s two-attempt repair loop (`crates/victory-gpu/src/shader_cache.rs` propagates with `?`), so that shader never translates for the run: its host pipeline is never made and its draws are dropped until the cache directory is cleaned. ## Change Treat an existing staging file as what it is - the leftover of a killed writer, which is the only process that could read it: open it with `truncate` instead of failing on `create_new`, then write and rename as before. The naming scheme and the published file are unchanged. ## Tests - `cargo test -p victory-pipeline --locked`: 5 passed, 0 failed. - New `a_stale_staging_file_does_not_fail_a_conversion` writes the half-finished file a killed process would leave at the next staging name; without the change it fails (`create_new`: os error 80, file exists), with it the conversion is written and renamed into place. - The cache tests now run one at a time: they share the process-wide counter that names staging files. - `cargo clippy -p victory-pipeline --all-targets --locked -- -D warnings`: clean. - No game or GPU needed: the defect is in the file layer and the test drives `get_or_convert` directly. - CI note: the `check` job on `main` at the time of writing is already failing on the repository's asset-policy test (`crates/victory-shader/src/emit/lower.rs` is 526,968 bytes against the 524,288-byte limit), unrelated to this branch.
`victory_pipeline::cache` stages a conversion in a file named by
`<pid>-<counter>` and publishes it with a rename. This title's host can
end a run at any point (`host_gpu_failed` calls `TerminateProcess`), and
Windows reuses process ids: a later process with the same id starts its
counter at 0 and meets the old file. `create_new` then fails and
`Cache::get_or_convert` returns the error before the shader cache's
two-attempt repair loop, so that shader never translates for the run, its
host pipeline is never made, and its draws are dropped.

An existing staging file can only be read by its writer, which is no
longer running: write it again (truncate) instead of failing. The name
scheme is unchanged.

Test: `a_stale_staging_file_does_not_fail_a_conversion` writes the
half-finished file a killed process would leave at the next name; without
the change it fails on `create_new` (os error 80, file exists), with it
the conversion is written and renamed into place. The cache tests now run
one at a time: they share the process-wide counter that names the staging
file.

`cargo test -p victory-pipeline --locked`: 5 passed, 0 failed;
`cargo clippy -p victory-pipeline --all-targets -- -D warnings`: clean.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 15:07:38 +00:00
Author
Owner

@⁠CwWwWwW on GitHub · 2026-11-26 15:09 UTC · original

CI note: the failing check is the pre-existing asset-policy violation on crates/victory-shader/src/emit/lower.rs (526,968 B against the 524,288-byte limit) on main, not this branch. #1322 from the same fork moves that file's tests under the limit; once it lands this can be rebased and the check should be green.

Local on this branch: cargo test -p victory-pipeline --locked 5 passed / 0 failed; the new test fails without the change (create_new: os error 80, file exists); cargo clippy -p victory-pipeline --all-targets --locked -- -D warnings clean.

**@⁠CwWwWwW** on GitHub · 2026-11-26 15:09 UTC · [original](https://github.com/fxceless/victory-fork/pull/1321#issuecomment-7195866373) CI note: the failing `check` is the pre-existing asset-policy violation on `crates/victory-shader/src/emit/lower.rs` (526,968 B against the 524,288-byte limit) on `main`, not this branch. [#1322](https://git.gtahub.st/github/fxceless--victory-fork/pulls/1322) from the same fork moves that file's tests under the limit; once it lands this can be rebased and the check should be green. Local on this branch: `cargo test -p victory-pipeline --locked` 5 passed / 0 failed; the new test fails without the change (`create_new`: os error 80, file exists); `cargo clippy -p victory-pipeline --all-targets --locked -- -D warnings` clean.
github-bot changed target branch from main to gh-pr/1321/base 2026-11-26 18:09:48 +00:00
github manually merged commit 40791368ab into gh-pr/1321/base 2026-11-26 18:09:49 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.