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

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

@⁠Trillazill on GitHub · 2026-11-30 10:48 UTC · original
Trillazill:fix/library-keeps-preload → main · +59 −1 · 2 files · 1 commits · open

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

**@⁠Trillazill** on GitHub · 2026-11-30 10:48 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3895) `Trillazill:fix/library-keeps-preload` → `main` · +59 −1 · 2 files · 1 commits · open ## 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)
A run's end rebuilt the library from the pipelines it used once the library
was over VICTORY_LIBRARY_KEEP_MB. After a preload that threw the places the
run did not visit away (5,658 pipelines, 1,158 MB, to 2,225, 164 MB), and
they compiled again in play at 0.5-1 s each.

known::keep_library, which both preload paths call, now writes
host-pipelines.preloaded beside the library with shader_cache::translation().
compact() leaves the library whole while that marker names this run's
translations; after a translator change it rebuilds as before and removes
the marker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 10:51:54 +00:00
github-bot changed title from Pipeline library: a run's end keeps a preload's library for the same translations (#3883) to Pipeline library: a run's end keeps a preload's library for the same translations 2026-12-01 06:26:20 +00:00
github-bot force-pushed github-bot/gh-3895 from 4ba9a4462d to cf9b91b6ba 2026-12-01 06:26:21 +00:00 Compare
Author
Owner

@⁠Trillazill on GitHub · 2026-12-01 06:21 UTC · original

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.

**@⁠Trillazill** on GitHub · 2026-12-01 06:21 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3895#issuecomment-7302784395) 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.
Author
Owner

@⁠gut0to on GitHub · 2026-12-01 15:24 UTC · original · reviewed

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.

**@⁠gut0to** on GitHub · 2026-12-01 15:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3895#pullrequestreview-6134311562) · **reviewed** 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.
@ -529,2 +529,4 @@
/// translations of now: a run's end leaves it whole (#3883).
pub fn keep_library() {
super::library::save(true);
super::library::note_preloaded();
Author
Owner

@⁠gut0to on GitHub · 2026-12-01 15:24 UTC · original

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** on GitHub · 2026-12-01 15:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3895#discussion_r4756437525) 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.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-12-01 15:35 UTC · original

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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-12-01 15:35 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3895#issuecomment-7316171308) 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 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/3895/head:github-bot/gh-3895'
git switch 'github-bot/gh-3895'

Merge

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