GPU/draw: create D3D12 command signatures outside cache mutex #1393
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!1393
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1393"
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?
@n-romanovich on GitHub · 2026-11-26 22:36 UTC · original
n-romanovich:perf/1370-unlock-command-signature→main· +107 −64 · 1 files · 1 commits · openAddresses side finding 1 in #1370.
Problem
Both
host_spread_signatureandhost_signatureheld their globalMADEcacheMutexacrossID3D12Device::CreateCommandSignature. During recording inexecute_indirect, a slow driverCreateCommandSignaturecall (observed taking seconds on Intel Arc and causingMutex::lock_contendedstalls across worker threads) blocked every other recording thread from looking up even already-cached command signatures.Changes (
crates/victory-gpu/src/draw.rs)cached_command_signaturehelper and use it in bothhost_spread_signatureandhost_signature:MADEbriefly for lookup and return immediately on cache hit.ID3D12Device::CreateCommandSignature.MADEand re-check for the key before inserting, returning the existing entry if another thread created it concurrently.Verification
draw::tests::command_signature_cache_creates_outside_lockusing barriers to verify that an in-flightcreatecallback does not block concurrent cache lookups on other threads.cargo test --locked -p victory-gpu --lib -- --test-threads=1:224 passed; 0 failed; 6 ignored(note: an unpinned parallel run hit the pre-existing test-harness0xc0000005tracked in #850)cargo build --release --locked -p victory@akimfomin on GitHub · 2026-11-26 22:58 UTC · original · edited 2026-11-26 23:43 UTC
The new cache helper can return
Noneeven after a concurrent caller publishes a valid signature for the same key. I ran a deterministic two-thread test on the helper from0a7ee02. A starts creating and waits. B creates and publishes the same key. A resumes withNone, and the early?bypasses the recheck. The extracted original failed (A returnedNone); moving?after the locked recheck passed (A returned B's result).One small follow-up: hold the result of
create()as an Option until after the second lookup, and add this interleaving to the existing test. The driver call still runs outside the lock. This was a CPU test of the helper, with the driver error simulated. PortBridge · AI-assisted review.Update: UwUCammie's AMD backport uses the recheck before propagating an error. I ran the same two-thread test on the exact helper at
2936e0c; it passed. UwUCammie separately tested the backport under Wine. Pinned backport test return.UwUCammie then added the ordered failure case as a regression and reported a pass under Wine 11.22.
@UwUCammie on GitHub · 2026-11-26 23:19 UTC · original
I ported the single command-signature cache on
linux-amd-best. The Windows MSVC regression passed under Wine 11.22. It checks that creation runs outside the mutex, that another caller’s published result wins, and that a failed creation can be retried. I haven't isolatedCreateCommandSignaturetime in a RADV game profile. AMD backportView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.