GPU: pipeline library loads do not wait for a save #2177
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2179"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by winne42 on 2026-11-25T07:06:43Z.
Refs #1615. #1000 took pipeline loads out from under the library's lock, but one part of #1615 is still there.
The problem
library::pipeline()still takes the library's mutex to clone theID3D12PipelineLibrary1before every load.save()holds that mutex throughGetSerializedSize+Serializeof the whole library, which is 230 MB (#1683) to over 600 MB (#1653) in the world. Saves run every 20 s while new pipelines are being made, and some run on the pipeline workers themselves (make.rs). So for the whole of each save, every load waits, on every worker.The change
One file,
crates/victory-gpu/src/pipeline/library.rs:Shared::loads) is kept besideMutex<Library>, and loads use it without taking any lock.ID3D12Device1::CreatePipelineLibrary("Thread Safety"), the library is free-threaded except for loads of the same name, whichNAMESalready keeps apart. The existingpipelines_load_on_many_threads_at_oncealready runs loads alongsideSerialize.New test
a_pipeline_loads_while_a_save_holds_the_library: it stores a pipeline throughpipeline(), holds the library's lock the way a save does, and checks that a load of the same pipeline returns within 30 s. It builds its root signature withD3D12SerializeRootSignatureand uses a compute shader with no resources, because Wine'sd3dcompiler_47does not embed a[RootSignature]attribute.This does not touch the save size itself (#1653) or the empty-blob fix for vkd3d-proton (#1722). It merges cleanly with #1722. It conflicts with #1653, which rewrites the same functions into 16 shards, each loaded under its own lock. The same split (a load handle per shard, beside its lock) would carry over there.
Tested
Linux,
x86_64-pc-windows-msvccross-build (lld-link + xwin), run under Wine 10.0 with vkd3d-proton 3.1 and DXVKdxgifrom Proton Experimental, on an RTX 3050 Laptop GPU (4 GB). Not run on Windows.main's empty library without it, solibrary()isNonethere):cargo test -p victory-gpu --lib pipeline::library: 9 passed.the load waited for the save(Err(Timeout)).victory-gpulib suite gives 130 passed, 14 failed and 2 ignored, andmaingives 129 / 14 / 2 on the same machine. The 14 failures are the same tests on both, and they fail onmainunder vkd3d-proton. The extra pass is the new test, which returns early there because there is no library.cargo clippy -p victory-gpu --all-targets --locked -- -D warnings, with and without--all-features: clean.Side note: under Wine,
pipelines_load_on_many_threads_at_oncereturns at "no shader compiler here", because Wine's compiler fails on its shader. So on Linux hosts it does not run.No game data was used.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T07:17:37Z.
Review: COMMENTED
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Pipeline library loads don't wait for a save — load-path latency fix; pairs with #2129/#2132's library mapping (duplicate pair still open).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T07:48:38Z.
I ran the pipeline-library tests on exact head
c8ad2a4on native Windows with the D3D12 WARP adapter and the diagnostics feature. All nine passed, including the load under a held save mutex and the concurrent load/store/serialize test.For a negative control I put the old lock acquisition back before the load and made unavailable GPU or FXC support fail explicitly. The new test reached the assertion and failed with “the load waited for the save” after 30 seconds. This establishes that the test exercises contention on the project mutex on WARP. Driver latency during serialization remains unmeasured.
AI-assisted. Synthetic shaders only.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T08:50:01Z.
I also checked the combination with #2129 on native Windows/WARP. The validation merge combines
c8ad2a4with2ef0c75and the optional mapped-replacement test f040754. In the mapped save path I kept the staging write and used the mutex on the new Shared state.Both runs passed 15 pipeline-library tests and skipped one memory measurement, with mapping enabled and with VICTORY_LIBRARY_MAP=0. The same build exercised the held-save-mutex test, concurrent loads and serialization, and loading the original PSOs after replacing the mapped file.
AI-assisted. Synthetic data only.
Imported from Marvisak/VIctory. Originally posted by ntgata1-dotcom on 2026-11-25T11:20:13Z.
RX 9070 XT (RADV) under Wine 11.22: works with #1722 (tests, and menus only)
Setup: Arch Linux, RX 9070 XT (RDNA4), RADV / Mesa 26.3.1. System Wine 11.22. vkd3d-proton
v3.1-83-gcae8353edand DXVKdxgifrom GE-Proton11-14.cargo xwin test --locked --target x86_64-pc-windows-msvc --no-fail-fast -p victory-gpu, runnerwine.victory-gpumain940d32fc8ad2a4a_pipeline_loads_while_a_save_holds_the_library: without #1722 it returns at its firstelsehere (library()isNoneunder vkd3d-proton), so its "ok" there means it didn't run. With #1722 it runs. A temporary print after the store showed the load returningOk(true)while the lock was held.pipeline::librarytests pass. Outsidepipeline::library, no test changes againstmain. With #2195 merged as well, the results are the same.bytes=1208 early=6 made=6, and run 2 loads it:made=0 loaded=6 started_early=6. Both run at 30.0 fps after start-up, with nocrashes.logand no amdgpu messages in the kernel log during the runs. With 6 pipelines and 1.2 KB saves, the menus can't show the load/save contention itself; that needs the world.Not run: Windows, the world.
AI-assisted (Claude Code); numbers from my own runs.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T12:40:06Z.
Automated triage for the maintainers.
Merge candidate. On
main,pipelineincrates/victory-gpu/src/pipeline/library.rsalready loads outside the library lock, but it takes the lock first to clone the interface. So every load waits out a save that holds the lock while it serialises the whole library. This PR keeps a second reference to the same library (Shared::loads) next to the locked state, so loads never take the lock. Stores, serialising and the pre-build list stay understate's lock, as before. Loads of one name stay apart throughNAMES, as onmain.The new test
a_pipeline_loads_while_a_save_holds_the_libraryholds the lock and checks that a stored pipeline still loads. A reviewer confirmed it fails (times out) with the old lock acquisition put back. CIcheckpasses, and the branch merges cleanly.For the maintainers: #1653 and #1651 rework the same function for sharding. Whichever lands second needs a rebase onto the other.
Generated by Claude Code
upstream-sync referenced this pull request2026-11-25 14:07:18 +00:00
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T14:56:57Z.
Review: APPROVED
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090:cargo test -p victory-gpu pipeline::library::tests: 9/9 passed (includinga_pipeline_loads_while_a_save_holds_the_library).cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).