GPU: load pipeline library entries without the global mutex #1680

Closed
github-bot wants to merge 1 commit from gh-pr/1680/head into gh-pr/1680/base
Owner

@⁠Calvix2k on GitHub · 2026-11-24 20:42 UTC · original
Calvix2k:codex/gpu-pipeline-library-locks-1615 → main · +27 −5 · 1 files · 1 commits · closed without merging

Summary

Loads from the host pipeline library ran under the one mutex that holds the library, so pipeline workers serialised behind loads that take seconds. CreatePipelineLibrary only requires that loads of the same pipeline name do not overlap.

Reworked on upstream 70564ae (which added the pre-built list):

  • Keep a cloned ID3D12PipelineLibrary1 beside the bookkeeping, so a load does not take the library mutex.
  • Loads take one of 64 locks chosen by pipeline name; different names run in parallel.
  • Stores and saves stay under the library mutex, so the serialised size cannot change under a save.
  • No change to the pre-build/prebuilt state, which is read and written under the same mutex as before.

Based on the original #1680 design by @⁠Vaximous, reduced to the load path for the new library structure.

Validation

  • cargo test -p victory-gpu --locked pipeline::library — 4 passed.
  • Full victory-gpu suite: 77 passed, 1 failed, 1 ignored. The failure is draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view, which fails identically on plain origin/main on this machine (unrelated).
  • clippy --all-targets --all-features -D warnings and cargo xtask policy (174 files) passed.
  • Not measured in the title; the original PR's 3.5 min → 30 s startup measurement was on the old library code.
**@⁠Calvix2k** on GitHub · 2026-11-24 20:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/1680) `Calvix2k:codex/gpu-pipeline-library-locks-1615` → `main` · +27 −5 · 1 files · 1 commits · closed without merging ## Summary Loads from the host pipeline library ran under the one mutex that holds the library, so pipeline workers serialised behind loads that take seconds. `CreatePipelineLibrary` only requires that loads of the same pipeline name do not overlap. Reworked on upstream 70564ae (which added the pre-built list): - Keep a cloned `ID3D12PipelineLibrary1` beside the bookkeeping, so a load does not take the library mutex. - Loads take one of 64 locks chosen by pipeline name; different names run in parallel. - Stores and saves stay under the library mutex, so the serialised size cannot change under a save. - No change to the pre-build/`prebuilt` state, which is read and written under the same mutex as before. Based on the original #1680 design by @⁠Vaximous, reduced to the load path for the new library structure. ## Validation - `cargo test -p victory-gpu --locked pipeline::library` — 4 passed. - Full `victory-gpu` suite: 77 passed, 1 failed, 1 ignored. The failure is `draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view`, which fails identically on plain `origin/main` on this machine (unrelated). - clippy `--all-targets --all-features -D warnings` and `cargo xtask policy` (174 files) passed. - Not measured in the title; the original PR's 3.5 min → 30 s startup measurement was on the old library code.
Loads ran under the one mutex that holds the library, so workers serialised behind loads that can take seconds. Keep a cloned `ID3D12PipelineLibrary1` beside the bookkeeping and guard loads with one of 64 locks chosen by pipeline name (`CreatePipelineLibrary` requires only same-name loads not to overlap). Stores and saves stay serialised by the library mutex, so the serialised size cannot change under a save.

Based on the original #1680 work; adapted to the pre-build/`prebuilt` state added upstream.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:41:19 +00:00
github-bot closed this pull request 2026-11-26 04:41:19 +00:00
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 22:17 UTC · original

Marking draft: upstream 70564ae rebuilt the library around the pre-built pipeline list (prebuilt, prebuilt_changed, save tagging), which overlaps every hunk of the lock/save split here. It needs a rework against the new state rather than a mechanical conflict resolution. The concurrency issue itself is still real (upstream still has one Mutex<Library>), so I will redo it on the new base.

**@⁠Calvix2k** on GitHub · 2026-11-24 22:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1680#issuecomment-7146045810) Marking draft: upstream 70564ae rebuilt the library around the pre-built pipeline list (prebuilt, prebuilt_changed, save tagging), which overlaps every hunk of the lock/save split here. It needs a rework against the new state rather than a mechanical conflict resolution. The concurrency issue itself is still real (upstream still has one `Mutex<Library>`), so I will redo it on the new base.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 00:46 UTC · original

Superseded by main: origin/main (4118f33) now holds a pipeline's name with NAMES.hold(name) around load/store and keeps the library in OnceLock<Option<Mutex>>, so loads of different names run in parallel while loads/stores of one name are serialised, and saves take the library mutex. That is the same outcome this PR's 64-stripe lock and STORES RwLock produced, with the new pre-build support on top. Closing this in favour of the code already on main; nothing from the PR is lost.

**@⁠Calvix2k** on GitHub · 2026-11-25 00:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/1680#issuecomment-7148868936) Superseded by main: origin/main (4118f33) now holds a pipeline's name with NAMES.hold(name) around load/store and keeps the library in OnceLock<Option<Mutex<Library>>>, so loads of different names run in parallel while loads/stores of one name are serialised, and saves take the library mutex. That is the same outcome this PR's 64-stripe lock and STORES RwLock produced, with the new pre-build support on top. Closing this in favour of the code already on main; nothing from the PR is lost.

Pull request closed

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!1680
No description provided.