Repository navigation
GPU: pool HostList device-local UAV buffers and wire ahead::card_if_ready - #884
Starchaser1024 wants to merge 1 commit into
Conversation
- Add `UAV_SPARE` (`crates/victory-gpu/src/host/uav_pool.rs`) to pool `COMMON`-state device-local scratch UAV buffers for `HostList::card_budget`, `indirect_scratch`, `batch_place`, and `place::between` across resets and list drops (`IDLE_MOST` overflow and `VICTORY_ALLOCATOR_TRIM` idle trim), eliminating thousands of synchronous `CreateCommittedResource` + `MakeResident` + `mapped()` stalls. - Key `UAV_SPARE` by exact `Width` in power-of-two multiples of 64 KiB (up to 16 MiB per item) while keeping `Host::uav_buffer` strictly zero-initialized for `Shadow` callers; transition `between` buffers back to `COMMON` at `HostList::close` and gate dropped list returns behind `RETIRED_UAVS` until in-flight GPU submissions finish. - Cap `UAV_SPARE` at 256 MiB (128 MiB on `<= 32 GiB` hosts), add `VICTORY_UAV_POOL` (`=0` disables pooling), and trim idle or pressured entries in `Host::sweep` and `trim_spare_chunks` with a 16 MiB warm floor. - Add `ahead::card_if_ready()` so `Host::uav_buffer(64 KiB)` reuses pre-made 64 KiB card buffers once `CARD_WANTED` is active without spawning `victory-ahead` during `victory warm`.
|
Build break when this is merged on top of #1012 (found while building a play-test stack; both PRs are currently #1012 gave For - && let Some(buffer) = UAV_SPARE.lock().unwrap_or_else(|e| e.into_inner()).take(size)
+ && let Some(buffer) = UAV_SPARE
+ .lock()
+ .unwrap_or_else(|e| e.into_inner())
+ .take(size, |_| true)I run exactly that in a 12-PR stack (#1002 #989 #1005 #65 #1014 #884 #941 #816 #797 #933 #934 #614 #1012) — green build here: https://github.com/Alxspb/VIctory-NVIDIA/actions/runs/46145821590 (the failing run before the fix: https://github.com/Alxspb/VIctory-NVIDIA/actions/runs/46145596521). Verified on an RTX 5060 Ti 16 GB / i5-13600KF, Series S job + DLSS Quality + 2x frame generation; the pool's own debug-layer reuse test is part of that stack, and If you would rather take the other direction (a |
|
Thanks @Alxspb for testing Agreed — keeping 1-arg |
…are matcher Merged-in trustno1-coder#1184 met trustno1-coder#933 lock-free copied[] and trustno1-coder#884 Spare::take matcher; adapt both calls instead of reintroducing a lock.
…er the submission fence # Conflicts: # crates/victory-gpu/src/host.rs
Summary
Pools
COMMON-state device-local scratch UAV buffers used byHostList(card_budget,indirect_scratch,batch_place, andplace::between) across list resets and drops, and wiresahead::card_if_ready()intoHost::uav_buffer— addressing the remaining per-list device-buffer churn noted in #57 (~13,500buffers /7.5 sof synchronousCreateCommittedResource+MakeResident+mapped()fence waits per 5 minutes, amplified now thatVICTORY_ALLOCATOR_TRIMis on by default).Design & Safety Invariants
Shadowzero-initialization vs transientHostListscratch (crates/victory-gpu/src/host/uav_pool.rs,host.rs,ahead.rs):Shadow(take,dword_runs,by_address) andambientrely onHost::uav_bufferreturning a freshly zero-initialized buffer.Host::uav_buffertherefore strictly preserves zero-initialized semantics (consultingahead::card_if_ready()for64 KiBpre-made zeroed buffers onceCARD_WANTEDis active, without spawningvictory-aheadduringvictory warm).uav_pool::take_uav(host, size)serves the four transientHostListscratch consumers (make_card_budget,indirect_scratch,batch_place, andplace::between), each of which overwrites its region before reading.Widthpower-of-two bucketing:UAV_SPAREkeys by exactGetDesc().Widthin power-of-two multiples of64 KiB(64 KiBminimum up to16 MiBper item), socard_budget(64 KiB),batch_args(64 KiB),indirect_scratch, andplace::betweenshare unified buckets without alteringGetDesc().Widthexpectations.HostList::betweentracks buffers inDeferred::between_uavsand batch-transitions them back toD3D12_RESOURCE_STATE_COMMONinHostList::close()(between_common), matchingcard_budget_out,indirect_common, andbatches_common.reset()orDrop for HostList(IDLE_MOSToverflow andVICTORY_ALLOCATOR_TRIM), buffers pass throughretire_uavs: enteringUAV_SPAREimmediately when no submissions are in flight, or waiting inRETIRED_UAVSuntilbury(finished)observes their fence completion.256 MiB(128 MiBon<= 32 GiBhosts), gated byVICTORY_UAV_POOL(default1,=0disables pooling), and hooked intoHost::sweep()andtrim_spare_chunks()(16 MiBwarm floor under mild pressure /allocator_trim,0under critical commit or>= 95%VRAM).Benchmark & Verification (RTX 5060 Ti 16 GB, Windows 11,
--release)host::uav_pool::tests::bench_host_list_uav_pool_ab(7 rounds each):VICTORY_UAV_POOL=0VICTORY_UAV_POOL=1reset()+4x betweencopies across 64HostLists (256betweenbuffers/round)-124.54 ms)HostListcreate + record (card_budget+batch_place+2x between) + reset + drop churn1,792D3D12 UAVs made)0D3D12 UAVs made,1,792pool hits)-126.82 ms)host::uav_pool::tests::host_list_uav_pool_lifecycle_retire_trim_and_info_queue: verified underVICTORY_D3D12_DEBUG=1(0ID3D12InfoQueueerrors acrosscard_budget, mid-listindirect_scratchgrowth,batch_place,betweencopy,reset(), in-flight retirement, and trim).cargo test -p victory-gpu --locked: 457 passed, 0 failed.cargo clippy --workspace --all-targets --all-features --locked: 0 warnings in changed files.cargo xtask policy: 295 files ok.