GPU: sweep cut pipeline-cache staging files #2510

Open
github-bot wants to merge 2 commits from github-bot/gh-2510 into main AGit
Owner

@⁠Ingenioeren on GitHub · 2026-11-25 15:03 UTC · original
Ingenioeren:fix/2496-pipeline-staging-sweep → main · +91 −1 · 1 files · 2 commits · open

What

use_pipeline_cache() in crates/victory-gpu/src/pipeline/library.rs now sweeps stale staging files. Only regular files named exactly {host-pipelines.bin,early-pipelines.txt,prebuilt-pipelines.txt}.tmp-<digits>-<digits> are removed. This process's go at once, because none of its writes has started yet. Other processes' go once untouched for 10 minutes, because the folder is shared and nothing stops a second instance from writing in it.

The earlier version also added a lock to save(). Triage pointed out that #2328 (opened earlier) makes the same change and has tests for it, so that half is dropped here. This PR is now only the sweep.

Why

Since #1660, each write stages in a unique <file>.tmp-<pid>-<n>. A write cut by an exit (the exit save's early return, host_gpu_failed, a crash exit) leaves that file for good: no later run reuses the name, and nothing swept the folder. #2328 makes the normal exit wait for a running save, but crash and host_gpu_failed exits can still cut a write, so a sweep is needed either way.

On #2129: it also removes staging files at load, but decides by checking whether the writing process is still running. This version uses only the file name and age, so it needs no process query and also covers a reused pid. Either approach closes the gap; I'm happy to defer to whichever you prefer.

How tested

  • New pipeline::library::tests::stale_staging_files_are_swept. It checks that own-pid and old foreign staging files are removed for all three cache files, and that a recent foreign one, the cache files themselves, near-miss names (.tmp-7, .tmp-7-x, other.bin.tmp-7-0) and a directory are kept. With the sweep disabled it fails (host-pipelines.bin.tmp-7-0 swept); with the fix it passes.
  • Rebased on current main. cargo test --locked --offline -p victory-gpu: 196 passed, 0 failed, 1 ignored.
  • cargo clippy --locked --offline -p victory-gpu --all-targets: no warnings.
  • cargo run -p xtask -- policy --staged: asset policy: 1 files ok.

Not tested: no game run.

Part of #2496 (the other half is #2328).

AI assistance: prepared with Claude Code, reviewed by Ingenioeren.

🤖 Generated with Claude Code

**@⁠Ingenioeren** on GitHub · 2026-11-25 15:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2510) `Ingenioeren:fix/2496-pipeline-staging-sweep` → `main` · +91 −1 · 1 files · 2 commits · open ## What `use_pipeline_cache()` in `crates/victory-gpu/src/pipeline/library.rs` now sweeps stale staging files. Only regular files named exactly `{host-pipelines.bin,early-pipelines.txt,prebuilt-pipelines.txt}.tmp-<digits>-<digits>` are removed. This process's go at once, because none of its writes has started yet. Other processes' go once untouched for 10 minutes, because the folder is shared and nothing stops a second instance from writing in it. The earlier version also added a lock to `save()`. Triage pointed out that #2328 (opened earlier) makes the same change and has tests for it, so that half is dropped here. This PR is now only the sweep. ## Why Since #1660, each write stages in a unique `<file>.tmp-<pid>-<n>`. A write cut by an exit (the exit save's early return, `host_gpu_failed`, a crash exit) leaves that file for good: no later run reuses the name, and nothing swept the folder. #2328 makes the normal exit wait for a running save, but crash and `host_gpu_failed` exits can still cut a write, so a sweep is needed either way. On #2129: it also removes staging files at load, but decides by checking whether the writing process is still running. This version uses only the file name and age, so it needs no process query and also covers a reused pid. Either approach closes the gap; I'm happy to defer to whichever you prefer. ## How tested - New `pipeline::library::tests::stale_staging_files_are_swept`. It checks that own-pid and old foreign staging files are removed for all three cache files, and that a recent foreign one, the cache files themselves, near-miss names (`.tmp-7`, `.tmp-7-x`, `other.bin.tmp-7-0`) and a directory are kept. With the sweep disabled it fails (`host-pipelines.bin.tmp-7-0 swept`); with the fix it passes. - Rebased on current `main`. `cargo test --locked --offline -p victory-gpu`: 196 passed, 0 failed, 1 ignored. - `cargo clippy --locked --offline -p victory-gpu --all-targets`: no warnings. - `cargo run -p xtask -- policy --staged`: `asset policy: 1 files ok`. Not tested: no game run. Part of #2496 (the other half is #2328). AI assistance: prepared with Claude Code, reviewed by Ingenioeren. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Since #1660 each cache write stages in `<file>.tmp-<pid>-<n>`, and a write
cut by an exit (TerminateProcess) leaves that file for good: no later run
reuses the name and nothing removed it.

