Skip to content

GPU: a save that fails gives its changes back for the next one - #2327

Open
denkencar-sketch wants to merge 1 commit into
Marvisak:mainfrom
denkencar-sketch:fix/plib-003
Open

denkencar-sketch wants to merge 1 commit into
Marvisak:mainfrom
denkencar-sketch:fix/plib-003

Conversation

@denkencar-sketch

@denkencar-sketch denkencar-sketch commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

save() cleared the dirty marks before the library was serialised and written, so a save that failed at shutdown left nothing to save next time. The marks are now taken, and given back when the save fails. Open PR #2232 restores only prebuilt_changed; this restores the added count, prebuilt_changed and USED_CHANGED.

Testing

Test a_failed_save_leaves_its_changes_to_the_next fails if the restore drops the added count and passes with this change. It tests Dirty take and restore, not the Err arms of save().

cargo test --workspace --locked passes apart from known flakes: modules::dstorage::tests::a_page_list_filled_after_its_request_starts fails now and then on main too, and so does a parallel-run flake in victory-gpu's lib tests (watch:: and descriptor::host:: tests, 2 of 40 runs on pristine main).

A save that keeps failing now retries every 20 s with a warning each time. It touches save() like #2326 and #2328 do and conflicts with them only in adjacent test blocks in library.rs. Not tried: a run in the game.

AI-assisted.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

I tested both list writes through library::save(true) on Windows/WARP at 940d32f and your exact head 2ba6697. Each case runs in a fresh process. I blocked prebuilt-pipelines.txt in one case and early-pipelines.txt in the other by making the destination a directory. After the library blob was written, I removed the directory and called save(true) again without recording another key.

  • 940d32f left both files missing after the retry. The early case had only a used key pending.
  • 2ba6697 recovered both keys. The prebuilt list also matched the tag for the saved library blob.

The test-only commit a4b65ac is available directly on your head. The library suite passed 10 tests. The full GPU suite on app-local WARP passed 148 project tests with 2 ignored, and strict GPU Clippy and the staged asset check passed. This confirms the failure path from #2232 and also covers an early-list-only retry. If you fold the test into your commit, please add Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A save that fails gives its changes back for the next one (Dirty::take reset on error). 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; atomic-ish retry semantics look right.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090:

  • Restoring dirty flags when a pipeline library save fails ensures pending changes are not lost for the next save.
  • cargo test -p victory-gpu pipeline::library::tests: 9/9 passed (including a_failed_save_leaves_its_changes_to_the_next).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Verdict: merge candidate. Rebased at e4edac7, which merges cleanly into main. In save() (crates/victory-gpu/src/pipeline/library.rs) the dirty marks (added, prebuilt_changed, USED_CHANGED) are now taken into a Dirty value and restored on each failure path: no buffer, Serialize error, and a failed file write (the lock is taken again for that). On main the marks are cleared before the write, and USED_CHANGED is cleared even when the no-memory path returns early, so a failed periodic save loses its changes until something else changes. restore adds to marks set meanwhile rather than overwriting them, which is right. The test covers Dirty::take/restore only, as the PR body says. The fix only helps the periodic saves; a failed final save at shutdown has no later save to retry.

For the maintainer: #2232 has since been closed, and #2328 (one save at a time) also touches save(), so whichever lands second will need a small rebase.

CI: passing (check).


Generated by Claude Code

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

I ported your change across the current pipeline/library.rs conflict. The handoff branch has your original Git author on 0323bc9 and the two-file fixture on 3969fc7. The port keeps the separate load handle, the ordered early list, and the fallible serialization buffer. An allocation failure now restores the same pending marks as a serialization or file write failure.

On app-local WARP, the same fixture left both cache list files missing after the second save on f3578e3. At 3969fc7, both files were recovered without recording another key, and the prebuilt list matched the serialized library's tag. The GPU suite passed 245 tests with one ignored. Strict GPU Clippy in both configurations and the asset policy passed. The tested branch is based on f3578e3 and also merges cleanly with the newer 219878a.

You can cherry-pick the two commits in that order. Please retain the Git authors. If you fold the fixture into the fix, please include Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com>.

The marks were cleared before the library was serialised and written, so a
failure at shutdown left nothing to save.
@pawrenity

Copy link
Copy Markdown

For triage: on main 63bcca4, pipeline/library.rs save() still clears added / prebuilt_changed in the Ok(bytes) arm, before the files are written, and clears USED_CHANGED in the "anything to save?" check. The Err arm only warns. So a failed write loses those changes until something else marks the library dirty, as this PR describes. #72 fixes the same thing for added and USED_CHANGED, but it predates the prebuilt list and does not cover prebuilt_changed. This PR covers all three flags and the serialise and allocation failure paths, so #72 looks superseded by it. This is from reading the code; I did not run either PR.

AI-assisted (Claude Code).

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

@denkencar-sketch I moved the end-to-end retry probe to your current e4edac7. 226b59c is a single test-only commit on that exact head.

The fixture blocks each list file in a fresh process, calls production save(true), removes the block and calls save(true) again without recording another key. On 63bcca43, both prebuilt-pipelines.txt and early-pipelines.txt were still missing after the retry. On your head, both were recovered. The test also verifies that the prebuilt list has the tag of the saved D3D12 library.

App-local WARP passed all 13 library tests on your head with the probe. Strict all-feature GPU Clippy passed. If you take the test, please retain its Git author, or add Co-authored-by: andrewpozdnakov7-jpg <andrewpozdnakov7-jpg@users.noreply.github.com> if folding it into another commit. AI-assisted with Codex.

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dirty::take and Dirty::restore (crates/victory-gpu/src/pipeline/library.rs:317-405) preserve concurrent increments accurately across OOM (try_reserve_exact), D3D12 Serialize, and filesystem error paths without losing newer USED_CHANGED, added, or prebuilt_changed updates.

Non-blocking follow-up / coordination notes:

  • As on main, LAST (L306-316) only guards the throttle timestamp rather than serializing the full save through file publication, and an EARLY_FILE error skips PREBUILT_FILE via .and_then; #2803 addresses full-save serialization and independent EARLY_FILE handling, so keeping both semantics together when reconciling #2327 / #2803 / #2129 will cover all save paths cleanly.
  • Minor formatting nit: rustfmt --check flags the new lines at library.rs:386 and library.rs:579 (>100 columns).

Local verification at e4edac7d (and cleanly merged onto origin/main at a610d5f5): xtask policy (191 files ok), cargo clippy -p victory-gpu --all-targets (default and --all-features, 0 warnings), and pipeline::library under VICTORY_D3D12_DEBUG=1 passed on both RTX 5090 (12/12) and WARP (12/12). Approving.

BastienRodz added a commit to BastienRodz/VIctory that referenced this pull request Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants