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

Manually merged
github merged 1 commit from gh-pr/983/head into gh-pr/983/base 2026-11-26 04:15:48 +00:00
Owner

@⁠LICObr on GitHub · 2026-11-24 14:39 UTC · original
LICObr:gpu/early-pipelines-most-recent → main · +50 −13 · 1 files · 1 commits · merged 2026-11-25 21:49 UTC

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.

**@⁠LICObr** on GitHub · 2026-11-24 14:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/983) `LICObr:gpu/early-pipelines-most-recent` → `main` · +50 −13 · 1 files · 1 commits · merged 2026-11-25 21:49 UTC > **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.
The early list keeps this run's keys first, then earlier runs' others,
but those came from a HashSet, so once the list was full the keys that
made room were any earlier ones, not the oldest.

Earlier keys now keep their place in the list as loaded. The list is
saved most recent run first, so sorting by that place drops the oldest
runs' keys and keeps the order across saves. A list saved by an earlier
build (in no order) still reads.

`save` also reads the list through `used()`, so a save before anything
read it in this run keeps the saved list instead of writing an empty one.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:15:45 +00:00
github manually merged commit 1edc06c7f2 into gh-pr/983/base 2026-11-26 04:15:48 +00:00
Author
Owner

@⁠Zipettte on GitHub · 2026-11-24 14:55 UTC · original

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).

**@⁠Zipettte** on GitHub · 2026-11-24 14:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/983#issuecomment-7135157753) 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)._
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 15:01 UTC · original

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.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 15:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/983#issuecomment-7135323459) 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.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 01:29 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 01:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/983#issuecomment-7149600996) <!-- 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)_
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/Marvisak--VIctory!983
No description provided.