Repository navigation
GPU: pipeline library saves run one at a time - #2328
denkencar-sketch wants to merge 2 commits into
Conversation
catminou4
left a comment
There was a problem hiding this comment.
Pipeline library saves run one at a time (SAVING mutex, try_lock for periodic, blocking for shutdown). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Same cluster; prevents blob/prebuilt interleaving.
DenRakEiw
left a comment
There was a problem hiding this comment.
Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090:
- Serializing pipeline library saves while letting periodic saves skip when a save is already running avoids concurrent write races cleanly.
cargo test -p victory-gpu pipeline::library::tests: 10/10 passed (includinga_periodic_save_does_not_wait_for_the_save_runninganda_save_waits_for_the_save_running).cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.
AI-assisted (Gemini 4 Neon).
|
Automated triage for the maintainers. Verdict: merge candidate. Thanks for the rebase. At The race is real on CI: passing ( Generated by Claude Code |
Since Marvisak#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. The other half of Marvisak#2496 (an exit save that waits for a running one) is left to Marvisak#2328. Fixes Marvisak#2496 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since Marvisak#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 Marvisak#2496: its other half (an exit save that waits for a running one) is Marvisak#2328. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The worker's save and the shutdown's could interleave their files: an older blob over a newer, or beside another's prebuilt list.
The workers call it after every pipeline; waiting for the files of another save would stall them. Shutdown's save still waits.
be591e1 to
a662de9
Compare
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed a662de92591345f983324ffef25365d7b5bf8a46 (merged cleanly onto 63bcca43c6a00a758510398fa43096ce7e4f7df0) and verified on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, VICTORY_D3D12_DEBUG=1).
The SAVING guard covers the full save sequence (early list, prebuilt list, and library blob) with consistent lock ordering (SAVING -> LAST -> state -> USED -> WRITING), keeping periodic saves non-blocking on contention while shutdown waits for an active save to finish.
Non-blocking notes for coordination / follow-up:
#2803already extendsLASTwith the same blocking/try_lockpolicy over the save window (so if both land, keeping a single outer lock avoids stacking two save mutexes), and#2327handles dirty-state restoration if a file replacement fails after clearing marks.- Replacing the 300 ms sleep in
a_save_waits_for_the_save_runningwith an explicit synchronization point (keeping a timeout only as a watchdog) would make the concurrency tests immune to scheduler jitter.
Verification
cargo run -p xtask -- policy(191 files ok),cargo clippy(default &--all-features) clean, new linesrustfmt-clean.victory-gpupipeline::library::withVICTORY_D3D12_DEBUG=1: 13/13 passed on both RTX 5090 and WARP (at both PR head and merged onto63bcca43).
Summary
The worker's pipeline library save and the shutdown's could interleave their files: an older blob over a newer one, or beside another save's prebuilt list. Saves now run one at a time. A second commit makes the periodic save, which workers call after every pipeline, leave it to the save running instead of waiting (shutdown's save still waits).
Testing
Tests
a_save_waits_for_the_save_runninganda_periodic_save_does_not_wait_for_the_save_runningfail without the lock and withouttry_lockrespectively, and pass with this change. The wait in the first test is timing-based.cargo test --workspace --lockedpasses apart from known flakes:modules::dstorage::tests::a_page_list_filled_after_its_request_startsfails now and then onmaintoo, and so does a parallel-run flake invictory-gpu's lib tests (watch::anddescriptor::host::tests, 2 of 40 runs on pristinemain).A skipped periodic save leaves its dirty marks for the next save. It touches
save()like #2326 and #2327 do and conflicts with them only in adjacent test blocks inlibrary.rs. Not tried: a run in the game.AI-assisted.