GPU: a full early pipeline list drops the oldest runs' keys #983

Merged
LICObr merged 1 commit from upstream-pr/983 into main 2026-11-25 21:49:31 +00:00
LICObr commented 2026-11-24 14:39:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LICObr on 2026-11-24T14:39:08Z.


Updated after c47b529 / 9c58a1c. Those commits on main fixed the main problem this PR first reported (a full early list refused every new key) with the Used { before, now } split. This PR is now rebased onto that design and only closes the two gaps left in it.

Problem

Used::list keeps this run's keys first, then earlier runs' others, cut to EARLY_MAX (8,192). The earlier keys come from a HashSet, so once the list is full, the keys that make room are any earlier keys, not the oldest ones. A key the last run drew with can go while one unused for many runs stays. That key's pipeline is then not started early and compiles on first use.

A smaller one: save reads USED directly, not through used(). If a save runs before anything in this run read the list, it writes an empty list over the saved one. keep_early_list covers the pre-build; the fix below covers every caller.

Change

  • Used::before keeps each earlier key with its place in the list as loaded (HashMap<String, usize>). The list is already saved this run first, so sorting earlier keys by that place gives most recent first. A full list then drops the oldest runs' keys, and the order carries across saves.
  • No file format change. A list saved by an earlier build (in no order) still reads; its order settles after one save.
  • Reading the list moved into Used::read.
  • save reads the list through used().

Verification

  • New test a_full_early_list_drops_the_oldest_runs_keys: it fills the list from a saved file, uses 10 new keys plus the oldest key again, and checks three things. The 10 keys that go are exactly the oldest ones not used again, the key used again stays, and the order holds after a save and read back. Against the current main behaviour, this test fails.
  • the_early_list_keeps_this_run_first (existing) still passes.
  • cargo clippy -p victory-gpu --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings, with and without --all-features: clean.

