Reduce CPU lock contention across shadow merges, refreshes, and card sync #1561
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1561"
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 mikael-jarvinen on 2026-11-28T21:45:11Z.
Rebased replacement for #1157 onto
main(923e38c), cleanly composed with upstream #1400 (UnderSlots+ batchedcard.dirty) andVICTORY_FAULT_UNLOCKED(dropping already-merged hunks).Summary of Changes
Shadow::merging([RwLock<()>; 64], lazily allocated): replaces the single per-ShadowRwLock<()>so concurrentland_card_piecesandmerge_under_writeson disjoint 64 KiB pages do not serialize each other; acquires only the touched stripe mask in ascending order and skipsself.before.lock()on card-backed copies.CopyState(RwLock<CopyState>): replaces separatecopied+rangedmutexes for concurrent lock-free reader sharing innothing_new_with.JournalRead+Shadow::nothing_new_with: acquiresJOURNALread lock once per refresh/span batch instead of per copy, with binary-searchedahead_contains.descriptor::constant_slots_batch+HostHeap::constant_at_with_base: resolvesSHADER_HEAPSonce and reuses cachedbuffer_gpuacrosscard_stepsconstant slots.Batchfast paths:Batch::note_gpu_writededuplicates repeated GPU writes and accumulatesdeclareddirectly (avoidingdeclared_writes(runs)rescan); 1-entrylast_aheadcache;Blocks::all_setword-level bitmap check inwatch::guard;CARD_WORKlocked aftersend::take.Verification & Re-Measurement on
main(923e38c)shadow+ 51/51watchtests pass; 0 new warnings.diagbuild, warm cache, 1440p DLSS Performance, FG off, 115 s scripted run):main(923e38c, ~7,650 draws)175c954, ~8,000–8,690 draws)lists' stepsTOTAL (copies & fills)planning card_stepsasking write watchImported from trustno1-coder/VIctory-NVIDIA. Originally posted by DoubleD17 on 2026-11-30T03:37:09Z.
We ran a test of this PR on current main (it still merges cleanly), on a CPU-bound machine (about 66 ms of CPU preparation per frame).
The difference is on the good side but inside the noise (the controls alone spread over 9 ms).
Picture: in round 1, one frame had the palms and the potted plants by the house missing. The game was at 8 fps at that moment, so that frame was on screen for about 140 ms. We saw none in the 320 control frames of this session nor in 800 earlier ones on this base, and we saw the same one-frame vegetation gap with #3502, #3476 and #3411. It may be a timing-sensitive problem in main rather than this PR alone.
Setup:
41adb551(only its own commits on top), against41adb551itself;41adb551spread through the session;Picture check: a burst of 10 captures a second at the end of each run (80 frames), looked at frame by frame.
AI Assisted