GPU: save early pipeline list without re-serialising the library #3179

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/3181 into main
fuzeofficlal commented 2026-11-26 11:21:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T11:21:27Z.


Summary

pipeline::library::save previously checked l.added == 0 && !l.prebuilt_changed && !USED_CHANGED.swap(false, Ordering::Relaxed) under library.state, and then unconditionally called GetSerializedSize(), allocated a buffer, called ID3D12PipelineLibrary1::Serialize(), and rewrote host-pipelines.bin even when added == 0 and only early-pipelines.txt (USED_CHANGED) had changed. In addition, if zeroed(size) or Serialize() failed and returned early, USED_CHANGED had already been cleared so the early-pipelines.txt update was lost.

Fix

  • Check l.added > 0 || l.prebuilt_changed and release library.state before calling a helper save_files.
  • Handle USED_CHANGED independently by writing early-pipelines.txt without serializing or rewriting host-pipelines.bin when the library itself has no new pipelines; restore USED_CHANGED = true if creating the directory or writing early-pipelines.txt fails so a later save retries.
  • Only lock and serialize the host pipeline library when library_changed is true, keeping early-pipelines.txt intact even if serialization fails or runs out of memory.

Verification

Added three deterministic unit tests in crates/victory-gpu/src/pipeline/library.rs:

  • saving_only_the_early_list_skips_the_library
  • saving_the_early_list_survives_failed_serialization
  • saving_the_early_list_retries_after_an_io_error

Ran:

  • cargo test --locked -p victory-gpu pipeline::library -- --test-threads=1: 14 passed, 0 failed
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default and --no-default-features): clean
  • cargo test -p xtask --locked policy::tests::repository_passes_policy: passed
<!-- greyfinch-sync:Marvisak/VIctory:issue:5509101452 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3181). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T11:21:27Z. --- ### Summary `pipeline::library::save` previously checked `l.added == 0 && !l.prebuilt_changed && !USED_CHANGED.swap(false, Ordering::Relaxed)` under `library.state`, and then unconditionally called `GetSerializedSize()`, allocated a buffer, called `ID3D12PipelineLibrary1::Serialize()`, and rewrote `host-pipelines.bin` even when `added == 0` and only `early-pipelines.txt` (`USED_CHANGED`) had changed. In addition, if `zeroed(size)` or `Serialize()` failed and returned early, `USED_CHANGED` had already been cleared so the `early-pipelines.txt` update was lost. ### Fix - Check `l.added > 0 || l.prebuilt_changed` and release `library.state` before calling a helper `save_files`. - Handle `USED_CHANGED` independently by writing `early-pipelines.txt` without serializing or rewriting `host-pipelines.bin` when the library itself has no new pipelines; restore `USED_CHANGED = true` if creating the directory or writing `early-pipelines.txt` fails so a later save retries. - Only lock and serialize the host pipeline library when `library_changed` is true, keeping `early-pipelines.txt` intact even if serialization fails or runs out of memory. ### Verification Added three deterministic unit tests in `crates/victory-gpu/src/pipeline/library.rs`: - `saving_only_the_early_list_skips_the_library` - `saving_the_early_list_survives_failed_serialization` - `saving_the_early_list_retries_after_an_io_error` Ran: - `cargo test --locked -p victory-gpu pipeline::library -- --test-threads=1`: 14 passed, 0 failed - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` (default and `--no-default-features`): clean - `cargo test -p xtask --locked policy::tests::repository_passes_policy`: passed
Dukestar69 commented 2026-11-26 11:26:59 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T11:26:59Z.

Review: APPROVED


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

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

Cleanly saves the early pipeline list independently without re-serializing the full pipeline library.

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

<!-- greyfinch-sync:Marvisak/VIctory:review:6073343889 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3181#pullrequestreview-6073343889). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T11:26:59Z. **Review:** APPROVED --- Verified on RTX 5090 against `origin/main` (`63bcca4`): - `cargo test -p victory-gpu --lib pipeline::library:: -- --test-threads=1`: 14/14 passed (including `saving_only_the_early_list_skips_the_library`, `saving_the_early_list_retries_after_an_io_error`, and `saving_the_early_list_survives_failed_serialization`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Cleanly saves the early pipeline list independently without re-serializing the full pipeline library. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
steven-seagull27 commented 2026-11-26 12:06:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-26T12:05:02Z.


Confirmed 8a216f5 across fresh processes on the RTX 5080 and Windows inbox WARP. An early-list-only save left the compiled binary untouched on both. When I held the early list open during a full save and released it before the retry, the next process recognized all 3/3 prebuilt keys, loaded all three PSOs from the disk cache and read back 96/96 correct words. Repeated twice per adapter.

Writing the early list independently makes a measurable difference here: the overlapping #3188 head loses all three prebuilt keys under the same one-time sharing violation. Four-revision comparison and reusable restart test

<!-- greyfinch-sync:Marvisak/VIctory:comment:7191544345 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3181#issuecomment-7191544345). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-26T12:05:02Z. --- Confirmed `8a216f5` across fresh processes on the RTX 5080 and Windows inbox WARP. An early-list-only save left the compiled binary untouched on both. When I held the early list open during a full save and released it before the retry, the next process recognized all **3/3 prebuilt keys**, loaded all three PSOs from the disk cache and read back **96/96 correct words**. Repeated twice per adapter. Writing the early list independently makes a measurable difference here: the overlapping #3188 head loses all three prebuilt keys under the same one-time sharing violation. [Four-revision comparison and reusable restart test](https://github.com/Marvisak/VIctory/pull/3188#issuecomment-7191538577)
andrewpozdnakov7-jpg commented 2026-11-28 14:59:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T14:59:45Z.


I combined your exact 8a216f5 with #3751 at 948e7b3 in ae4cb99. Both heads are direct parents. The merge routes the no-library fallback through your save_files helper, with the library-change argument false. Your helper also handles the retry after an early-list write fails.

All 15 pipeline-library tests passed on Windows with WARP 1.0.22 and Agility 1.620.2. That includes your three independent-save tests and the new two-process test. The new test simulates an unavailable native library, retries after an I/O failure, and checks that both keys are recognized in a fresh process. Both strict GPU Clippy configurations and the asset policy also passed.

The combined commit is available for merge coordination. Please retain the Git authors on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding my change into another commit.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7241108585 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3181#issuecomment-7241108585). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T14:59:45Z. --- I combined your exact `8a216f5` with #3751 at `948e7b3` in [`ae4cb99`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/ae4cb996bcada304a962a2375bcc9f1cc41b8512). Both heads are direct parents. The merge routes the no-library fallback through your `save_files` helper, with the library-change argument false. Your helper also handles the retry after an early-list write fails. All 15 pipeline-library tests passed on Windows with WARP 1.0.22 and Agility 1.620.2. That includes your three independent-save tests and the new two-process test. The new test simulates an unavailable native library, retries after an I/O failure, and checks that both keys are recognized in a fresh process. Both strict GPU Clippy configurations and the asset policy also passed. The combined commit is available for merge coordination. Please retain the Git authors on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding my change into another commit. AI-assisted with OpenAI Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3181:upstream-pr/3181'
git switch 'upstream-pr/3181'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3181'
git switch 'upstream-pr/3181'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3181'
git switch 'upstream-pr/3181'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3181'
git switch 'main'
git merge --squash 'upstream-pr/3181'
git switch 'main'
git merge --ff-only 'upstream-pr/3181'
git switch 'main'
git merge 'upstream-pr/3181'
git push origin 'main'
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!3179
No description provided.