Not exercised in a game run: no game files were used.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6584285678 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/983). Originally posted by [LICObr](https://github.com/LICObr) on 2026-11-24T14:39:08Z. --- > **Updated after c47b529 / 9c58a1c.** Those commits on `main` fixed the main problem this PR first reported (a full early list refused every new key) with the `Used { before, now }` split. This PR is now rebased onto that design and only closes the two gaps left in it. ## Problem `Used::list` keeps this run's keys first, then earlier runs' others, cut to `EARLY_MAX` (8,192). The earlier keys come from a `HashSet`, so once the list is full, the keys that make room are **any** earlier keys, not the oldest ones. A key the last run drew with can go while one unused for many runs stays. That key's pipeline is then not started early and compiles on first use. A smaller one: `save` reads `USED` directly, not through `used()`. If a save runs before anything in this run read the list, it writes an empty list over the saved one. `keep_early_list` covers the pre-build; the fix below covers every caller. ## Change - `Used::before` keeps each earlier key with its place in the list as loaded (`HashMap<String, usize>`). The list is already saved this run first, so sorting earlier keys by that place gives most recent first. A full list then drops the oldest runs' keys, and the order carries across saves. - No file format change. A list saved by an earlier build (in no order) still reads; its order settles after one save. - Reading the list moved into `Used::read`. - `save` reads the list through `used()`. ## Verification - New test `a_full_early_list_drops_the_oldest_runs_keys`: it fills the list from a saved file, uses 10 new keys plus the oldest key again, and checks three things. The 10 keys that go are exactly the oldest ones not used again, the key used again stays, and the order holds after a save and read back. Against the current `main` behaviour, this test fails. - `the_early_list_keeps_this_run_first` (existing) still passes. - `cargo clippy -p victory-gpu --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings`, with and without `--all-features`: clean. Not exercised in a game run: no game files were used.
Zipettte commented 2026-11-24 15:04:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T14:55:00Z.


Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 486b54e: cargo test -p victory-gpu passes, 52 passed / 0 failed. Workspace baseline on main (ffe310e) was green on the same machine (342 passed).

Tested with AI assistance (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135157753 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/983#issuecomment-7135157753). Originally posted by [Zipettte](https://github.com/Zipettte) on 2026-11-24T14:55:00Z. --- Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 486b54e: `cargo test -p victory-gpu` passes, 52 passed / 0 failed. Workspace baseline on main (ffe310e) was green on the same machine (342 passed). _Tested with AI assistance (Claude)._
MichaelSmithAI commented 2026-11-24 15:04:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T15:01:07Z.


We checked the save-before-first-use case through save_pipeline_cache() on an RTX 4090 under Wine/vkd3d-proton 3.2. A temporary cache started with two legacy keys, aaaa and bbbb. After creating a compute PSO, the first save preserved both keys at run 0. After ready() marked the new pipeline used, a second save placed its key first at run 1 and kept both older entries.

Bypassing only the read-before-save step made the first save replace the list with an empty file. Both builds included #844’s empty-library fix so the Wine backend could create and save the host library. This comparison covers preservation and promotion through the save API. Game startup timing remains unmeasured.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7135323459 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/983#issuecomment-7135323459). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T15:01:07Z. --- We checked the save-before-first-use case through `save_pipeline_cache()` on an RTX 4090 under Wine/vkd3d-proton 3.2. A temporary cache started with two legacy keys, `aaaa` and `bbbb`. After creating a compute PSO, the first save preserved both keys at run 0. After `ready()` marked the new pipeline used, a second save placed its key first at run 1 and kept both older entries. Bypassing only the read-before-save step made the first save replace the list with an empty file. Both builds included #844’s empty-library fix so the Wine backend could create and save the host library. This comparison covers preservation and promotion through the save API. Game startup timing remains unmeasured.
mercuryVM commented 2026-11-24 17:02:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T16:26:27Z.

Review: APPROVED


Tested 486b54e on Windows 11, RTX 5070, MSVC: builds, cargo test --workspace --no-fail-fast 576 passed, 0 failed (on our fork main), with victory-shader single-threaded. Both new pipeline::library tests pass.

  • The fix is right. Previously note_used refused new keys once the union of every run reached EARLY_MAX, so the list stopped learning. Now keys are ranked by last run and cut on save. The test fills the list with 8,192 keys from two runs and shows exactly one key from the oldest run making room for a new one.
  • save now reads through used(), which fixes the empty-overwrite when nothing had read the list yet.
  • Old files stay compatible. A bare key fails the <run> parse and reads as run 0; a key containing a space still parses, because the first field must be a number.
  • The run number is one past the newest in the file. A run that uses nothing new writes the same numbers, so the next run reuses that number, which is harmless.
  • Nit: within one run, keys grows past EARLY_MAX until save cuts it. That's bounded by the pipelines a run makes, so it's fine.

Merged into our fork's main.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6043222241 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/983#pullrequestreview-6043222241). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T16:26:27Z. **Review:** APPROVED --- Tested 486b54e on Windows 11, RTX 5070, MSVC: builds, `cargo test --workspace --no-fail-fast` 576 passed, 0 failed (on our fork main), with victory-shader single-threaded. Both new `pipeline::library` tests pass. - The fix is right. Previously `note_used` refused new keys once the union of every run reached `EARLY_MAX`, so the list stopped learning. Now keys are ranked by last run and cut on save. The test fills the list with 8,192 keys from two runs and shows exactly one key from the oldest run making room for a new one. - `save` now reads through `used()`, which fixes the empty-overwrite when nothing had read the list yet. - Old files stay compatible. A bare key fails the `<run>` parse and reads as run 0; a key containing a space still parses, because the first field must be a number. - The run number is one past the newest in the file. A run that uses nothing new writes the same numbers, so the next run reuses that number, which is harmless. - Nit: within one run, `keys` grows past `EARLY_MAX` until save cuts it. That's bounded by the pipelines a run makes, so it's fine. Merged into our fork's main. AI-assisted (Claude Code).
upstream-sync changed title from [PR #983] GPU: the early pipeline list keeps the most recently used keys to [PR #983] GPU: a full early pipeline list drops the oldest runs' keys 2026-11-25 00:05:40 +00:00
Marvisak commented 2026-11-25 02:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:29:13Z.


Automated triage for the maintainers.

Merge candidate. This closes two gaps in the early pipeline list in crates/victory-gpu/src/pipeline/library.rs:

  • Used::before now keeps each earlier key's place in the loaded list. Used::list sorts earlier keys by that place, so a full list (EARLY_MAX) drops the oldest runs' keys rather than arbitrary HashSet entries. The order carries across saves, and lists saved by older builds still read.
  • save reads the list through used(), not USED directly. A save that runs before anything else reads the list no longer overwrites it with an empty one. @MichaelSmithAI reproduced that case through save_pipeline_cache().

Checked: used() takes only the USED lock, so calling it from save adds no lock-order problem. wanted_early moves to contains_key with no change in behaviour. The new test a_full_early_list_drops_the_oldest_runs_keys asserts the intended eviction order, not just the current output. The PR merges cleanly with current main, including the concurrent-load changes to the same file.

CI: no check runs on the head commit. A reviewer reports cargo test -p victory-gpu passing on an RX 7700 XT.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149600996 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/983#issuecomment-7149600996). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:29:13Z. --- <!-- victory-triage v1 head=1edc06c7f28810bbea1f2987a445890c059ca714 verdict=merge-candidate at=2026-11-25T01:29:12Z --> Automated triage for the maintainers. **Merge candidate.** This closes two gaps in the early pipeline list in `crates/victory-gpu/src/pipeline/library.rs`: - `Used::before` now keeps each earlier key's place in the loaded list. `Used::list` sorts earlier keys by that place, so a full list (`EARLY_MAX`) drops the oldest runs' keys rather than arbitrary `HashSet` entries. The order carries across saves, and lists saved by older builds still read. - `save` reads the list through `used()`, not `USED` directly. A save that runs before anything else reads the list no longer overwrites it with an empty one. @MichaelSmithAI reproduced that case through `save_pipeline_cache()`. Checked: `used()` takes only the `USED` lock, so calling it from `save` adds no lock-order problem. `wanted_early` moves to `contains_key` with no change in behaviour. The new test `a_full_early_list_drops_the_oldest_runs_keys` asserts the intended eviction order, not just the current output. The PR merges cleanly with current `main`, including the concurrent-load changes to the same file. CI: no check runs on the head commit. A reviewer reports `cargo test -p victory-gpu` passing on an RX 7700 XT. --- _Generated by [Claude Code](https://claude.ai/code)_
upstream-sync closed this pull request 2026-11-25 22:02:45 +00:00
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!983
No description provided.