`use_pipeline_cache()` sweeps the staging files of the three cache files:
this process's at once, other processes' after 10 minutes untouched (the
folder is shared and nothing stops a second instance). Only regular files
named exactly `<cache file>.tmp-<digits>-<digits>` go.

Part of #2496: its other half (an exit save that waits for a running
one) is #2328.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:07:50 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 16:00 UTC · original · edited 2026-11-25 16:48 UTC

Automated triage for the maintainers.

Merge candidate.

Changed since the last review (new head 1b6a079): the save() lock that duplicated #2328 is gone. The PR is now only the staging-file sweep in crates/victory-gpu/src/pipeline/library.rs. At startup, use_pipeline_cache calls sweep_staging, which removes leftover temporary files from interrupted cache writes.

  • It removes only files named <cache file>.tmp-<pid>-<n>, matching the names write_atomically creates in main. staging_pid requires both numbers to be all digits.
  • It removes this process's own staging files at once. Another process's files are removed only after 10 minutes untouched, since a running instance may still be writing them.
  • Directories and other files are left alone.

stale_staging_files_are_swept covers the name matching, the age rule and the directory case. tempfile is already a dev-dependency.

On your reply: thanks, this is the reduced version that was asked for. #2129 also clears staging files at load, by checking whether the writing process is still running, so the maintainer will pick one of the two.

CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 16:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2510#issuecomment-7167508319) · edited 2026-11-25 16:48 UTC <!-- victory-triage v1 head=1b6a0795161ead0e1b6bd5f87b4a32d8ce6b6947 verdict=merge-candidate at=2026-11-25T16:44:54Z --> Automated triage for the maintainers. **Merge candidate.** Changed since the last review (new head `1b6a079`): the `save()` lock that duplicated #2328 is gone. The PR is now only the staging-file sweep in `crates/victory-gpu/src/pipeline/library.rs`. At startup, `use_pipeline_cache` calls `sweep_staging`, which removes leftover temporary files from interrupted cache writes. - It removes only files named `<cache file>.tmp-<pid>-<n>`, matching the names `write_atomically` creates in main. `staging_pid` requires both numbers to be all digits. - It removes this process's own staging files at once. Another process's files are removed only after 10 minutes untouched, since a running instance may still be writing them. - Directories and other files are left alone. `stale_staging_files_are_swept` covers the name matching, the age rule and the directory case. `tempfile` is already a dev-dependency. On your reply: thanks, this is the reduced version that was asked for. #2129 also clears staging files at load, by checking whether the writing process is still running, so the maintainer will pick one of the two. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Ingenioeren on GitHub · 2026-11-25 16:05 UTC · original

Thanks for the triage. I dropped the save() lock, since #2328 already covers it. The PR is now only the staging-file sweep, rebased on current main (1b6a079). I also changed "Fixes #2496" to "Part of #2496" and added a note to the description comparing this with #2129.

**@⁠Ingenioeren** on GitHub · 2026-11-25 16:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2510#issuecomment-7167582629) Thanks for the triage. I dropped the `save()` lock, since #2328 already covers it. The PR is now only the staging-file sweep, rebased on current `main` (1b6a079). I also changed "Fixes #2496" to "Part of #2496" and added a note to the description comparing this with #2129.
Author
Owner

@⁠futurepro62 on GitHub · 2026-11-26 01:09 UTC · original

Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head 1b6a079 (on its base 67e8ae1).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 9 ignored.
  • The new tests ran and passed: stale_staging_files_are_swept.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
**@⁠futurepro62** on GitHub · 2026-11-26 01:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/2510#issuecomment-7179490772) Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head `1b6a079` (on its base `67e8ae1`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **774 passed, 0 failed, 9 ignored**. - The new tests ran and passed: `stale_staging_files_are_swept`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 18:42 UTC · original · approved these changes

Reviewed and verified 1b6a0795161ead0e1b6bd5f87b4a32d8ce6b6947 merged onto main (63bcca43) on Windows 11 x64 (cargo test -p xtask --locked policy::tests::repository_passes_policy: 1 passed, 191 files ok; cargo clippy --locked -p victory-gpu --all-targets -- -D warnings: clean; cargo test --locked -p victory-gpu --lib pipeline::library::: 12 passed, 0 failed, including stale_staging_files_are_swept).

