perf(gpu): fix sweep_unmapped zombie leak, lock-free kept slot bitmap, and read-first shadow let_go_idle #4041
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4041"
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-30T15:05:05Z.
Summary
Eliminates three long-session CPU sweep cliffs on the submitting thread:
resource::let_go_idle(sweep_unmapped_on):sweep_unmapped_oncalledmade.take()without resettingr.host.used.store(0, Relaxed)(unlike the main idle loop, dead-RT sweep, andslot_evict). Evicted streamed-out textures remained permanentused != 0zombies, re-runningK32QueryWorkingSetExand bloatingby_age/slot_evictscans on every sweep.HostHeap::slots_showingandHostHeap::shows(descriptor/host.rs):kept_raw: Box<[AtomicUsize]>and 64-slot occupancy bitmaskkept_non_empty: Box<[AtomicU64]>, updated under the existing per-slotkept[i]lock inkeep,keep_ref, andtake_kept.slots_showingskips empty 64-slot words in one instruction and readskept_rawwith zero per-slotMutex::lock()calls (replacing up to ~1M mutex acquisitions per pressuredslot_evictpass underSHADER_HEAPS.read()).showsalso becomes lock-free.shadow::let_go_idle(shadow.rs):LOOSE.read()first so COMreferences()checks do not block concurrent recording threads underLOOSE.write(); takesLOOSE.write()only when idle candidates exist and re-verifiesis_idlebefore removing.Verification
cargo check -p victory-gpu --all-targets --all-features --locked: exit 0.cargo test -p victory-gpu --lib --locked -- resource:: descriptor::host:: shadow:: --test-threads=1: passed (0 failed).git merge-tree --write-tree 41adb551 HEAD: clean merge.heapssweep time dropped2.60 -> 0.50-0.60 ms(max7.3 -> 1.7 ms).Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by IRennie74 on 2026-11-30T18:22:55Z.
This conflicts with main now, and part of it is already there:
let_go_idle's unmapped path now goes throughtake_unmapped_hostand resetsusedright afterwanted(crates/victory-gpu/src/resource.rs:3509on84bd61e2:r.host.used.store(0, Relaxed);). The one-line hunk here can go.kept_raw/kept_non_empty) conflicts with main'sslots_showing. On main it now returns a 6-tuple(index, raw, key, ok, lately, indexed)(callers atdescriptor.rs:2185and:2338). Slot eviction's choice also runs aside on main now (VICTORY_SLOT_EVICT_ASIDE, on), so the per-slot locks this removes are mostly off the submitting thread already. A fresh measurement on main would show whether the mirror (8 bytes plus a bit per slot) still pays for itself.LOOSEscan inshadow::let_go_idle) still applies, as far as I can see. It is the part most likely to help the frame, because recording threads takeLOOSEtoo. Rebased down to this part alone, it would be easy to land.The
heaps2.60 -> 0.50-0.60 ms figure predates main moving slot eviction aside, so it would need measuring again after the rebase.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:46:56Z.
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed