Repository navigation
Conversation
…line/heap metadata
Dukestar69
left a comment
There was a problem hiding this comment.
Verified on RTX 5090 against origin/main (63bcca4):
cargo test -p victory-gpu --lib shadow:: -- --test-threads=1: 11/11 passed (includingsnapshot_pool_trims_after_idle_window).cargo test -p victory-gpu --lib pipeline:: -- --test-threads=1: 24/24 passed (includingnote_created_counts_total_and_distinct_keys);texture::: 2/2 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Cleanly reclaims idle snapshot/staging pools and compacts pipeline/heap metadata.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
Tested Two things from reading it:
AI-assisted (Claude) |
|
Thanks for catching both! Updated PR #3230:
|
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed and verified bc4382251a2ec76003877fdd1f787acb4d9bb6c8 on both RTX 5090 and WARP with VICTORY_D3D12_DEBUG=1.
Checks run:
cargo xtask policy— passcargo clippy --tests -p victory-gpu -- -D warnings(default and--features diagnostics) — cleanshadow::tests(10/10),pipeline::library::tests(12/12),texture::tests(2/2),memory::tests(8/8 on WARP, 7/7 on RTX 5090 excluding the pre-existinglists_share_a_table_and_copies_keep_their_viewsbaseline failure),descriptor::tests(7/7 on WARP) — all pass with 0 D3D12 Debug Layer errors- Live probe exercising
texture::recycle()across two 64-submission windows (36 MiB -> 36 MiB -> 4 MiBunder the 8 MiB spare cap) andScratch's 16 MiBcapacity()retention check — passes cleanly on both RTX 5090 and WARP with 0 Debug Layer errors.
Lifetimes and locking look sound: texture::recycle() runs in bindless::uploads (bindless.rs:204) before the next submission's uploads once the prior submission has completed, shadow::trim_snapshot_pool() runs in host.rs:1429 after GPU completion and release_retired(), and std::mem::take(&mut *pending) (descriptor.rs:101) releases the pending vector's capacity while holding the lock before publishing OnceLock.
One non-blocking edge case worth polishing in a follow-up (crates/victory-gpu/src/shadow.rs:132-139):
- In
SnapshotPool::trim_to,total += v.capacity(); total <= max_byteskeeps adding dropped buffers' capacities intototal. Since buffers are sorted descending, if a single pooled buffer exceedsbudget(e.g.[64 MiB, 16 MiB, 8 MiB]trimmed toPOOL_SPARE_BYTES = 32 MiB),totaljumps to 64 MiB on the first buffer and evicts the 16 MiB and 8 MiB buffers as well (emptying the pool to 0 bytes instead of retaining 24 MiB of warm spare buffers). Guarding the increment fixes it:self.buffers.retain(|v| { if total + v.capacity() <= max_bytes { total += v.capacity(); true } else { false } });
LGTM!
|
Wine verification at clean exact head VICTORY_SOURCE_DIR="$PWD/VIctory-pr3230" \
/usr/bin/bash .compat-tools/cargo-victory-wine.sh \
test -p victory-gpu --lib shadow::tests::snapshot_pool_trims_after_idle_window \
-- --exact --nocapture --test-threads=11 passed,0 failed/ignored,0.00s reported test time; fresh compilation8.12s from the intended checkout, total guarded command8.85s. Rust1.98.1 Windows-MSVC, Wine11/Linux6.17, i7-13620H/15693MiB RAM. CPU ownership/pool policy only: no D3D12 device or GPU execution in this fixture. No source changes; touching crate roots only forced correct shared-target provenance. The fixture checks the first window retains its96MiB peak demand despite a taken buffer being dropped, and the next idle window trims the two retained32MiB buffers to one. It does not touch/measure all reserved pages, prove an RSS delta, or test title progress. Evidence: Not tested: matched base, title, full suite, physical RAM release or staging GPU fences. This bounds/reclaims idle snapshot capacity, not aggregate live shadows/XMem/process RAM. Our older main owner census sampled idle snapshots/standalone staging at zero; that is a different stack/stage, not proof they remain zero in the later scoped-backing stack. No new title trial justified by this isolated pass. The already-discussed oversized-leading-buffer over-trim remains a warm-spare-policy edge, not new evidence from this run. AI assistance: omp ( |
|
Thanks @fuzeofficlal for the review and catching that edge case! Fixed |
|
I benchmarked the snapshot pool at this head ( The idle trim releases memory in most cases I tried. It has a reload cost, and in one case its trim windows run but evict nothing. The sequence is load (230 world submissions) → idle (1000 small-only submissions, eight trim windows) → reload (230):
The cost is re-allocation in the first one or two reload submissions. Observed reload p50 medians were within 0.9 ms of main's; no equivalence test was performed. Maxima varied up to 2.7× between repeated same-seed runs, so the last column is approximate. Where it does not work: a large set in pieces that fills the 512 MiB cap (256 MiB in 4 growth steps: 64 + 128 + 192 + 256 MiB).
Hypothetical variants, to separate the two effects (not proposals):
Each has a measured cost, so I'm not suggesting one. Counting 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, or one submission late), not upstream's (returned when the shadow's last pending range completes, not measured); sizes are assumptions, and 174 MiB is the earlier-discussed heap size; page faults are process-wide, so none are attributed to the pool; pool figures are pool bytes, not process commit, unless "peak commit" is stated; 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
Reclaims idle host memory held by internal pools and metadata after loading spikes, without lowering burst ceilings or regressing active frame performance.
Changes
shadow::POOL(shadow.rs,host.rs): Keeps the 512 MiB burst ceiling (POOL_BYTES), but tracks peak live demand across 128-submission windows (trim_snapshot_pool()called once per submission inHost::execute) and trims excess pooled buffers down to recent peak demand (floorPOOL_SPARE_BYTES = 32 MiB).texture::BUFFERSand bounded per-threadScratch(texture.rs): TrimsBUFFERS.freedown to recent 64-submission peak usage (floor8 MiB, ceiling64 MiB), and caps per-threadScratchretention at8 MiBcheckingcapacity() <= KEEP(avoiding 32 MiB/thread permanent retention).Heap::pendingvector (descriptor.rs): Usesstd::mem::take(&mut *pending)when initializingHostHeapso the boot-timeVec<u32>capacity is freed immediately.library::CREATED(pipeline/library.rs): Stores 16-byte BLAKE3 key prefixes ([u8; 16]) instead of heap-allocatedStrings for 60k+ created pipeline keys.BITMAP_POOL_CAP(memory.rs): Lowers the idle dirty-page bitmap pool cap from64(16 MiB) to16(4 MiB).Verification
cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warningscargo xwin clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warningscargo test -p xtask --locked(6/6 passed)snapshot_pool_trims_after_idle_window,note_created_counts_total_and_distinct_keys,mark_runs_are_reused_and_joined,memory::tests::bitmap_pool_reuses_and_zeroes_across_resets+ 5 non-DXCmemory::testspassed (9/11 passed; the 2 DXC-dependentmemory::testsfail on Wine'sd3dcompiler_47due to pre-existingE5017: Unbounded resource arrays).Partial Overlaps / Related PRs
#2153and#472also touchshadow::POOL(lowering the hard cap or draining on allocation failure); this PR preserves the 512 MiB burst cap and trims only after idle submission windows.#2972trimstexture::Chunks,HostList::scratch, andshadow::Arena; this PR covers the complementarytexture::BUFFERS, per-threadtexture::Scratch,shadow::POOL,Heap::pending,library::CREATED, andmemory::BITMAP_POOL_CAP.