sweep_staging and staging_pid (crates/victory-gpu/src/pipeline/library.rs:59-87) cleanly restrict cleanup to immediate regular <cache-file>.tmp-<pid>-<n> staging files and ignore locked-file/directory errors so live reads and saves continue unaffected.

Two minor non-blocking notes:

  • use_pipeline_cache (library.rs:46-49) runs sweep_staging before DIR.set(dir); guarding the sweep with DIR.get().is_none() would ensure a repeated call cannot sweep an active staging file of the current pid without waiting STAGING_KEPT.
  • rustfmt --edition 2024 --check flags the single-line else { return }; and else { continue }; at library.rs:60, 63.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 18:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2510#pullrequestreview-6079109521) · **approved these changes** Reviewed and verified `1b6a0795161ead0e1b6bd5f87b4a32d8ce6b6947` merged onto `main` (`63bcca43`) on Windows 11 x64 (`cargo test -p xtask --locked policy::tests::repository_passes_policy`: `1 passed`, `191 files ok`; `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings`: clean; `cargo test --locked -p victory-gpu --lib pipeline::library::`: `12 passed, 0 failed`, including `stale_staging_files_are_swept`). `sweep_staging` and `staging_pid` (`crates/victory-gpu/src/pipeline/library.rs:59-87`) cleanly restrict cleanup to immediate regular `<cache-file>.tmp-<pid>-<n>` staging files and ignore locked-file/directory errors so live reads and saves continue unaffected. Two minor non-blocking notes: - `use_pipeline_cache` (`library.rs:46-49`) runs `sweep_staging` before `DIR.set(dir)`; guarding the sweep with `DIR.get().is_none()` would ensure a repeated call cannot sweep an active staging file of the current `pid` without waiting `STAGING_KEPT`. - `rustfmt --edition 2024 --check` flags the single-line `else { return };` and `else { continue };` at `library.rs:60, 63`.
Author
Owner

@⁠Ingenioeren on GitHub · 2026-11-26 18:48 UTC · original

Thanks for the review. Commit c5d6577 moves the staging sweep inside DIR.get_or_init. Only the winning initializer sweeps, and the cache path is published after it finishes. I also expanded the new single-line let else statements.

A Windows temp-directory probe reproduced the reported behavior on the previous head. A second initialization removed a same-process staging file. With this change, the initial sweep still removed the cut write, and both a live staging file and a file in a later ignored directory survived. All 12 pipeline-library tests passed with the PR applied to 63bcca4. Clippy with warnings denied and the staged asset policy passed.

AI-assisted verification with OpenAI Codex.

**@⁠Ingenioeren** on GitHub · 2026-11-26 18:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2510#issuecomment-7200874046) Thanks for the review. Commit `c5d6577` moves the staging sweep inside `DIR.get_or_init`. Only the winning initializer sweeps, and the cache path is published after it finishes. I also expanded the new single-line `let else` statements. A Windows temp-directory probe reproduced the reported behavior on the previous head. A second initialization removed a same-process staging file. With this change, the initial sweep still removed the cut write, and both a live staging file and a file in a later ignored directory survived. All 12 pipeline-library tests passed with the PR applied to `63bcca4`. Clippy with warnings denied and the staged asset policy passed. AI-assisted verification with OpenAI Codex.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 18:50 UTC · original · approved these changes

LGTM — verified on Windows against origin/main (63bcca4).

  • Sweeping <file>.tmp-<pid>-<n> regular staging files for the three pipeline cache files (immediately for the current PID, after 10 minutes for other PIDs) cleans up leftovers from interrupted atomic writes without risking active writers or unrelated files/directories.
  • cargo test -p victory-gpu --lib pipeline::library:: -- --test-threads=1: 12 passed, 0 failed (including stale_staging_files_are_swept).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 18:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2510#pullrequestreview-6079174064) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Sweeping `<file>.tmp-<pid>-<n>` regular staging files for the three pipeline cache files (immediately for the current PID, after 10 minutes for other PIDs) cleans up leftovers from interrupted atomic writes without risking active writers or unrelated files/directories. - `cargo test -p victory-gpu --lib pipeline::library:: -- --test-threads=1`: 12 passed, 0 failed (including `stale_staging_files_are_swept`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2510/head:github-bot/gh-2510'
git switch 'github-bot/gh-2510'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2510'
git switch 'github-bot/gh-2510'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2510'
git switch 'github-bot/gh-2510'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2510'
git switch 'main'
git merge --squash 'github-bot/gh-2510'
git switch 'main'
git merge --ff-only 'github-bot/gh-2510'
git switch 'main'
git merge 'github-bot/gh-2510'
git push origin 'main'
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!2510
No description provided.