GPU: skip host pipeline library serialisation when only early list changed #3188

Open
github-bot wants to merge 2 commits from github-bot/gh-3188 into main AGit
Owner

@⁠reeledMarek on GitHub · 2026-11-26 11:28 UTC · original
reeledMarek:fix/gpu-library-save-early-only → main · +142 −35 · 1 files · 2 commits · open

Summary

  • In crates/victory-gpu/src/pipeline/library.rs, save() allocated zeroed(size) (~1.7 GB on NVIDIA), held library.state while calling ID3D12PipelineLibrary1::Serialize, and atomically rewrote host-pipelines.bin even when l.added == 0 && !l.prebuilt_changed and only USED_CHANGED was set (e.g., every 20 seconds during warm runs as cached pipelines are first used).
  • Additionally, if zeroed(size) returned None (OOM) or Serialize failed, USED_CHANGED had already been cleared by swap(false) and was never restored, silently dropping updates to early-pipelines.txt.
  • Split save() via SaveKind::{None, EarlyOnly, Full}: when only USED_CHANGED is set, release the lock immediately and write only early-pipelines.txt; if library serialisation fails/OOMs, still write early-pipelines.txt when needed; and restore USED_CHANGED if writing early-pipelines.txt fails.

Testing

  • Added save_kind_skips_library_serialisation_when_only_early_list_changed and write_early_list_updates_only_early_file in crates/victory-gpu/src/pipeline/library.rs.
  • Verified cargo test -p xtask --locked passes.
**@⁠reeledMarek** on GitHub · 2026-11-26 11:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/3188) `reeledMarek:fix/gpu-library-save-early-only` → `main` · +142 −35 · 1 files · 2 commits · open ## Summary - In `crates/victory-gpu/src/pipeline/library.rs`, `save()` allocated `zeroed(size)` (~1.7 GB on NVIDIA), held `library.state` while calling `ID3D12PipelineLibrary1::Serialize`, and atomically rewrote `host-pipelines.bin` even when `l.added == 0 && !l.prebuilt_changed` and only `USED_CHANGED` was set (e.g., every 20 seconds during warm runs as cached pipelines are first used). - Additionally, if `zeroed(size)` returned `None` (OOM) or `Serialize` failed, `USED_CHANGED` had already been cleared by `swap(false)` and was never restored, silently dropping updates to `early-pipelines.txt`. - Split `save()` via `SaveKind::{None, EarlyOnly, Full}`: when only `USED_CHANGED` is set, release the lock immediately and write only `early-pipelines.txt`; if library serialisation fails/OOMs, still write `early-pipelines.txt` when needed; and restore `USED_CHANGED` if writing `early-pipelines.txt` fails. ## Testing - Added `save_kind_skips_library_serialisation_when_only_early_list_changed` and `write_early_list_updates_only_early_file` in `crates/victory-gpu/src/pipeline/library.rs`. - Verified `cargo test -p xtask --locked` passes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:33:19 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 11:48 UTC · original · approved these changes

Verified on RTX 5090 against origin/main (63bcca4):

  • cargo test -p victory-gpu --lib pipeline::library:: -- --test-threads=1: 13/13 passed (including save_kind_skips_library_serialisation_when_only_early_list_changed and write_early_list_updates_only_early_file).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Cleanly skips re-serializing the host pipeline library when only the early list changed.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 11:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/3188#pullrequestreview-6073619616) · **approved these changes** Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib pipeline::library:: -- --test-threads=1`: 13/13 passed (including `save_kind_skips_library_serialisation_when_only_early_list_changed` and `write_early_list_updates_only_early_file`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly skips re-serializing the host pipeline library when only the early list changed. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 12:04 UTC · original

Found a restart regression on d5b24d1 when early-pipelines.txt is temporarily busy during a full save. After the retry, the RTX 5080 and Windows inbox WARP both loaded and dispatched all three cached PSOs (96/96 output words correct), but the next pre-build recognized 0/3 pipeline keys. The same test recognizes 3/3 on the parent, on #3181, and with the small write-order fix below.

The test uses a fresh directory, seeds two real compute pipelines, then adds a third in a new process. A read handle on the early-list file blocks its replacement during one full save. It closes the handle, calls save(true) again, and starts another process. Two runs per adapter gave identical results.

Revision Binary left untouched on an early-list-only save Prebuilt keys after the one-time early-list error and retry
Parent 63bcca4 No 3/3
#3181 8a216f5 Yes 3/3
#3188 d5b24d1 Yes 0/3
#3188 + 5d8a276 Yes 3/3

