GPU: bound idle staging, shadow snapshot, arena, and list scratch pools #3442
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3442"
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 Marvisak/VIctory. Originally posted by Luislariosss on 2026-11-27T02:23:07Z.
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):Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T02:26:57Z.
Review: APPROVED
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).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T02:40:12Z.
Review: APPROVED
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().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).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).Imported from Marvisak/VIctory. Originally posted by farhankhan8571811-star on 2026-11-28T10:12:34Z.
I benchmarked the snapshot pool at this head (
5876166d) against main (63bcca43), #3230 and #3384 in a CPU-only harness. Pool code is copied verbatim from each head; the caller (Shadow::writing's merge and the copy-back return) is ported once from main, as it is the same at all four heads apart from #3384'sPOOL.call syntax. The workload is synthetic: no game files, no GPU. Claim: https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7226578104In 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:
CORRECTIONS.md.https://github.com/farhankhan8571811-star/victory-snapshot-pool-bench
AI-assisted (Claude Code).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.