perf(gpu): split CardShared out of CARD_WORK lock and avoid full-plan flags scan in relay gather #1322
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1322"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by qlfu on 2026-11-28T17:20:30Z.
Summary
Eliminates long
CARD_WORKmutex holds duringHost::card_beforeand removes the full-planflagsallocation / per-piece binary search loop inHost::relay_card_back:CardShared) out ofCARD_WORK(crates/victory-gpu/src/host.rs):root,pso, anddiffers(initialized once inmake_card_workand read-only afterward) into aOnceLock<CardShared>(CARD_SHARED).Host::relay_card_backnow readsCARD_SHAREDwith zero locking onCARD_WORK.Host::card_beforenow runscard_make_before,send::take,synccommand recording +ExecuteCommandLists, span merging, andcheckcommand recording outsideCARD_WORK, takingCARD_WORKonly briefly to pop pooled command lists and advancetaken/out.card_beforeheldCARD_WORKfor ~10–13 ms/frame acrosssend::takeand D3D12 recording, stalling bothrelay_card_back(which pieces to fetch) andcard_done(read-backs and lists) on the relay landing thread.relay_card_back(crates/victory-gpu/src/host.rs,crates/victory-gpu/src/host/torn.rs):Suspects::is_empty()and replaced the per-planflags: Vec<(usize, u32, bool)>allocation (46,000+ entries/frame) + per-piecebinary_searchloop withcollect_flagged_range()(collecting only flagged/wanted pieces directly into a reusedVec<(usize, u32)>, with a bounds-checked contiguous slice fast-path whensuspectsis empty) andflagged_in_range()(partition_pointslice lookup per range).flagged_pieces()under#[cfg(test)]and added unit testcollect_flagged_range_and_slice_lookup_match_flagged_pieces.Benchmark (GTA VI, 90s steady gameplay, 1440p Series X, DLSS Quality, Ryzen 7 5700X + RTX 4070 Ti 12 GB)
Paired A/B on
main(9ce3cf9) with-FrameGen(idle PC, D3D12 VRAM budget ~10,430 MB):main(9ce3cf9)pr/card-work-lock-and-gather-perf(083a625)which pieces to fetch(per frame)6.00 – 7.05 ms0.40 – 0.51 msread-backs and lists(card_done, per frame)3.18 – 3.57 ms1.54 – 1.79 mscopy-back(back)16.7 ms13.7 msp10FPS13.3/14.314.6/14.618.6/18.5418.5/18.67+0.7% mean71.0%73.0%WARN/ERRORcount0/00/0Verification
cargo clippy -p victory-gpu --all-targets --lockedand--all-features --locked: 0 warnings/errors inhost.rsandhost/torn.rs.cargo test -p victory-gpu --lib --locked -- --test-threads=1 --quiet: 455 passed, 0 failed, 36 ignored.cargo build --release --locked -p victory: exit0.