With the file writable throughout, all four builds recovered 3/3 keys. With the file busy, this head installs the new binary, fails to replace the early list, and skips writing prebuilt-pipelines.txt. The retry repairs the early list. On restart the old manifest's tag no longer matches the binary, so even the two earlier keys are forgotten. Writing the matching manifest right after the binary lets the existing early-list retry handle its own failure.

The write-order fix can be cherry-picked on its own. The opt-in restart test is separate. To take both on this head:

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/cache-sidecar-restart
git cherry-pick 252655c10ecf8629f90749bddd1fedf3f132bc6c 5d8a276e49ea7becaff2e3f0fbdd7ec043c2ad1a
cargo test --locked -p victory-gpu --all-features --lib cache_manifest_survives_early_list_retry -- --ignored --nocapture --test-threads=1

Synthetic native D3D12 tests with the debug layer enabled. AI-assisted with Codex.

**@⁠steven-seagull27** on GitHub · 2026-11-26 12:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/3188#issuecomment-7191538577) Found a restart regression on `d5b24d1` when `early-pipelines.txt` is temporarily busy during a full save. After the retry, the RTX 5080 and Windows inbox WARP both loaded and dispatched **all three cached PSOs (96/96 output words correct)**, but the next pre-build recognized **0/3** pipeline keys. The same test recognizes **3/3** on the parent, on #3181, and with the small write-order fix below. The test uses a fresh directory, seeds two real compute pipelines, then adds a third in a new process. A read handle on the early-list file blocks its replacement during one full save. It closes the handle, calls `save(true)` again, and starts another process. Two runs per adapter gave identical results. | Revision | Binary left untouched on an early-list-only save | Prebuilt keys after the one-time early-list error and retry | |---|---|---:| | Parent `63bcca4` | No | 3/3 | | #3181 `8a216f5` | Yes | 3/3 | | #3188 `d5b24d1` | Yes | 0/3 | | #3188 + `5d8a276` | Yes | 3/3 | With the file writable throughout, all four builds recovered 3/3 keys. With the file busy, this head installs the new binary, fails to replace the early list, and skips writing `prebuilt-pipelines.txt`. The retry repairs the early list. On restart the old manifest's tag no longer matches the binary, so even the two earlier keys are forgotten. Writing the matching manifest right after the binary lets the existing early-list retry handle its own failure. The [write-order fix](https://github.com/steven-seagull27/VIctory/commit/5d8a276e49ea7becaff2e3f0fbdd7ec043c2ad1a) can be cherry-picked on its own. The [opt-in restart test](https://github.com/steven-seagull27/VIctory/commit/252655c10ecf8629f90749bddd1fedf3f132bc6c) is separate. To take both on this head: ```sh git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/cache-sidecar-restart git cherry-pick 252655c10ecf8629f90749bddd1fedf3f132bc6c 5d8a276e49ea7becaff2e3f0fbdd7ec043c2ad1a cargo test --locked -p victory-gpu --all-features --lib cache_manifest_survives_early_list_retry -- --ignored --nocapture --test-threads=1 ``` Synthetic native D3D12 tests with the debug layer enabled. AI-assisted with Codex.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-26 12:06 UTC · original

WARP verification of #3188 at d5b24d1f (base 63bcca4, origin/main). Software adapter only; synthetic tests only; no GPU, game files, dumps, shader names or hashes.

Environment: Windows 11 Pro 10.0.26200; WARP d3d10warp.dll 10.0.26100.9818 (VICTORY_D3D12_WARP=1); dxil.dll and dxc.exe 1.8.2502.11 from Windows SDK 10.0.26100.0 (VICTORY_DXIL set to that dxil.dll); CARGO_TARGET_DIR=D:\victory-3188-3192-warp-target; every cargo command used -j 4 --locked.

Commands and counts

  • cargo test -p victory-gpu --lib pipeline::library:: -- --test-threads=1: 13 passed, 0 failed, 0 ignored. Includes save_kind_skips_library_serialisation_when_only_early_list_changed and write_early_list_updates_only_early_file.
  • cargo test -p victory-gpu --lib -- --test-threads=1, head: 233 passed, 0 failed, 1 ignored.
  • Same command on base 63bcca4: 231 passed, 0 failed, 1 ignored (+2 = the two new tests).

Revert check: restoring the old behaviour in save_kind (the used_changed-only case returns Full instead of EarlyOnly, one line, rest of the PR kept) makes save_kind_skips_library_serialisation_when_only_early_list_changed fail (left: Full, right: EarlyOnly); the other 12 pass. A literal revert of the whole diff does not compile with the new tests, hence the one-line mutation.

