GPU: pipeline library loads do not wait for a save #2179
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2179
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2179/head"
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?
@winne42 on GitHub · 2026-11-25 07:06 UTC · original
winne42:gpu/library-loads-beside-saves→main· +123 −16 · 1 files · 1 commits · merged 2026-11-25 21:55 UTCRefs #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
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 07:48 UTC · original
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.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 08:50 UTC · original
I also checked the combination with #2129 on native Windows/WARP. The validation merge combines
c8ad2a4with 2ef0c75 and 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.
@ntgata1-dotcom on GitHub · 2026-11-25 11:20 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 12:40 UTC · original
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