Repository navigation
GPU: bound idle staging, shadow snapshot, arena, and list scratch pools - #3442
Luislariosss wants to merge 1 commit into
Conversation
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on Windows (RTX 5090):
cargo test -p victory-gpu --lib shadow::(10/10),texture::(3/3, includingstaging_chunks_kept_defaults_to_four_and_respects_env), andhost::(34/34 excluding the pre-existingorigin/mainRTX 5090dynamic_slots_are_held_until_releasedfailure) all passedcargo clippy -p victory-gpu --all-targets -- -D warningspassed with 0 warningscargo xtask policypassed (191 files ok)
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal
left a comment
There was a problem hiding this comment.
Looks good to me — clean, disciplined idle-pool trimming across scratch, snapshot, arena, and texture staging pools with proper lock-free resource drops and safe env-var parsing.
Review & Verification Notes
crates/victory-gpu/src/host.rs:1792-1812:HostList::resettrims scratch chunks past1 MiB(keeping at least one chunk) only when the list is idle, dropping excess chunks outsideself.scratch.lock().crates/victory-gpu/src/shadow.rs:120-148, 711-715, 1137-1295:VICTORY_SHADOW_POOL_MBusessaturating_mul(1 << 20)safely across0, invalid, and huge inputs;Arenatracks live slots asVec<Option<ArenaChunk>>, returns completely empty chunks pastARENA_SPAREto be dropped afterarena()releases the lock, reusesNoneholes without invalidating remainingSliceindices, and updateslog_viewsto iterateflatten().crates/victory-gpu/src/texture.rs:115-205:recycle()lowers default idle retention (KEPT_BYTES = 16 MiB,DEFAULT_CHUNKS_KEPT = 4, overridable viaVICTORY_TEXTURE_STAGING_CHUNKS) and drops excess chunks outsideCHUNKS.lock().- Verified locally on
5876166d:cargo xtask policypasses (191 files ok).cargo clippy -p victory-gpu(--lib,--tests, and--features diagnostics--lib/--tests,-D warnings) is clean.shadow::tests(9/9) andtexture::tests(3/3) pass on discrete D3D12 hardware (VICTORY_D3D12_DEBUG=1,VICTORY_D3D12_GBV=1) and WARP (--features diagnostics,VICTORY_D3D12_DEBUG=1,VICTORY_D3D12_WARP=1).- Also verified edge-case probes on discrete D3D12:
pool_bytes_forbounds (0, negative, non-numeric,usize::MAX),Arenaempty-chunk eviction &None-slot reuse preserving live slice indices, andHostList::resettrimming 4 scratch chunks back down to 1 (524,288B).
…2 MiB The pool of host snapshot buffers kept for reuse between submissions held up to 512 MiB past its largest buffer. On a 16 GB machine that is idle commit the title could use. The cap is now 128 MiB by default and can be set in MiB with VICTORY_SHADOW_POOL_MB (the switch name of the source PR). The largest buffer is still always kept, as before. Only the snapshot pool part of the source PR is ported: its staging chunk, view arena and list scratch changes do not map onto our code, which manages those pools differently. Source: Marvisak/VIctory pull request #3442 (GPL-3.0) Marvisak/VIctory#3442 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I benchmarked the snapshot pool at this head ( In this synthetic model the 128 MiB default regresses several cases, and the boundary is not one snapshot size. Real world submissions weren't measured, so this is a regression case worth checking, not a gameplay finding. Steady state, 460 world submissions per run, medians over 5 seeds, p50 host time per submission. "Requested" sums every take in one submission, including each growth-chain piece. Main misses 0.05–0.13% in every row.
Per seed, p50 is 2.5–3.8× main's at 96 MiB in 4 steps, and 4.7–6.4× from 174 MiB up.
I'm not suggesting a default; that needs real per-submission sizes. The idle trims I measured (#3230 and variants) each have a measured cost too. Limitations: the submission mix is a model, not a capture; marked writes (which skip snapshots) aren't modelled; snapshot lifetimes are the harness's (returned at copy-back), not upstream's (returned when the shadow's last pending range completes); 174 MiB is the earlier-discussed heap size, not a measured snapshot; page faults are process-wide, so none are attributed to the pool; one Windows machine at 79–95% memory load (at run end), single-threaded, 5 seeds per case, no significance test. With real per-submission snapshot sizes I can rerun. Harness, pins, scripts, raw results and reproduction steps: 1,240 original runs plus 631 targeted follow-up runs (36 superseded runs kept, labelled). Byte-for-byte snapshot verification: 6,288 submissions, then 96,096 snapshots, 0 failures. Corrections to my earlier write-ups: https://github.com/farhankhan8571811-star/victory-snapshot-pool-bench AI-assisted (Claude Code). |
Summary
Bounds four idle GPU/host memory pools that previously retained over 1 GiB of Private Commit across steady-state frames:
texture.rs): lower defaultCHUNKS_KEPTfrom16(512 MiB ofD3D12_HEAP_TYPE_UPLOAD) to4(128 MiB), overridable viaVICTORY_TEXTURE_STAGING_CHUNKS, and lowerKEPT_BYTESfor oversized power-of-two staging buffers from64 MiBto16 MiB(still covering the 12.7 MiB movie upload path). Excess chunks are drained and dropped outsideCHUNKS.lock().shadow.rs): lower defaultPOOL_BYTESfrom512 MiBto128 MiB, overridable viaVICTORY_SHADOW_POOL_MB.shadow.rs): release completely empty 16 MiBArenaChunks pastARENA_SPARE = 1(preserving existingSliceindices viaOption<ArenaChunk>slots and dropping releasedID3D12Resources outsideARENA.lock()).host.rs): onHostList::reset(), trim grown scratch chunks past1 MiB(keeping at least the first chunk, and dropping excess chunks outsidescratch.lock()).Validation
cargo test -p victory-gpu --lib -- texture:: shadow:: host::tests::list_scratch: 14/14 passed (including new env-override and excess-arena-chunk release assertions).cargo clippy -p victory-gpu --all-targets -- -D warnings(default and--features diagnostics): clean.cargo xtask policy: 191 files ok.2,048frames presented,0errors):