GPU: sweep cut pipeline-cache staging files #2510
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2510
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2510"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Ingenioeren on GitHub · 2026-11-25 15:03 UTC · original
Ingenioeren:fix/2496-pipeline-staging-sweep→main· +91 −1 · 1 files · 2 commits · openWhat
use_pipeline_cache()incrates/victory-gpu/src/pipeline/library.rsnow 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 andhost_gpu_failedexits 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
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.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
@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): thesave()lock that duplicated #2328 is gone. The PR is now only the staging-file sweep incrates/victory-gpu/src/pipeline/library.rs. At startup,use_pipeline_cachecallssweep_staging, which removes leftover temporary files from interrupted cache writes.<cache file>.tmp-<pid>-<n>, matching the nameswrite_atomicallycreates in main.staging_pidrequires both numbers to be all digits.stale_staging_files_are_sweptcovers the name matching, the age rule and the directory case.tempfileis 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:
checkpassing.Generated by Claude Code
@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 currentmain(1b6a079). I also changed "Fixes #2496" to "Part of #2496" and added a note to the description comparing this with #2129.@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 base67e8ae1).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo 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.stale_staging_files_are_swept.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#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_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
@fuzeofficlal on GitHub · 2026-11-26 18:42 UTC · original · approved these changes
Reviewed and verified
1b6a0795161ead0e1b6bd5f87b4a32d8ce6b6947merged ontomain(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, includingstale_staging_files_are_swept).sweep_stagingandstaging_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) runssweep_stagingbeforeDIR.set(dir); guarding the sweep withDIR.get().is_none()would ensure a repeated call cannot sweep an active staging file of the currentpidwithout waitingSTAGING_KEPT.rustfmt --edition 2024 --checkflags the single-lineelse { return };andelse { continue };atlibrary.rs:60, 63.@Ingenioeren on GitHub · 2026-11-26 18:48 UTC · original
Thanks for the review. Commit
c5d6577moves the staging sweep insideDIR.get_or_init. Only the winning initializer sweeps, and the cache path is published after it finishes. I also expanded the new single-linelet elsestatements.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.
@Dukestar69 on GitHub · 2026-11-26 18:50 UTC · original · approved these changes
LGTM — verified on Windows against
origin/main(63bcca4).<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 (includingstale_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).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.