GPU: reclaim idle snapshot and texture staging pools and compact pipeline/heap metadata #3230
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
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
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
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/Marvisak--VIctory!3230
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3230"
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?
@0xKaji on GitHub · 2026-11-26 13:49 UTC · original
0xKaji:perf/reclaim-idle-pools-and-metadata→main· +134 −32 · 6 files · 1 commits · openSummary
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.@Dukestar69 on GitHub · 2026-11-26 14:08 UTC · original · approved these changes
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).
@potatoe0100 on GitHub · 2026-11-26 14:11 UTC · original
Tested
d2d85cbmerged ontomain63bcca4on an RTX 4060 8 GB (driver 621.14, i5-13600KF, Windows 11 Pro 26300). No game files.cargo test -p victory-gpu --lib --locked -- --test-threads=1gives 231 passed and 2 failed. The newsnapshot_pool_trims_after_idle_windowandnote_created_counts_total_and_distinct_keyspass. The 2 failures are the known capped-heap ones (#1835), the same as onmainwith this card.Two things from reading it:
SnapshotPool::live_bytescan only drift upward.takeadds a buffer's capacity andgive_backsubtracts it. But snapshot segments only go back throughgive_backinShadow::snapshot(merging) and whenpendingempties.impl Drop for Shadowreturns its slice and marks, notsegments. So if a copy is dropped while a snapshot is still pending, its bytes stay counted as live forever.step_windowthen setspeak_bytes = live_bytes, so over a long session the trim budget creeps up toPOOL_BYTESand stops trimming. That's harmless, but it's the opposite of what the PR is for. One option is to count the bytes taken within each window instead of a running live total, so nothing has to be given back to keep the count right.Scratchkeep limit 32 MiB → 8 MiB. A 2048×2048 RGBA8 texture needs a 16 MiB scratch, so those are no longer reused. On this CPU, a fresh 16 MiBVecfilled once costs 4.8 ms, against 0.7 ms reused, because of first-touch page faults (8 MiB: 2.1 vs 0.5 ms; 32 MiB: 7.3 vs 1.8 ms; a standalonerustc -Oloop, median of 20). That's about 4 ms more per such texture on the thread preparing the frame, while streaming. Unless the 24 MiB per thread is a real problem, 16 MiB, or keeping the old 32 MiB with thelen→capacityfix, may be a safer default. Thecapacityfix itself looks right.AI-assisted (Claude)
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.