Retry failed pipeline cache saves #640

Closed
Fluxxer763664 wants to merge 1 commit from upstream-pr/640 into main
Fluxxer763664 commented 2026-11-24 06:04:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Fluxxer763664 on 2026-11-24T06:04:16Z.


This fix lets VIctory retry saving its pipeline cache after a failed write. The Windows GPU suite passed 46 tests, and the fix passed three simulated write-failure scenarios. No game files were used. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6575732557 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/640). Originally posted by [Fluxxer763664](https://github.com/Fluxxer763664) on 2026-11-24T06:04:16Z. --- This fix lets VIctory retry saving its pipeline cache after a failed write. The Windows GPU suite passed 46 tests, and the fix passed three simulated write-failure scenarios. No game files were used. AI-assisted.
LAKSHYA-cmd-tech commented 2026-11-24 06:54:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T06:13:40Z.

Review: APPROVED


Tested on Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc).

  • cargo test -p victory-gpu: all 43 unit tests passed cleanly (0 failed, 1 ignored benchmark).
  • cargo xtask policy: 151 files ok.
  • Verified atomic retention of l.added and restoration of USED_CHANGED on serialization/write failure to allow retries.
<!-- greyfinch-sync:Marvisak/VIctory:review:6034538121 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/640#pullrequestreview-6034538121). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T06:13:40Z. **Review:** APPROVED --- Tested on Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc). - cargo test -p victory-gpu: all 43 unit tests passed cleanly (0 failed, 1 ignored benchmark). - cargo xtask policy: 151 files ok. - Verified atomic retention of l.added and restoration of USED_CHANGED on serialization/write failure to allow retries.
mercuryVM commented 2026-11-24 12:04:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T11:09:54Z.

Review: COMMENTED


Tested 446fef9 on Windows 11, RTX 5070, MSVC: cargo test -p victory-gpu -- --test-threads=1 43 passed, and with --features diagnostics 45 passed. Clippy's 1 warning is the existing undocumented_unsafe_blocks in host.rs.

The retry logic is right. USED_CHANGED is restored on both failure paths, and added -= added keeps pipelines added during the write. Nothing else lowers added after creation, so the subtraction can't underflow. One concern before approving:

  • pipeline/library.rs (save): LAST is now held across Serialize and both write_atomically calls. save(false) is called from pipeline creation (make.rs:186, make.rs:218). Before, a second caller during a save saw the fresh timestamp and returned at once. Now it blocks on LAST until the whole serialize-and-write finishes, then returns. So pipeline creation threads stall for the length of a library write, which can be many MB. To keep the "no two saves share temp paths" guarantee without the stall, take the lock with LAST.try_lock() when !now and return on WouldBlock, or use a separate SAVING: Mutex<()> taken with try_lock for the write. Only save(true) (shutdown) should wait.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6038128325 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/640#pullrequestreview-6038128325). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T11:09:54Z. **Review:** COMMENTED --- Tested 446fef9 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-gpu -- --test-threads=1` 43 passed, and with `--features diagnostics` 45 passed. Clippy's 1 warning is the existing `undocumented_unsafe_blocks` in host.rs. The retry logic is right. `USED_CHANGED` is restored on both failure paths, and `added -= added` keeps pipelines added during the write. Nothing else lowers `added` after creation, so the subtraction can't underflow. One concern before approving: - `pipeline/library.rs` (`save`): `LAST` is now held across `Serialize` and both `write_atomically` calls. `save(false)` is called from pipeline creation (`make.rs:186`, `make.rs:218`). Before, a second caller during a save saw the fresh timestamp and returned at once. Now it blocks on `LAST` until the whole serialize-and-write finishes, then returns. So pipeline creation threads stall for the length of a library write, which can be many MB. To keep the "no two saves share temp paths" guarantee without the stall, take the lock with `LAST.try_lock()` when `!now` and return on `WouldBlock`, or use a separate `SAVING: Mutex<()>` taken with `try_lock` for the write. Only `save(true)` (shutdown) should wait. AI-assisted (Claude Code).
geiyiliyabumo commented 2026-11-24 12:04:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T11:41:19Z.


Independent verification & code review on Windows 11 Pro (build 26100) + AMD Radeon RX 9060 XT (RDNA4, driver 32.0.32029.2010, Rust 1.98.1), cleanly merged onto main (ffe310e):

  • cargo xtask policy: PASS (154 files ok)
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings: PASS
  • cargo clippy -p victory-gpu --all-targets --features diagnostics --locked -- -D warnings: PASS
  • cargo test -p victory-gpu --locked: 50 passed, 0 failed, 1 ignored

Diff review (crates/victory-gpu/src/pipeline/library.rs): clean and deadlock-free:

  • Holding LAST across both write_atomically calls prevents concurrent save() calls from racing on the shared .tmp filenames while keeping the lock order strictly LAST -> library / LAST -> USED (never acquiring LAST from inside either).
  • Subtracting added only on Ok(()) preserves both failed-save retry state and any pipelines stored concurrently during disk I/O, and restoring USED_CHANGED on serialize/write failure avoids silently dropping early-pipeline updates.
  • Note: PR #72 also targets retry-on-write-failure in library.rs, so maintainers may want to pick one of #640 or #72.

AI-assisted; synthetic tests only, no game files.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7130418587 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/640#issuecomment-7130418587). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T11:41:19Z. --- Independent verification & code review on Windows 11 Pro (build 26100) + AMD Radeon RX 9060 XT (RDNA4, driver `32.0.32029.2010`, Rust `1.98.1`), cleanly merged onto `main` (`ffe310e`): - `cargo xtask policy`: PASS (`154 files ok`) - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings`: PASS - `cargo clippy -p victory-gpu --all-targets --features diagnostics --locked -- -D warnings`: PASS - `cargo test -p victory-gpu --locked`: **50 passed, 0 failed, 1 ignored** Diff review (`crates/victory-gpu/src/pipeline/library.rs`): clean and deadlock-free: - Holding `LAST` across both `write_atomically` calls prevents concurrent `save()` calls from racing on the shared `.tmp` filenames while keeping the lock order strictly `LAST -> library` / `LAST -> USED` (never acquiring `LAST` from inside either). - Subtracting `added` only on `Ok(())` preserves both failed-save retry state and any pipelines stored concurrently during disk I/O, and restoring `USED_CHANGED` on serialize/write failure avoids silently dropping early-pipeline updates. - Note: PR #72 also targets retry-on-write-failure in `library.rs`, so maintainers may want to pick one of #640 or #72. *AI-assisted; synthetic tests only, no game files.*
upstream-sync closed this pull request 2026-11-25 01:04:35 +00:00
Marvisak commented 2026-11-25 01:07:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:26:41Z.


Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #72. Same retry-after-failed-save change as #72 without its unique temp files or tests.

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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148516002 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/640#issuecomment-7148516002). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:26:41Z. --- Automated triage for the maintainers. Closing because another open pull request covers the same change. See #72. Same retry-after-failed-save change as #72 without its unique temp files or tests. 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!640
No description provided.