Pipeline library: stores go on during a save, and the library is rebuilt past 1 GB #919

Open
0xkn0wh3r3 wants to merge 0 commits from upstream-pr/919 into main
0xkn0wh3r3 commented 2026-11-28 09:05:54 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by 0xkn0wh3r3 on 2026-11-28T09:05:54Z.


Why

The host pipeline library (ID3D12PipelineLibrary1) only grows. It has no way to take a pipeline out, and every change of a translation stores its pipelines under new names beside the old ones. On an RTX 5070 Ti (16 GB) after some weeks of play the library held 80,703 pipelines in 4.78 GB, of which a run loaded about 1,000.

Every save serialises the whole library. So:

  • every 20 s while any pipeline came in, a save wrote 4.78 GB again, beside the title's own streaming;
  • every pipeline made during a save waited for the save to end before it was stored and handed to the draws that wanted it.

What

Three commits:

  1. Stores go on during a save. A pipeline made while a save holds the library is used at once and stored after the save (VICTORY_LIBRARY_STORE_LATER=0: as before).
  2. Saves of a large library come less often. A save waits 20 s up to 256 MB, and as much longer as the library is larger: about 6 minutes at 4.78 GB. The save at the end of a run is not held back (VICTORY_LIBRARY_SAVE_S=20: as before). This overlaps #81, which spaces saves out during bursts of new pipelines and under memory pressure; the two can live together, or this part can go if #81 lands first.
  3. The library is rebuilt at the end of a run once it passes 1 GB (VICTORY_LIBRARY_KEEP_MB, default 1024; 0: never). The pipelines the run loaded or made are written into a fresh library, which replaces the file. A run that used fewer than 1,000 pipelines (one that ended at the menu) leaves the library alone, so it does not lose the world's pipelines. victory preload still saves the whole library and never rebuilds. The early list still names the title's other pipelines, so the next run starts them early, as before. Those no longer in the library are compiled then, which the driver's own disk cache makes quick where it holds them.

The rebuild line also counts names that came again and pipelines the new library refused.

Before / after

At the end of a play run on that RTX 5070 Ti:

host pipeline library rebuilt with the pipelines this run used before=4782276762 after=25170136 kept=928

4.78 GB to 25 MB. That run had loaded 1,199 pipelines and made 1,394, and that line could not say why only 928 were kept. It also predates the last commit, which counts repeated names (a pipeline the title makes twice is loaded twice) and refused stores, so the next log will say.

