GPU: every pipeline library load runs under one mutex; startup loads take minutes to drain (fix on a fork) #1615
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#1615
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Vaximous on GitHub · 2026-11-24 19:48 UTC · original
Problem
Loading cached pipelines at startup is serialised. With a warm cache, the 1,225 library loads of the early list took about 3.5 minutes to drain. The world then started with about 800 pipelines still queued, so draws were dropped for missing pipelines.
Cause: in
crates/victory-gpu/src/pipeline/library.rs(from35b054e), oneMutex<Library>covers everyLoadGraphicsPipeline/LoadComputePipeline/StorePipelinecall, and a load can take up to seconds. A periodic save also holds that mutex while it serialises the library, which reaches gigabyte size. As a result, the pipeline workers load one at a time and wait for each other.D3D12 does not require this. Per
ID3D12Device1::CreatePipelineLibrary("Thread Safety"), the library is free-threaded and synchronises itself. The only exception is that loads of the same pipeline name must not overlap.Fix
RwLock. A save takes it exclusively, so the serialised size can't change betweenGetSerializedSizeandSerialize. Loads don't touch it, so a save never blocks them.try_lock). Periodic saves back off: 20, 40, 80, then every 160 s, and at least 30x the last save's duration. The final save at the end of a run is unchanged.One file,
crates/victory-gpu/src/pipeline/library.rs, +127/-46, with a test for the save schedule.Branch
https://github.com/Vaximous/VIctory/compare/main...fix/pipeline-library-locks — commit 5fd3b27, based on
ffe310e.Tested
cargo test -p victory-gpu: 51 passed, 0 failed, 1 ignored, includingpipeline::library::tests::*. Clippy-D warningsis clean with and withoutdiagnostics.Related
#275 moves periodic saves to a background thread, but loads still share one mutex. #780 covers pipeline library name mismatches (separate). #72 and #640 retry saves.
AI use
Written with Claude Code (Claude Opus 5.5); tested locally.
@Revens2 on GitHub · 2026-11-24 21:47 UTC · original
publish: branch for #1615
Branch: https://github.com/Revens2/VIctory/tree/work/issue-1615
Commit: 1bf07ce5
Tests:
Refs #1615
Branch: https://github.com/Revens2/VIctory/tree/work/issue-1615
Commit: 1bf07ce
Base:
70564aeupstream/mainTests (run on this machine):
AI-assisted: yes (harness victory-ops); reviewed by a second model before publishing.
Refs #1615
@Marvisak on GitHub · 2026-11-25 12:49 UTC · original
Automated triage for the maintainers.
mainhas changed here sinceffe310e. Incrates/victory-gpu/src/pipeline/library.rs, the load path (the function that callsloadand thencreate) now takes theLibrarymutex only to clone the pipeline library interface, and runsLoadGraphicsPipeline/LoadComputePipelineoutside it; a per-name hold (NAMES.hold) keeps loads of the same name from overlapping. So loads of different names already run in parallel onmain(landed with256d7b9). What is still as described:saveholds the same mutex acrossGetSerializedSizeandSerialize, so during a periodic save (every 20 s) new loads wait at that brief clone, andStorePipelinealso waits. The save backoff andtry_lockskipping from your branch would still apply there.Pull requests are open to everyone: please rebase the save-side part of the branch onto current
mainand open it as a PR so it can be reviewed here (#275, which moves periodic saves to a background thread, is related). The second branch posted in the comments has no description of what it changes beyond this issue.Generated by Claude Code
@pes7 on GitHub · 2026-11-26 15:21 UTC · original
This is one of the two issues #1653 is about (the other is what a save writes).
The two halves of the mutex problem, as they stand here:
A load waited out a whole save. A save holds the library's lock while it serialises the entire library — 230-600 MB in the world — and that was the same lock every load took. #2179 took the first step by keeping the library a second time beside the lock, so loads take the interface and never the lock. That change is on
mainand #1653 now ports it onto the sharded code, with #2179's own test (a_pipeline_loads_while_a_save_holds_the_library— it holds a shard's lock and requires a stored pipeline to load within 30 s; the version that cloned under the lock times out).One lock for everything. Even with loads out of the way, stores and saves of unrelated pipelines serialised: a save of the whole library blocked every store, and two saves could not overlap. #1653 splits the library into 16 files by pipeline-name hash, so a save serialises and writes only the shards that gained pipelines, and each shard has its own lock: a save of shard 3 blocks stores of shard 3, not the other fifteen. The shard a pipeline lands in is a hash of its name, so it is stable across runs — which is what lets a save write only the files that changed.
The startup side of it (the first-run pre-build, where all ~2 900 title pipelines are made) is unaffected by either: it is one long store sequence with nothing to load yet.
Worth knowing for anyone merging in this area: #2328 ("saves run one at a time"), #3181 and #3188 ("save the early list without re-serialising") are outcomes #1653 gives by construction — snapshot+publish are one transaction under a single guard, and a shard that gained nothing is not serialised at all — so those three and #1653 are alternatives rather than neighbours. The full overlap map of that file (six other open PRs) is in #1633.