fix(gpu): keep slot_evict inside ring history and recycle card buffer heaps #362
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/362"
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 Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T16:48:11Z.
Fixes the
#282P0 #1 (slot_evictidle-cutoff ring mismatch) and P0 #2 (CardBumpPoolpinned heap growth) VRAM leaks (#276).Changes
slot_evict(crates/victory-gpu/src/resource.rs)slot_evict_idle_ms(budget, used, high)clamped to5_000..=60_000 msinsideRING's 120 s history instead of passingvram_keep_below'sKEPT_MS = 600_000, which causedring::frame_atto returnNoneand skip slot eviction until 10 minutes elapsed.(92%, 88%, 256 MiB)(VICTORY_SLOT_EVICT_PERCENT/LOW_PERCENT/MB, withVICTORY_SLOT_EVICT=0kill-switch) and lifted the tight-pressure threshold / uncapped sweep trigger to96%so steady-state VRAM stays stable without mid-scene eviction thrashing.CardPool(crates/victory-gpu/src/ahead.rs)CardBumpPoolbump allocator with bitset-backedCardBlock(CardPool) suballocation gated on both fence completion (card_fence >= last_fence) and full rest (alloc_mask == 0), plus aCardReclaimCOM drop hook matchingSharedBlock.slot_range_maskandfind_free_slotsbitset helpers acrossSharedBlockandCardBlock.CreateHeapbudget re-check inalloc_pooled_card(Dropfrees excess heap), extendedtrim_buffer_poolsto release idle empty card heaps, and addedlive_card_heaps=telemetry toaheadpool logging.Verification Gates
cargo +1.98.1-x86_64-pc-windows-gnu xtask policy->asset policy: 325 files okcargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu slot_evict --locked->3 passed; 0 failedcargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu ahead::tests --locked -- --test-threads=1->12 passed; 0 failedcargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings-> passcargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warnings-> passobjdump -pon plain--releasebuild -> standard Windows system DLLs onlyPaired Plain
--releaseA/B Benchmarks (vsmain@3efe907,Series Xparity, DLSS Quality)ab-main-3efe907-4k-90svsab2-pr-vram-4k-90s):6525 MB->6215 MB(-310 MB);room_false:100.0%->87.5%;pool_not_made:889->65126506(636 MBcard) ->21661(530 MBcard)card_heaps:116->62(live_card_heaps=48) while serving7426vs6450card buffers6.3 fps->6.35 fps(max_draws12832->13462);preparing:23.4 ms->21.35 ms;copyback:15.0 ms->13.65 ms;mapped()longest:20.5 ms->15.0 msab-main-3efe907-4k-drive120vsab2-pr-vram-4k-drive120):6891 MB(over=118 MB) ->6338 MB(over=0 MB,-553 MB)card_heaps:167->58(live_card_heaps=45) while serving10296vs8194card buffersmapped()longest:9.6 msab2-main-3efe907-1440p-90svsab2-pr-vram-1440p-90s):6124 MB->6090 MB;final_waiting:4190->3287;card_heaps:94->74(live_card_heaps=71)13.75 fps->13.5 fps(min FPS1.8->5.2 fps);mapped()longest:46.3 ms->10.0 ms--features diagnosticsVisual Verification (diag-pr-vram-1440p-90s, 90s 1440p)world_windows=20(max_draws=12750),crashes=0,used_max=5971 MB(over=0 MB,room_false=0.0%),final_waiting=2123,mapped_rate=1.1 ms/s(longest9.2 ms),pngs=24(lit=22/24,luma=100.09,near_black=0.06%,edge_energy=7.76,magenta=0.0%).frame-2086.png,frame-2094.png, andframe-2100.png: sharp architectural/foliage textures, natural lighting, clean water reflections, and crisp HUD overlays.Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T17:04:54Z.
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):noneSummary
This PR addresses two VRAM growth issues in
victory-gpu:slot_evict(crates/victory-gpu/src/resource.rs): Introducesslot_evict_idle_ms(budget, used, high)(clamped to5_000..=60_000 ms, linearly scaling down betweenmin(high, 95)%and96%) soframe_at(&ring, now_ms.saturating_sub(evict_idle_ms))stays withinRING's 120-second history instead of returningNonewhen callers passKEPT_MS = 600_000. Also updates defaultparse_slot_evict_settingshysteresis from(85%, 75%, 256 MiB)to(92%, 88%, 256 MiB)and raises the uncapped sweep trigger inslot_evictfrom92%to96%.CardPool(crates/victory-gpu/src/ahead.rs): Extracts sharedslot_range_mask/find_free_slotsbitset helpers and replaces the monotonicCardBumpPoolwithCardBlock/CardPool+ aCardReclaimCOM drop hook (SetPrivateDataInterface(&CARD_HEAP_KEY, ...)). Freed slot ranges are gated on both GPU submission completion (finished_sub >= freed_sub) andREST_MSbefore reuse, concurrentCreateHeapcalls re-checkpool.takeunder lock (dropping the extra heap outside the lock),trim_buffer_poolsreleases idle empty card heaps, andlive_card_heapsis logged innote_pool_progress.Review Findings
slot_evict_idle_msusesu128for percentage math, handlesbudget == 0, and clampsstartto95 * 100(< end = 96 * 100), avoiding overflow or divide-by-zero even whenVICTORY_SLOT_EVICT_PERCENT=97.CardReclaimCOM refcounting andattach_card_reclaimproperly avoid double-retire or leaks onSetPrivateDataInterfacefailure (forget(object)+drop(Box::from_raw(made)), followed byCARD_POOL.lock().cancel(...)).ID3D12ResourceorID3D12Heapis dropped while holdingCARD_POOL(including inalloc_pooled_cardandtrim_buffer_pools), avoiding recursivecard_reclaim_releasedeadlocks.SharedBlock(which tracksever_usedand zeroes recycled ranges viawrite_bytes),CardBlockrecycles GPU heap ranges without clearing them. Whilealloc_pooled_card's doc comment was updated to drop"zero-initialized", the module doc comment at the top ofcrates/victory-gpu/src/ahead.rsstill states buffers fromaheadmatchHost::uav_bufferas "new, zeroed". Please confirm during local GPU testing (and across allalloc_pooled_card/uav_buffercallers) that no caller reads unwritten bytes from a recycled card buffer without initializing them first.fix(gpu/ahead): replace bump-only CardBumpPool with fence-gated recycling) modifies the sameCardBumpPoolregion incrates/victory-gpu/src/ahead.rs. Maintainers should coordinate which PR lands and close/supersede the other.none); ensure workspace tests and clippy pass on CI alongside local GPU validation.Verdict
needs-gpu-test— Logic and safety look solid with unit tests covering both changes, but this PR modifies D3D12 placed-resource heap recycling and VRAM eviction thresholds and warrants a local real-GPU smoke test (including D3D12 debug layer validation for placed-resource lifetime/aliasing) before merging.Generated with Antigravity CLI (
agy).Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T17:06:09Z.
Architect Review (plain-
--releaseA/B +--features diagnosticsvisual PNGs verified):6,891 MB(118 MBover) ->6,338 MB(0 MBover,-553 MB),card_heaps 167 -> 58(live_card_heaps=45); 4K 90s-310 MBVRAM,preparing 23.4 -> 21.35 ms,copyback 15.0 -> 13.65 ms; 1440pfinal_waiting 4,190 -> 3,287,min FPS 1.8 -> 5.2,mapped()longest46.3 -> 10.0 ms,0crashes.diag-pr-vram-1440p-90sframe-2086.png,frame-2094.png): clean textures, foliage, reflections, lighting, and HUD (6/6 gates PASS).#355(noCardZeroer/host::settle()stall, includes bothfinished_sub >= freed_suband 500 msREST_MSrest window).checks=[](no GitHub Actions CI run recorded on9d487e3ayet — please push/rebase ontomainto trigger CI). While touching the branch, consider adding+ crate::queue::queued()tostarted_subincard_reclaim_release(readingqueued()beforesubmissions().0, matching#335/#282P1 #21) so thin-mode queued submissions are always covered even if a queue stalls > 500 ms. Once CI is green, this is ready to merge immediately (and supersedes#355)!