gpu: honour slot eviction backoff on the aside path and keep fast readback while evicted #4433
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!4433
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-4432"
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?
@nidea1 on GitHub · 2026-11-30 20:19 UTC · original
nidea1:fix/slot-evict-aside-backoff→main· +431 −56 · 3 files · 6 commits · closed without mergingWhat it changes
Two correctness bugs in texture slot eviction and sampled-slot readback cadence, observed on an 8 GB VRAM GPU (RTX 3060 Ti):
slot_evict_aside()never updatesNEXT_SLOT_MSbackoff and allows overlapping background looks (crates/victory-gpu/src/resource.rs)slot_evict()returns immediately after dispatchingslot_look_aside(job), skipping theNEXT_SLOT_MSstore that follows the inline path (#2549).VICTORY_SLOT_EVICT_ASIDEis on (default),NEXT_SLOT_MSstays at0forever:VICTORY_SAMPLED_EVICT=0(default), empty background looks spin on every 1 s sweep instead of backing off 15 s.VICTORY_SAMPLED_EVICT=1, consecutive sweeps launch overlapping/back-to-back evictions without the 2 s / 5 s cooldown, over-evicting live textures and churning remakes.NEXT_SLOT_MSto a module-level static shared viaschedule_slot_backoff(now_ms, evicted, over_budget).slot_look_aside, claimSLOT_LOOKINGfirst and then checkSLOT_HAS_READY.load(Acquire) || now_ms < NEXT_SLOT_MS.load(Acquire)(closing the TOCTOU window where a finishing look orslot_evict_readypublishes state right beforeSLOT_LOOKINGis claimed).SLOT_LOOKINGwhenvictims.is_empty().slot_evict_ready, keepSLOT_HAS_READYset (via aDropguard) acrossslot_applyandschedule_slot_backoff(now_ms, n, job.over_budget)so a concurrentslot_evictcannot start a second look before backoff is published, and a batch whose candidates were all kept at their second look gets the 15 s empty backoff.sampled::on_presentfalls back to 30-frame readback cadence while evicted indexed slots wait to wake (crates/victory-gpu/src/sampled.rs)sweep_cadenceonly checkeddescriptor::host::any_held_textures(), notEVICTED_ANY.VICTORY_SAMPLED_EVICT=1, once newly freed VRAM allowed held textures to drop back to0, thousands of evicted indexed slots were still sitting null while readback dropped from every 4 frames to every 30 frames (~0.5–1.5 s wake latency when a previously evicted texture comes back into view).EVICTED_ANY.load(Relaxed)intosweep_cadence(any_held, any_evicted)so readback stays atHELD_SWEEP_EVERY(4 frames) while any indexed slots are evicted.Intentionally leaves
VICTORY_SAMPLED_EVICToff by default pending extended outdoor/foliage verification.How it was tested
VICTORY_SAMPLED_EVICT=0: 64 emptyslot eviction asidelooks in 38 s (avg 28.9 ms, max 49.4 ms).VICTORY_SAMPLED_EVICT=1: 32+ looks (40,793 evicted), 2,417 quick remakes (<2 s), 9,518 total remakes, readback cadence fell back to 30 frames with 31,015 slots still null.a99138aa):VICTORY_SAMPLED_EVICT=0: 4 emptyslot eviction asidelooks in 40 s (honouring 15 s empty-pass backoff).VICTORY_SAMPLED_EVICT=1: 8 looks (24,194–26,707 evicted), quick remakes (<2 s) 378–669 (-72% to -84%), total remakes 2,026–2,339 (-75% to -79%), readback cadence stayed locked at 4 frames throughout, steady VRAM 6.2–6.4 / 6.5–6.6 GB,WAITS FOR GPU0.0–0.6 ms.cargo testpassed for the crates it touches: yes (cargo test -j 4 -p victory-gpu --locked --lib -- resource::tests:: sampled::tests::: 72 passed, 0 failed, 1 pre-existing ignored;cargo clippy -j 4 -p victory-gpu --all-targets --locked --no-deps: 0 warnings inresource.rsandsampled.rs;cargo run -p xtask -- policy --staged: ok).Checked for overlap
NEXT_SLOT_MSon the aside path), #3697, #4340, #3750, and #4466 (opened shortly after this PR for theresource.rsbackoff part only; this PR also closes theslot_look_aside/slot_evict_readyconcurrency windows and fixes thesampled.rswake cadence).@tikD1337 on GitHub · 2026-11-30 20:51 UTC · original
Tested headlessly on
origin/main(e1251c31, Windows 11, no game run):origin/main.cargo test -p victory-gpu --lib -- slot_evict/sampled::tests: 13 passed, 0 failed (1187 filtered).Note: the
crates/victory-gpu/src/resource.rsbackoff/guard change overlaps with #4466 (merging both would conflict inresource.rs). #4433 usesAcquire/ReleaseonNEXT_SLOT_MSand additionally updatessweep_cadenceincrates/victory-gpu/src/sampled.rsto keep fast readback while evicted slots are waiting to wake.(AI-assisted build/unit-test check and diff review; game runtime not launched.)
@IRennie74 on GitHub · 2026-11-30 22:38 UTC · original
For whoever merges this together with #4559 (whole sweep off the submitting thread,
VICTORY_SWEEP_OFF_THREAD=1): on that pathslot_evictruns on the sweep's own thread and does not hand off toslot_look_aside(... && slot_evict_aside() && !crate::host::sweeper::here()). The inlineNEXT_SLOT_MSbackoff therefore already applies there, and this PR changes nothing for it. It fixes the default path. Both edit the sameif !forced && slot_evict_aside()line inslot_evict, so expect a small textual conflict, and keep the!hereterm when resolving it.Of this and #4466, this one is the superset (the same backoff hoist plus the
slot_evict_readywindow and thesampled.rscadence), so only one of the two should land.(The CI failure is main's clippy errors,
loop_caps/ranged/is_multiple_of, not this change. The new test therefore has not run in CI yet.)a99138aab6to90687a7545@nidea1 on GitHub · 2026-12-01 03:09 UTC · original
@IRennie74 Thanks for the review and heads-up on #4559!
#4433 is now rebased cleanly onto
7d93ee0759(90687a75). If #4559 lands first, I will rebase and make sure!crate::host::sweeper::here()is preserved onif !forced && slot_evict_aside()so the off-thread sweep path stays untouched.@Maverick0351a on GitHub · 2026-12-01 03:51 UTC · original
Confirming this bug on a 16 GB GPU as well (Windows 11 x64, RTX 5080 Laptop 16 GB, 32 GB RAM, Series S profile, 2560x1440, DLSS Quality + DLSS FG 4x,
VICTORY_SLOT_EVICT=1,VICTORY_SAMPLED_EVICT=1,VICTORY_TEXTURE_ROOM_PERCENT=88).Over a 1h 46m run (99,983 DLSS frames), the missing
NEXT_SLOT_MSbackoff on theVICTORY_SLOT_EVICT_ASIDEpath caused:13,815 / 15,235 MB),sweep()fired two back-to-back slot-eviction bursts 57 ms apart (2,243copies /256 MB, then1,256copies /114 MB), with annvlddmkmEvent ID 153 /0x887A0006device hang occurring 31 ms after the first burst.One minor ordering detail worth checking alongside this PR: in
crates/victory-gpu/src/host.rs(sweep()),crate::resource::slot_evict_ready()currently runs aftertake_idle_reclaim_request()->let_go_idle(), whereas movingslot_evict_ready()beforetake_idle_reclaim_request()ensures a ready batch is applied and publishesNEXT_SLOT_MSbefore any new reclaim request checks it.Note: this PR currently shows unrelated base diffs from today's
mainupdate (f5c3d243), so a rebase ontof5c3d243will keep the diff scoped cleanly toresource.rsandsampled.rs.90687a7545to4674870535@nidea1 on GitHub · 2026-12-01 09:59 UTC · original · edited 2026-12-01 10:32 UTC
@Maverick0351a Thanks for the detailed 16 GB field confirmation (those 57 ms back-to-back bursts and 35k null slots stuck on the 30-frame cadence match what we saw on 8 GB).
Rebased onto current
main(5fabb46e): updated branch head is24a8bb50(ab666153+46748705+24a8bb50), cleanlyMERGEABLEand scoped strictly tocrates/victory-gpu/src/resource.rsandcrates/victory-gpu/src/sampled.rs. Follow-up24a8bb50also encapsulates the four aside-coordination statics intoSlotAside(SLOT_ASIDE_STATE) so the unit test runs on an isolated instance (eliminating the parallelsweep() -> slot_evict_ready()race incargo testand directly exercising empty-look backoff, in-flightapply_readyexclusion, and panic cleanup).host.rssweep()ordering (slot_evict_ready()vstake_idle_reclaim_request()): checkedcrates/victory-gpu/src/host.rs:910-917and intentionally kepthost.rsout of this PR to stay cleanly scoped toresource.rs/sampled.rsand avoid conflicting with#4558's hunk ontake_idle_reclaim_request(). Even withslot_evict_ready()right aftertake_idle_reclaim_request(), no second burst can launch when a ready batch is pending:slot_look_aside()claimslookingand immediately returns ifhas_ready.load(Acquire)is set, andslot_evict_ready()then runs on the very next line of the samesweep(), applying the batch and publishingnext_ms(Release) before clearinghas_ready. (WhenVICTORY_SLOT_EVICT_ASIDE=0,has_readyis never set; for F7/F8 forced flushes, backoff is bypassed regardless of order.)Verification on
24a8bb50(base5fabb46e):cargo test --locked -p victory-gpu --lib -- resource::tests:: sampled::tests::: 72 passed, 0 failed, 1 ignoredcargo test --locked -p victory-gpu --liband-- --test-threads=1: 1096 passed, 0 failed, 66 ignoredcargo test --locked -p victory-gpu --features diagnostics --test replay --test replay_big: 1 passed, 0 failed, 1 ignoredcargo clippy -p victory-gpu --all-targets --all-features --locked --no-deps: 0 warnings inresource.rsandsampled.rs(onlymain's 5 pre-existing warnings infont.rs/menu.rs/panel.rs, tracked in#4707)cargo xtask policy(and--staged): 464 files ok / 1 files ok@nidea1 on GitHub · 2026-12-01 12:33 UTC · original
Live runtime verification on updated
SlotAsidehead24a8bb50(RTX 3060 Ti 8 GB (ReBAR off, driver621.40), 32 GB RAM, Windows 11, Series S, DLSS Quality, FSR 3 FG, RT off,VICTORY_SAMPLED_EVICT=1,VICTORY_WINDOW_GROW=1,VICTORY_POOL_SMALL=0,VICTORY_RIPE_BLOCKS=12— 5-minute (300 sin-world,357 stotal) live validation on a combined 15-PR release build overorigin/main(5fabb46eaf).):300 sin-world (357 stotal) with0nvlddmkmevents (id153=0),0device hangs, and0Victory errors.VICTORY_SLOT_EVICT_ASIDE:16looks off the submitting thread (23.9 msavg,49.1 msmax),37,972textures evicted (561kept at second look, longest carry-out8.96 ms).VICTORY_SAMPLED_MARKS=1maintained fast 4-frame readback cadence throughout (6,390–6,516marked over last 4 frames;38,377index-picked slots nulled,4,795/12.5%requeued,33,582null at end).t=139..357 s): only1<2 seviction remake across the final 3.5 minutes; VRAM held steady at6,559 / 6,770 MB(-211 MBunder budget), Shared GPU RAM fell7,280 -> 5,980 MB.+31 s,+151 s,+285 s) checked clean with no missing/corrupt textures.Caveat: combined 15-PR release build over a 5-minute opening/cell sequence (not an isolated A/B or multi-hour driving session).
@andrewpozdnakov7-jpg on GitHub · 2026-12-01 13:12 UTC · original
24a8bb50keeps the fast readback cadence while indexed evictions wait. There is a heap-lifetime case: destroying a shader heap removes it from the heap registry, but its slots remain inEVICTEDuntil those indices are marked again. An unused index can keep fast readback active after its heap is gone. The same condition is also in #4891.b118f9cc records the indexed eviction while the heap is still registered, then removes that heap's entries when it unregisters. Entries for other heaps at the same index remain eligible to wake.
I ran the exact eviction registration, heap drop, and cadence functions in one Windows Rust fixture with two synthetic heaps and stubbed descriptor writes. The author head kept all three entries and a four-frame cadence after both heaps closed. The patch kept the remaining heap's one entry and four-frame cadence after the first close, then zero entries and the normal 30-frame cadence after the second. The staged asset check passed for both files. The fixture checks host state and scheduling.
Please keep the Git author on cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if folding the change in.AI-assisted with OpenAI Codex.
@nidea1 on GitHub · 2026-12-01 14:48 UTC · original · edited 2026-12-01 15:09 UTC
Thanks @andrewpozdnakov7-jpg for catching the
Heap::drop/EVICTEDlifetime leak and providing the fix!Cherry-picked
b118f9cc77onto this branch as7b5b09d99ewith your original Git author preserved, and added unit + concurrency tests (006d953c8a,14c87fec33):descriptor::tests::dropping_a_shader_heap_forgets_its_evicted_slots_and_restores_cadence: shared/unique slot cleanup onHeap::drop, unregistered heap drops, staleevict_slots, and cadence restoration back toSWEEP_EVERY(with consistent lock-heldevicted_snapshot()and test serialization guardevicted_test_lock()).resource::tests::indexed_evict_slots_forgets_heap_on_drop_and_concurrent_release: end-to-end liveHostHeapevict_slots(..., indexed = true)->Heap::dropcleanup plus a 16-round barrier-synchronized concurrentevict_slotsvsHeap::droprace check.Verified on
14c87fec33:cargo test --locked -p victory-gpu --lib -- resource::tests:: sampled::tests:: descriptor::tests::: 91 passed, 0 failed, 1 ignoredcargo test --locked -p victory-gpu --lib -- --test-threads=1: 1098 passed, 0 failed, 66 ignoredcargo test --locked -p victory-gpu --lib: 1098 passed, 0 failed, 66 ignored (clean parallel pass; both eviction tests also passed 5/5 repeated parallel runs)cargo clippy --locked -p victory-gpu --all-targets --no-deps(default and--all-features): 0 warnings indescriptor.rs,sampled.rs, andresource.rs(onlymain's 5 pre-existing#4707warnings inhost/{font,menu,panel}.rs)cargo xtask policy: 464 files ok@trustno1-coder on GitHub · 2026-12-01 18:41 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