gpu/pipeline: adapter-keyed PSO cache filenames and atomic rename (1/4 of #51) #56

Open
github-bot wants to merge 1 commit from github-bot/gh-56 into beta AGit
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 00:26 UTC · original
Vladimir-Human:perf/split-adapter-pso-cache → beta · +539 −44 · 1 files · 1 commits · open

Part 1/4 of the split requested on #51, cleanly branched from beta (78ad5711).

Scope

  • Touches only crates/victory-gpu/src/pipeline/library.rs.
  • Keys pipeline library filenames by AdapterKey (VendorId, DeviceId, Revision, and is_software flag; GetAdapterLuid is used only to locate the matching DXGI adapter) so WARP/iGPU/dGPU runs never overwrite or load an incompatible GPU's cache blob.
  • Uses unique temporary filenames + atomic rename/replace when persisting the library so concurrent or rapid exits never truncate an in-use cache.
  • Preserves read-only fallback from legacy cache filenames for hardware adapters without writing back to them from WARP.
  • Completely independent of Parts 2-4 (zero file or symbol overlap).

Verification (with VICTORY_D3D12_DEBUG=1)

  • cargo test -p victory-gpu pipeline::library: passed (includes adapter_keys_produce_distinct_filenames_for_hardware_and_software, legacy_fallback_reads_hardware_cache_and_never_touches_it_on_warp, warp_save_does_not_discard_hardware_pipeline_library)
  • cargo test -p victory-gpu --all-features --lib pipeline::library: passed
  • cargo test -p victory-gpu: full crate test suite passed (157 passed; 0 failed; 3 ignored)
  • cargo run -p xtask -- policy --staged: passed (library.rs is 58,047 bytes)
**@⁠Vladimir-Human** on GitHub · 2026-11-26 00:26 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/56) `Vladimir-Human:perf/split-adapter-pso-cache` → `beta` · +539 −44 · 1 files · 1 commits · open Part 1/4 of the split requested on #51, cleanly branched from `beta` (`78ad5711`). ### Scope - Touches **only** `crates/victory-gpu/src/pipeline/library.rs`. - Keys pipeline library filenames by `AdapterKey` (`VendorId`, `DeviceId`, `Revision`, and `is_software` flag; `GetAdapterLuid` is used only to locate the matching DXGI adapter) so WARP/iGPU/dGPU runs never overwrite or load an incompatible GPU's cache blob. - Uses unique temporary filenames + atomic rename/replace when persisting the library so concurrent or rapid exits never truncate an in-use cache. - Preserves read-only fallback from legacy cache filenames for hardware adapters without writing back to them from WARP. - Completely independent of Parts 2-4 (zero file or symbol overlap). ### Verification (with `VICTORY_D3D12_DEBUG=1`) - `cargo test -p victory-gpu pipeline::library`: passed (includes `adapter_keys_produce_distinct_filenames_for_hardware_and_software`, `legacy_fallback_reads_hardware_cache_and_never_touches_it_on_warp`, `warp_save_does_not_discard_hardware_pipeline_library`) - `cargo test -p victory-gpu --all-features --lib pipeline::library`: passed - `cargo test -p victory-gpu`: full crate test suite passed (`157 passed; 0 failed; 3 ignored`) - `cargo run -p xtask -- policy --staged`: passed (`library.rs` is 58,047 bytes)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:53:52 +00:00
Author
Owner

@⁠PastiiJay on GitHub · 2026-11-26 00:34 UTC · original

Got it, part 1/4 is in the queue. One detail: the code still keys the filename on vendor, device, revision and the software flag (the LUID is only used to find the adapter), while the description lists SubSysId and AdapterLuid too, so the summary could use the same fix as #51.

**@⁠PastiiJay** on GitHub · 2026-11-26 00:34 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/56#issuecomment-7178892047) Got it, part 1/4 is in the queue. One detail: the code still keys the filename on vendor, device, revision and the software flag (the LUID is only used to find the adapter), while the description lists SubSysId and AdapterLuid too, so the summary could use the same fix as #51.
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 00:48 UTC · original

Good catch, thanks @⁠PastiiJay — updated the PR #56 description to list only (VendorId, DeviceId, Revision, is_software) in the filename key and note that AdapterLuid is only used to look up the DXGI adapter.

**@⁠Vladimir-Human** on GitHub · 2026-11-26 00:48 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/56#issuecomment-7179127536) Good catch, thanks @⁠PastiiJay — updated the PR #56 description to list only `(VendorId, DeviceId, Revision, is_software)` in the filename key and note that `AdapterLuid` is only used to look up the DXGI adapter.
Author
Owner

@⁠HandshakeHackin on GitHub · 2026-11-26 02:44 UTC · original

