perf(gpu): fix sweep_unmapped zombie leak, lock-free kept slot bitmap, and read-first shadow let_go_idle #4041
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!4041
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@qlfu on GitHub · 2026-11-30 15:05 UTC · original
qlfu:pr/fix-sweep-unmapped-zombie-and-lockfree-kept→main· +92 −46 · 3 files · 1 commits · closed without mergingSummary
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).@IRennie74 on GitHub · 2026-11-30 18:22 UTC · original · edited 2026-11-30 18:44 UTC
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.@trustno1-coder on GitHub · 2026-12-01 18:46 UTC · original
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