perf(gpu/sweep): offload pressure trims off-thread and make slots_showing lock-free #278
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: launcher
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
run report
security: hold
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs gpu test
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Androtim--MiniVI!278
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/278/head"
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?
@Androtim on GitHub · 2026-12-01 08:01 UTC · original
Androtim:perf/pillar2-async-sweep-and-lockfree-slots→main· +302 −83 · 8 files · 1 commits · merged 2026-12-01 09:22 UTCSummary
Replaces three synchronous submitting-thread bottlenecks in
sweep()/slot_evict()under steady-state host pressure without adding opt-in toggles:host.rs,host/uav_pool.rs,list.rs,shadow.rs):crate::host::drop_aside(a dedicated background reaper thread) so D3D12ID3D12Resource::Releaseand largeVec<u8>VirtualFreedrops fromtrim_spare_chunks_with,give_list_uploads,ReadbackPool::trim,uav_pool::account_trimmed,list::trim_on_pressure,shadow::trim_snapshot_pool, andshadow::give_backno longer stall the submitting thread.< 1.5 GiB):16 MiBspare scratch chunks,8 MiBper list-upload pool,256idle host command lists (64on critical), and4/16 MiBCPU snapshot buffers, stopping per-second allocator/list thrashing while keeping full draining under critical commit (trim_spare_chunksstill drains to0).HostHeap::slots_showing+AddressHash(descriptor/host.rs,descriptor.rs,resource.rs):self.kept_raw(AtomicUsize::load(Acquire)) instead of locking1,000,000+per-slotMutexes inself.kept.crate::host::ByCopy<usize>directly intoevictable_slots()(dropping the intermediateHashSetcopy and default SipHash).host_written_snapshot(texture.rs,resource.rs):HOST_WRITTENonce per sweep (before lockingTEXTURES) instead of acquiringHOST_WRITTEN's mutex~43,000+times per pass, and short-circuits inactive/recent textures inslot_evictonr.host.usedfirst.Verification
cargo +1.98.1-x86_64-pc-windows-gnu xtask policy(317 files ok,host.rswithin size cap, 100% title-neutral)--locked --test-threads=1):descriptor:::81 passed; 0 failed(includingslots_showing_from_raws_filters_zero_and_classifies_slots,slots_showing_reflects_keep_ref_updates)resource:::34 passed; 0 failedlist_upload_pool_tests:5 passed; 0 failed(includinglist_upload_spare_limit_keeps_warm_floor_until_critical,drop_aside_runs_drop_asynchronously)list:::17 passed; 0 failed(includingpressure_idle_cap_preserves_frame_working_set_until_critical)shadow:::49 passed; 0 failed(3 ignored; includingsnapshot_pressure_cap_keeps_warm_floor_until_critical)clippy --workspace --all-targets --locked -- -D warnings(default +--features diagnostics)Plain
--release60s A/B Benchmark (-PlayParity -Console series-x -DlssMode quality, NO--features diagnostics)Measured on RTX 4060 Ti 8 GB / i7-13700F / 32 GB RAM:
origin/main(ff6e5925)13.9 fps(72.0 ms, min4.5)14.75 fps(67.85 ms, min5.4)+0.85 fps(-4.15 ms)32.1 / 0.0 / 13.1 ms30.7 / 0.0 / 11.7 ms-1.4 / 0.0 / -1.4 msahead.part(14)(heaps & sweep)6.2–10.6 ms(mean7.84 ms)1.5–2.2 ms(mean1.70 ms)-6.14 ms/frame(-78%)over)6833 / 6724 MB(over=96 MB,49blocks)6695 / 6732 MB(over=0 MB,45blocks)-138 MB(over=0 MB)626 MBfree /0given back308 MBfree /1given back-318 MBfree wasteuploaded/final_waiting)38304/1545340641/14297+2337/-11560/60/6@Androtim on GitHub · 2026-12-01 08:04 UTC · original · edited 2026-12-01 09:05 UTC
Automated triage for the maintainers (not an approval).
Verdict:
needs-gpu-test· CI (check):passingIndependent review of PR #278 (
15b4351217bd). Logic, lock ordering, and unit test coverage look solid, and CI is passing. Because this changes D3D12 host resource release timing (offloadingID3D12Resourcedrops to a background thread), host/VRAM pressure trim floors, and lock-free descriptor-heap scanning during slot eviction, it warrants a local real-GPU smoke test under memory pressure before merging.What was verified
crates/victory-gpu/src/host.rs,crates/victory-gpu/src/host/uav_pool.rs,crates/victory-gpu/src/list.rs,crates/victory-gpu/src/shadow.rs):host::drop_asidespawns a single"victory-reaper"background thread viaOnceLockand falls back to synchronousdropif thread creation or channel send fails. All pool accounting (ALIVE,UAV_SPARE_STATS,ReadbackStats,IDLEbyte totals) is updated synchronously before handing retired objects todrop_aside.sweep()passesresidency::critical_commit()intotrim_spare_chunks_with,shadow::trim_snapshot_pool, andlist::trim_on_pressure, preserving small warm floors under non-critical pressure (16 MiBspare chunks,8 MiBper list-upload pool,256idle lists,4/16 MiBsnapshot buffers) while still draining to0(64idle lists) when commit is critical.list_upload_spare_limitmatchestrim_spare_chunks_with'sLIST_UPLOAD_SPARE_MOST / 8non-critical pressure cap.shadow::trim_snapshot_pool, theif kept > 0 && total > max_bytescheck intentionally retains at least one buffer under non-critical pressure even if that single buffer exceeds16 MiB, and drains to0whencriticalis true.slots_showing+AddressHash(crates/victory-gpu/src/descriptor/host.rs,crates/victory-gpu/src/descriptor.rs,crates/victory-gpu/src/resource.rs):HostHeap::slots_showing_from_rawsscanskept_rawwithOrdering::Acquireinstead of acquiring per-slotkeptmutexes, short-circuits on emptyraws, and preserves the exacti < count && !sampler && tabled_lately(i)andseen_since(tabled_stamp(i), cutoff, frame)classification.evictable_slotstakes&crate::host::ByCopy<usize>directly, avoiding the intermediateHashSetallocation and default SipHash.host_written_snapshot(crates/victory-gpu/src/texture.rs,crates/victory-gpu/src/resource.rs):let_go_idleandslot_evictsnapshotHOST_WRITTENbefore acquiringtextures(), avoiding lock nesting. Any texture written by the host concurrently after the snapshot will have a freshr.host.usedtimestamp (andslot_evictre-checkslong_ago(r.host.used, ...)andArc::strong_count(host) == 1underr.host.made), so the snapshot is safe against concurrent writes.slot_evictonr.host.usedfirst avoids unnecessary descriptor/map lookups for inactive or recently used textures.Notes for local GPU verification
VICTORY_SLOT_EVICT=1) confirms no visual corruption, no stuck/leaked host commit from the"victory-reaper"queue, and clean process exit while D3D12 resources are being dropped off-thread.Generated with Antigravity CLI (
agy).@Androtim on GitHub · 2026-12-01 09:22 UTC · original
Architect & Strict-Gate Review (plain
--releaseA/B vsff6e5925, CI passing,minivi-triageverified on15b43512):All strict merge gates pass cleanly with zero new
VICTORY_*opt-in toggles and zero visual/shader-path changes:13.9 -> 14.75 fps(+0.85 fps,-4.15 ms/frame, min4.5 -> 5.4)32.1 -> 30.7 ms(-1.4 ms,ahead.part(14)-78%) /13.1 -> 11.7 ms(-1.4 ms)6833/6724 MB (over=96 MB)->6695/6732 MB (over=0 MB)(-138 MB,room_false 100.0% -> 93.3%,1pool block returned,-318 MBfree-pool waste)uploaded 38,304 -> 40,641(+2,337),final_waiting 15,453 -> 14,297(-1,156)0crashes/DRED,untranslated = 6 -> 6Squash-merging into
main.