I compared the split with the version we tested earlier. pipeline/library.rs is byte-for-byte identical in 356690c and 7d31a81 (Git blob 9d948988). The earlier Windows WARP save/reopen run covered this file, including preserving both synthetic hardware and legacy cache files. Windows run

One detail for the PR description: two processes saving the same adapter key in the same cache directory derive the same .tmp path. The test verified isolation between hardware and WARP. I’d narrow the concurrent-exit claim to distinct adapter keys unless there’s a separate same-key writer test. Filename construction · Save path

**@⁠HandshakeHackin** on GitHub · 2026-11-26 02:44 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/56#issuecomment-7181069689) I compared the split with the version we tested earlier. `pipeline/library.rs` is byte-for-byte identical in `356690c` and `7d31a81` (Git blob `9d948988`). The earlier Windows WARP save/reopen run covered this file, including preserving both synthetic hardware and legacy cache files. [Windows run](https://github.com/HandshakeHackin/klbf-lab/actions/runs/45707827754) One detail for the PR description: two processes saving the same adapter key in the same cache directory derive the same `.tmp` path. The test verified isolation between hardware and WARP. I’d narrow the concurrent-exit claim to distinct adapter keys unless there’s a separate same-key writer test. [Filename construction](https://github.com/PastiiJay/klbf-lab/blob/356690c87817ddc643b10f28452a5a0e75c028f4/crates/victory-gpu/src/pipeline/library.rs#L478-L502) · [Save path](https://github.com/PastiiJay/klbf-lab/blob/356690c87817ddc643b10f28452a5a0e75c028f4/crates/victory-gpu/src/pipeline/library.rs#L760-L795)
Author
Owner

@⁠HandshakeHackin on GitHub · 2026-11-26 04:40 UTC · original

I found a cache-isolation case with the default Microsoft Basic Render Driver on native Windows. DXGI returned 1414:008c with flags 0x0 for the default device and the same IDs with flags 0x2 for explicit WARP. On 356690c, the default device got the -hw filename and opened all 30 bytes of a synthetic unsuffixed legacy file. Explicit WARP got -sw and read zero bytes. Before

The attached commit recognizes the Basic Render Driver by its PCI ID as well as the software flag. Both devices then selected -sw and read zero legacy bytes. All seven library tests passed. I also checked that sharing this key works on the runner. A compute pipeline saved on one device reopened by name on the other, in both directions, with mapped and buffered storage (four cache hits). Cherry-pick 91ef4c9 · After · Cache round trips

**@⁠HandshakeHackin** on GitHub · 2026-11-26 04:40 UTC · [original](https://github.com/PastiiJay/klbf-lab/pull/56#issuecomment-7182795779) I found a cache-isolation case with the default Microsoft Basic Render Driver on native Windows. DXGI returned `1414:008c` with flags `0x0` for the default device and the same IDs with flags `0x2` for explicit WARP. On `356690c`, the default device got the `-hw` filename and opened all 30 bytes of a synthetic unsuffixed legacy file. Explicit WARP got `-sw` and read zero bytes. [Before](https://github.com/HandshakeHackin/klbf-lab/actions/runs/45755822131/job/139694070784) The attached commit recognizes the Basic Render Driver by its PCI ID as well as the software flag. Both devices then selected `-sw` and read zero legacy bytes. All seven library tests passed. I also checked that sharing this key works on the runner. A compute pipeline saved on one device reopened by name on the other, in both directions, with mapped and buffered storage (four cache hits). [Cherry-pick `91ef4c9`](https://github.com/HandshakeHackin/klbf-lab/commit/91ef4c9e465e50312894682c87da5677a37a6427) · [After](https://github.com/HandshakeHackin/klbf-lab/actions/runs/45755822131/job/139694070471) · [Cache round trips](https://github.com/HandshakeHackin/klbf-lab/actions/runs/45756241892/job/139695414273)
This pull request can be merged automatically.
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/56/head:github-bot/gh-56'
git switch 'github-bot/gh-56'

Merge

Merge the changes and update on Forgejo.
git switch 'beta'
git merge --no-ff 'github-bot/gh-56'
git switch 'github-bot/gh-56'
git rebase 'beta'
git switch 'beta'
git merge --ff-only 'github-bot/gh-56'
git switch 'github-bot/gh-56'
git rebase 'beta'
git switch 'beta'
git merge --no-ff 'github-bot/gh-56'
git switch 'beta'
git merge --squash 'github-bot/gh-56'
git switch 'beta'
git merge --ff-only 'github-bot/gh-56'
git switch 'beta'
git merge 'github-bot/gh-56'
git push origin 'beta'
This discussion has been locked. Commenting is limited to contributors.
No description provided.