Review: no defects found. Checked: a failed serialise or allocation still writes the early list (used_changed was already swapped out); early-write failure re-arms USED_CHANGED; on a full-save write failure USED_CHANGED is re-armed only if the early list was due; the prebuilt list is still tagged against the unchanged library bytes.

Coverage gaps

  • save() itself is untested (needs a live pipeline library). The tests cover only the pure save_kind table and write_early_list, so they do not prove that serialisation is skipped on the early-only path or that USED_CHANGED is restored after a failed write.
  • write_early_list_updates_only_early_file asserts only that no other files are created in an empty dir; it does not show an existing library file is left untouched.
  • Behaviour change worth knowing: on a full save whose serialise fails, the early list is now still written (previously nothing was).

AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5).

**@⁠oni-swr** on GitHub · 2026-11-26 12:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/3188#issuecomment-7191585094) **WARP verification of #3188 at `d5b24d1f`** (base `63bcca4`, `origin/main`). Software adapter only; synthetic tests only; no GPU, game files, dumps, shader names or hashes. **Environment:** Windows 11 Pro 10.0.26200; WARP `d3d10warp.dll` 10.0.26100.9818 (`VICTORY_D3D12_WARP=1`); `dxil.dll` and `dxc.exe` 1.8.2502.11 from Windows SDK 10.0.26100.0 (`VICTORY_DXIL` set to that dxil.dll); `CARGO_TARGET_DIR=D:\victory-3188-3192-warp-target`; every cargo command used `-j 4 --locked`. **Commands and counts** - `cargo test -p victory-gpu --lib pipeline::library:: -- --test-threads=1`: 13 passed, 0 failed, 0 ignored. Includes `save_kind_skips_library_serialisation_when_only_early_list_changed` and `write_early_list_updates_only_early_file`. - `cargo test -p victory-gpu --lib -- --test-threads=1`, head: **233 passed, 0 failed, 1 ignored**. - Same command on base `63bcca4`: **231 passed, 0 failed, 1 ignored** (+2 = the two new tests). **Revert check:** restoring the old behaviour in `save_kind` (the `used_changed`-only case returns `Full` instead of `EarlyOnly`, one line, rest of the PR kept) makes `save_kind_skips_library_serialisation_when_only_early_list_changed` fail (`left: Full, right: EarlyOnly`); the other 12 pass. A literal revert of the whole diff does not compile with the new tests, hence the one-line mutation. **Review: no defects found.** Checked: a failed serialise or allocation still writes the early list (`used_changed` was already swapped out); early-write failure re-arms `USED_CHANGED`; on a full-save write failure `USED_CHANGED` is re-armed only if the early list was due; the prebuilt list is still tagged against the unchanged library bytes. **Coverage gaps** - `save()` itself is untested (needs a live pipeline library). The tests cover only the pure `save_kind` table and `write_early_list`, so they do not prove that serialisation is skipped on the early-only path or that `USED_CHANGED` is restored after a failed write. - `write_early_list_updates_only_early_file` asserts only that no other files are created in an empty dir; it does not show an existing library file is left untouched. - Behaviour change worth knowing: on a full save whose serialise fails, the early list is now still written (previously nothing was). AI use: Claude Code (Claude Sonnet 5.5), coordinated by Claude Code (Claude Opus 5.5).
Author
Owner

@⁠reeledMarek on GitHub · 2026-11-26 15:20 UTC · original

Great catch @⁠steven-seagull27 — thanks for the thorough restart test on RTX 5080 and WARP!

Fixed in 90dee35: write_full_save() now writes prebuilt-pipelines.txt immediately after host-pipelines.bin and before early-pipelines.txt, so a transient failure replacing early-pipelines.txt leaves the library binary and prebuilt manifest tag in sync while the EarlyOnly retry updates early-pipelines.txt. Added a regression test write_full_save_updates_prebuilt_manifest_before_early_list covering this exact failure + retry sequence.

**@⁠reeledMarek** on GitHub · 2026-11-26 15:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/3188#issuecomment-7196120292) Great catch @⁠steven-seagull27 — thanks for the thorough restart test on RTX 5080 and WARP! Fixed in `90dee35`: `write_full_save()` now writes `prebuilt-pipelines.txt` immediately after `host-pipelines.bin` and before `early-pipelines.txt`, so a transient failure replacing `early-pipelines.txt` leaves the library binary and prebuilt manifest tag in sync while the `EarlyOnly` retry updates `early-pipelines.txt`. Added a regression test `write_full_save_updates_prebuilt_manifest_before_early_list` covering this exact failure + retry sequence.
This pull request can be merged automatically.
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/3188/head:github-bot/gh-3188'
git switch 'github-bot/gh-3188'

Merge

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