Correctness

  • a_rebuilt_library_holds_the_pipelines_it_was_given (needs a GPU): a library rebuilt from a list that names one pipeline twice holds it once, refuses it a second time, and opens again from its serialised bytes.
  • only_large_libraries_of_runs_that_reached_the_world_are_rebuilt, saves_of_large_libraries_wait_longer: the thresholds.
  • Tried in play: the run above had the first two commits in; the rebuild ran at its end, and the log has no errors from the library. The log does not show whether a store landed during a save.
  • Not verified: the first launch after a rebuild (how much more compiling it does where the driver cache lacks a pipeline).
  • cargo test --workspace --locked --no-fail-fast: every crate passes, 0 failures (victory-gpu: 456 passed). modules::dstorage::tests::a_read_into_memory_guarded_for_a_moment_is_tried_again (victory-hle, untouched here) failed once in an earlier run, then passed in this one and three runs on its own.
  • cargo clippy --workspace --all-targets --locked -- -D warnings stops at two findings that fail on main already (shadow.rs:1708 manual_is_multiple_of, victory-shader/src/emit/mod.rs:2768 let_and_return; #630 fixes them), and with --all-features at a third (descriptor.rs:1234 manual_is_multiple_of). It reports nothing in the files this PR changes.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5538573831 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/919). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-28T09:05:54Z. --- ## Why The host pipeline library (`ID3D12PipelineLibrary1`) only grows. It has no way to take a pipeline out, and every change of a translation stores its pipelines under new names beside the old ones. On an RTX 5070 Ti (16 GB) after some weeks of play the library held **80,703 pipelines in 4.78 GB**, of which a run loaded about 1,000. Every save serialises the whole library. So: - every 20 s while any pipeline came in, a save wrote 4.78 GB again, beside the title's own streaming; - every pipeline made during a save waited for the save to end before it was stored and handed to the draws that wanted it. ## What Three commits: 1. **Stores go on during a save.** A pipeline made while a save holds the library is used at once and stored after the save (`VICTORY_LIBRARY_STORE_LATER=0`: as before). 2. **Saves of a large library come less often.** A save waits 20 s up to 256 MB, and as much longer as the library is larger: about 6 minutes at 4.78 GB. The save at the end of a run is not held back (`VICTORY_LIBRARY_SAVE_S=20`: as before). This overlaps #81, which spaces saves out during bursts of new pipelines and under memory pressure; the two can live together, or this part can go if #81 lands first. 3. **The library is rebuilt at the end of a run once it passes 1 GB** (`VICTORY_LIBRARY_KEEP_MB`, default 1024; `0`: never). The pipelines the run loaded or made are written into a fresh library, which replaces the file. A run that used fewer than 1,000 pipelines (one that ended at the menu) leaves the library alone, so it does not lose the world's pipelines. `victory preload` still saves the whole library and never rebuilds. The early list still names the title's other pipelines, so the next run starts them early, as before. Those no longer in the library are compiled then, which the driver's own disk cache makes quick where it holds them. The rebuild line also counts names that came again and pipelines the new library refused. ## Before / after At the end of a play run on that RTX 5070 Ti: ``` host pipeline library rebuilt with the pipelines this run used before=4782276762 after=25170136 kept=928 ``` 4.78 GB to 25 MB. That run had loaded 1,199 pipelines and made 1,394, and that line could not say why only 928 were kept. It also predates the last commit, which counts repeated names (a pipeline the title makes twice is loaded twice) and refused stores, so the next log will say. ## Correctness - `a_rebuilt_library_holds_the_pipelines_it_was_given` (needs a GPU): a library rebuilt from a list that names one pipeline twice holds it once, refuses it a second time, and opens again from its serialised bytes. - `only_large_libraries_of_runs_that_reached_the_world_are_rebuilt`, `saves_of_large_libraries_wait_longer`: the thresholds. - Tried in play: the run above had the first two commits in; the rebuild ran at its end, and the log has no errors from the library. The log does not show whether a store landed during a save. - Not verified: the first launch after a rebuild (how much more compiling it does where the driver cache lacks a pipeline). - `cargo test --workspace --locked --no-fail-fast`: every crate passes, 0 failures (`victory-gpu`: 456 passed). `modules::dstorage::tests::a_read_into_memory_guarded_for_a_moment_is_tried_again` (`victory-hle`, untouched here) failed once in an earlier run, then passed in this one and three runs on its own. - `cargo clippy --workspace --all-targets --locked -- -D warnings` stops at two findings that fail on `main` already (`shadow.rs:1708` `manual_is_multiple_of`, `victory-shader/src/emit/mod.rs:2768` `let_and_return`; #630 fixes them), and with `--all-features` at a third (`descriptor.rs:1234` `manual_is_multiple_of`). It reports nothing in the files this PR changes.
Dukestar69 commented 2026-11-28 09:21:32 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Dukestar69 on 2026-11-28T09:21:32Z.

Review: APPROVED


Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge; cargo xtask policy passed (294 files ok).
  • Tests (RTX 5090): cargo test -p victory-gpu --lib pipeline:: passed (28 passed; 0 failed, including only_large_libraries_of_runs_that_reached_the_world_are_rebuilt, saves_of_large_libraries_wait_longer, a_rebuilt_library_holds_the_pipelines_it_was_given, and concurrent_write_atomically_never_fails_or_truncates) with 0 compiler warnings.

Great pipeline-library scaling and non-blocking save/rebuild behavior past 1 GB. LGTM.

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

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6096943524 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/919#pullrequestreview-6096943524). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-28T09:21:32Z. **Review:** APPROVED --- Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge; `cargo xtask policy` passed (`294 files ok`). - **Tests (RTX 5090)**: `cargo test -p victory-gpu --lib pipeline::` passed (`28 passed; 0 failed`, including `only_large_libraries_of_runs_that_reached_the_world_are_rebuilt`, `saves_of_large_libraries_wait_longer`, `a_rebuilt_library_holds_the_pipelines_it_was_given`, and `concurrent_write_atomically_never_fails_or_truncates`) with 0 compiler warnings. Great pipeline-library scaling and non-blocking save/rebuild behavior past 1 GB. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/919:upstream-pr/919'
git switch 'upstream-pr/919'

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/919'
git switch 'upstream-pr/919'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/919'
git switch 'upstream-pr/919'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/919'
git switch 'main'
git merge --squash 'upstream-pr/919'
git switch 'main'
git merge --ff-only 'upstream-pr/919'
git switch 'main'
git merge 'upstream-pr/919'
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
trustno1-coder/VIctory-NVIDIA!919
No description provided.