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

Open
github-bot wants to merge 1 commit from github-bot/gh-2327 into main AGit
Owner

@⁠denkencar-sketch on GitHub · 2026-11-25 10:42 UTC · original
denkencar-sketch:fix/plib-003 → main · +56 −8 · 1 files · 1 commits · open

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.

**@⁠denkencar-sketch** on GitHub · 2026-11-25 10:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2327) `denkencar-sketch:fix/plib-003` → `main` · +56 −8 · 1 files · 1 commits · open ## 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.
The marks were cleared before the library was serialised and written, so a
failure at shutdown left nothing to save.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:25 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 10:48 UTC · original

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 <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 10:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2327#issuecomment-7160209287) 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`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/a4b65aca9ac4ef8005278c38c2802053be0718ba) 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 <[email protected]>`.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:20 UTC · original · edited 2026-11-26 03:24 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 15:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2327#issuecomment-7166698875) · edited 2026-11-26 03:24 UTC <!-- victory-triage v1 head=e4edac7d31048d1fb6b13b2b7b7db34b45e1d38c verdict=merge-candidate at=2026-11-26T03:24:01Z --> 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](https://claude.ai/code)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-25 22:43 UTC · original

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 <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 22:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/2327#issuecomment-7176719521) I ported your change across the current `pipeline/library.rs` conflict. The [handoff branch](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/codex2/rebase-2327) has your original Git author on [`0323bc9`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/0323bc932d3145dcc7b2789ebb39bbbe186ebacd) and the two-file fixture on [`3969fc7`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/3969fc7190116ecd141c6bb14b9e44921ec0a061). 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 <[email protected]>`.
Author
Owner

@⁠pawrenity on GitHub · 2026-11-26 04:33 UTC · original

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).

**@⁠pawrenity** on GitHub · 2026-11-26 04:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2327#issuecomment-7182700476) 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).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 10:54 UTC · original · reviewed

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.

**@⁠catminou4** on GitHub · 2026-11-25 10:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/2327#pullrequestreview-6056244975) · **reviewed** 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.
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 11:42 UTC · original · approved these changes

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).

**@⁠DenRakEiw** on GitHub · 2026-11-25 11:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2327#pullrequestreview-6056966920) · **approved these changes** 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).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 13:31 UTC · original

@⁠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 <[email protected]> if folding it into another commit. AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 13:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2327#issuecomment-7193474669) @⁠denkencar-sketch I moved the end-to-end retry probe to your current `e4edac7`. [`226b59c`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/226b59c17a3628e1afb888ffe79cebb678b318e0) 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 <[email protected]>` if folding it into another commit. AI-assisted with Codex.
Author
Owner

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

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 14:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2327#pullrequestreview-6076046323) · **approved these changes** `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.
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/2327/head:github-bot/gh-2327'
git switch 'github-bot/gh-2327'

Merge

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