Pipeline library: a run's end keeps a preload's library for the same translations #3895

Open
Trillazill wants to merge 1 commit from upstream-pr/3895 into main
Trillazill commented 2026-11-30 10:48:33 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Trillazill on 2026-11-30T10:48:33Z.


What this changes

pipeline::library::finish rebuilds the library from the pipelines the run used once it is over VICTORY_LIBRARY_KEEP_MB (1,024 MB) and the run used 1,000 or more. That is right for a library full of names of earlier translations: the RTX run in keep_bytes's comment had 80,703 pipelines, of which it loaded 986. It is wrong for a library a preload just filled. Every name in it is current, and one walk's rebuild threw away the places the walk did not visit. In #3883: 5,658 pipelines, 1,158 MB, rebuilt to 2,225 (164 MB). Those places then compiled again in play, at 566–1,023 ms a pipeline.

Now:

  • known::keep_library is what both victory preload paths call: the periodic save during the fill and the final one. After saving, it writes host-pipelines.preloaded beside the library, holding shader_cache::translation(). That is the hash of the translator's sources and of every switch that changes a translation, so it also decides the pipelines' names.
  • compact returns before rebuilding when that marker names the translations of this run, and says so: host pipeline library not rebuilt: a preload filled it for these translations.
  • After a translator change, the marker names other translations, and the library is rebuilt as before; the rebuild removes the marker. A preload run with other switches than play's (#3884) also has a different marker. In that case its pipelines aren't the ones play uses, and the rebuild goes ahead as well.

VICTORY_LIBRARY_KEEP_MB and COMPACT_LEAST are unchanged.

Tests

  • New: pipeline::library::tests::a_preloaded_library_is_kept_while_its_translations_are_current. It covers the same marker, a marker with a line ending, a changed translator, no marker, and an empty one.
  • cargo test -p victory-gpu --lib -- pipeline::library::: 14 pass.
  • Clippy (-p victory-gpu --lib --tests): nothing in the lines this change adds or touches.
  • cargo xtask policy --staged: ok (2 files).
  • In game (release build of this branch, RTX 4080, Series X), with VICTORY_LIBRARY_KEEP_MB=100 so that a 388 MB library is over the line:
    • victory play --preload: the preload put 2,856 of 2,856 pipelines in the library in 2.9 min and wrote the marker.
    • The game run then used 2,921 pipelines, past COMPACT_LEAST. At the end it logged host pipeline library not rebuilt: a preload filled it for these translations ... bytes=387625628 used=2921, and the file stayed at 387,625,628 bytes. Without the marker, compacts(387625628, 2921, 100 MB) is true, and the run would have rebuilt the library from its 2,921 pipelines.

No game data, logs or other files from the title are in this change.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5563746495 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3895). Originally posted by [Trillazill](https://github.com/Trillazill) on 2026-11-30T10:48:33Z. --- ## What this changes `pipeline::library::finish` rebuilds the library from the pipelines the run used once it is over `VICTORY_LIBRARY_KEEP_MB` (1,024 MB) and the run used 1,000 or more. That is right for a library full of names of earlier translations: the RTX run in `keep_bytes`'s comment had 80,703 pipelines, of which it loaded 986. It is wrong for a library a preload just filled. Every name in it is current, and one walk's rebuild threw away the places the walk did not visit. In #3883: 5,658 pipelines, 1,158 MB, rebuilt to 2,225 (164 MB). Those places then compiled again in play, at 566–1,023 ms a pipeline. Now: - `known::keep_library` is what both `victory preload` paths call: the periodic save during the fill and the final one. After saving, it writes `host-pipelines.preloaded` beside the library, holding `shader_cache::translation()`. That is the hash of the translator's sources and of every switch that changes a translation, so it also decides the pipelines' names. - `compact` returns before rebuilding when that marker names the translations of this run, and says so: `host pipeline library not rebuilt: a preload filled it for these translations`. - After a translator change, the marker names other translations, and the library is rebuilt as before; the rebuild removes the marker. A preload run with other switches than `play`'s (#3884) also has a different marker. In that case its pipelines aren't the ones play uses, and the rebuild goes ahead as well. `VICTORY_LIBRARY_KEEP_MB` and `COMPACT_LEAST` are unchanged. ## Tests - New: `pipeline::library::tests::a_preloaded_library_is_kept_while_its_translations_are_current`. It covers the same marker, a marker with a line ending, a changed translator, no marker, and an empty one. - `cargo test -p victory-gpu --lib -- pipeline::library::`: 14 pass. - Clippy (`-p victory-gpu --lib --tests`): nothing in the lines this change adds or touches. - `cargo xtask policy --staged`: ok (2 files). - In game (release build of this branch, RTX 4080, Series X), with `VICTORY_LIBRARY_KEEP_MB=100` so that a 388 MB library is over the line: - `victory play --preload`: the preload put 2,856 of 2,856 pipelines in the library in 2.9 min and wrote the marker. - The game run then used 2,921 pipelines, past `COMPACT_LEAST`. At the end it logged `host pipeline library not rebuilt: a preload filled it for these translations ... bytes=387625628 used=2921`, and the file stayed at 387,625,628 bytes. Without the marker, `compacts(387625628, 2921, 100 MB)` is true, and the run would have rebuilt the library from its 2,921 pipelines. No game data, logs or other files from the title are in this change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Trillazill commented 2026-12-01 06:21:44 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Trillazill on 2026-12-01T06:21:44Z.


Rebased onto main 5fabb46e. Conflict in library.rs: main moved the rebuild into compact_to_dir; the marker check sits before it, and the marker is removed after a written rebuild. Tests on the rebased branch: cargo test -p victory-gpu --lib -- pipeline::library:: 21 pass; cargo clippy -p victory-gpu --lib --tests no errors.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7302784395 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3895#issuecomment-7302784395). Originally posted by [Trillazill](https://github.com/Trillazill) on 2026-12-01T06:21:44Z. --- Rebased onto main 5fabb46e. Conflict in `library.rs`: main moved the rebuild into `compact_to_dir`; the marker check sits before it, and the marker is removed after a written rebuild. Tests on the rebased branch: `cargo test -p victory-gpu --lib -- pipeline::library::` 21 pass; `cargo clippy -p victory-gpu --lib --tests` no errors.
gut0to commented 2026-12-01 15:24:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by gut0to on 2026-12-01T15:24:14Z.

Code review location: crates/victory-gpu/src/pipeline/known.rs; line 532

@@ -525,9 +525,11 @@ pub fn use_library(shaders: PathBuf) {
     crate::shader_cache::use_shader_cache(shaders);
 }
 
-/// Writes the library [`use_library`] filled.
+/// Writes the library [`use_library`] filled, marked as a preload's for the
+/// translations of now: a run's end leaves it whole (#3883).
 pub fn keep_library() {
     super::library::save(true);
+    super::library::note_preloaded();

Could the marker be written only after confirming the library was serialized? save(true) returns no status, and save_library() can return Ok(0) when it cannot acquire the writer lock. keep_library() then still writes the current translation marker, so a later run can skip compaction even though the preload never persisted its complete library. Please propagate a confirmed-save result before writing this marker and cover the skipped-writer path in a test.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review-comment:4756437525 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3895#discussion_r4756437525). Originally posted by [gut0to](https://github.com/gut0to) on 2026-12-01T15:24:14Z. **Code review location:** `crates/victory-gpu/src/pipeline/known.rs`; line 532 ~~~~diff @@ -525,9 +525,11 @@ pub fn use_library(shaders: PathBuf) { crate::shader_cache::use_shader_cache(shaders); } -/// Writes the library [`use_library`] filled. +/// Writes the library [`use_library`] filled, marked as a preload's for the +/// translations of now: a run's end leaves it whole (#3883). pub fn keep_library() { super::library::save(true); + super::library::note_preloaded(); ~~~~ --- Could the marker be written only after confirming the library was serialized? `save(true)` returns no status, and `save_library()` can return Ok(0) when it cannot acquire the writer lock. `keep_library()` then still writes the current translation marker, so a later run can skip compaction even though the preload never persisted its complete library. Please propagate a confirmed-save result before writing this marker and cover the skipped-writer path in a test.
gut0to commented 2026-12-01 15:24:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by gut0to on 2026-12-01T15:24:14Z.

Review: COMMENTED


AI-assisted review: I traced the preload save, writer-lock fallback, and later compaction skip. I used AI assistance and verified the incomplete-save path in the current source.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:review:6134311562 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3895#pullrequestreview-6134311562). Originally posted by [gut0to](https://github.com/gut0to) on 2026-12-01T15:24:14Z. **Review:** COMMENTED --- AI-assisted review: I traced the preload save, writer-lock fallback, and later compaction skip. I used AI assistance and verified the incomplete-save path in the current source.
andrewpozdnakov7-jpg commented 2026-12-01 15:35:24 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by andrewpozdnakov7-jpg on 2026-12-01T15:35:24Z.


On cf9b91b6, the binary library is saved in the active adapter directory while host-pipelines.preloaded is written in the shared root. That can protect another adapter’s library. The root marker is also written after a skipped or failed save.

e2747fd2 publishes the marker after the binary library is successfully saved, beside that adapter’s file and under the same writer lock. Compaction checks and clears the adapter’s marker under that lock as well. Changing translations still permits a rebuild.

A focused Windows fixture ran the exact file save, marker and compaction code with two synthetic adapter directories and a stub serializer. A failed save left the prior binary untouched and produced no marker. The matching adapter kept its library, the other adapter could compact, and switching translations rebuilt the first and removed its stale marker. The fixture also confirmed that compaction defers while another writer holds the lock. The staged asset policy passed.

Please keep the Git author on cherry-pick or rebase, or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]> if folding the change in.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7316171308 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3895#issuecomment-7316171308). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-12-01T15:35:24Z. --- On `cf9b91b6`, the binary library is saved in the active adapter directory while `host-pipelines.preloaded` is written in the shared root. That can protect another adapter’s library. The root marker is also written after a skipped or failed save. [e2747fd2](https://github.com/andrewpozdnakov7-jpg/VIctory-NVIDIA/commit/e2747fd2bbc05e1fa51520ed0261aafb4e9bcedf) publishes the marker after the binary library is successfully saved, beside that adapter’s file and under the same writer lock. Compaction checks and clears the adapter’s marker under that lock as well. Changing translations still permits a rebuild. A focused Windows fixture ran the exact file save, marker and compaction code with two synthetic adapter directories and a stub serializer. A failed save left the prior binary untouched and produced no marker. The matching adapter kept its library, the other adapter could compact, and switching translations rebuilt the first and removed its stale marker. The fixture also confirmed that compaction defers while another writer holds the lock. The staged asset policy passed. Please keep the Git author on cherry-pick or rebase, or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` if folding the change in. 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/3895:upstream-pr/3895'
git switch 'upstream-pr/3895'

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