perf(gpu/mem): add safe title-private working-set trimming via VICTORY_TRIM_BELOW_MB (#276) #384
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/384"
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 Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T10:43:16Z.
Summary
Adds safe, paced working-set trimming of cold title-private RAM pages when host physical RAM runs low (
VICTORY_TRIM_BELOW_MB), targeting 16 GiB RAM systems without risking GPU device loss (0x887A0005).Adapted from GPL-3.0
LinkoArts/VIctorycommits7839a18and2fa2113(originally derived fromtshadofr/Leilapatches0012and0055), with two clean refinements:in_placerange subtraction once per region instead of twice.base.checked_add(len)bounds, half-openat..endremoval on sub-decommits, andallocation_base(at)normalization inopened_whole.1536 MiBfree-RAM threshold on<= 20 GiBtotal RAM hosts whenVICTORY_TRIM_BELOW_MBis unset, while remaining disabled (0) on> 20 GiBhosts unless explicitly set.Safety Invariants
watch::title_memory_allocated/title_memory_freed), D3D12 in-place host heaps (inplace::open), and write-combined ranges (shadow::write_combined_ranges).VICTORY_TRIM_GENTLE=1) trims strictlyMEM_COMMIT+MEM_PRIVATEpages belonging to tracked title allocations after subtracting all in-place heaps and write-combined ranges, and never touchesMEM_IMAGE,MEM_MAPPED,PAGE_WRITECOMBINE,PAGE_GUARD,PAGE_NOACCESS, runtime heaps, stacks, or driver allocations.2s, trims at most once per30s, and requires+2048 MiBworking-set growth since the previous settled trim.Verification
cargo test -p victory-gpu --lib trim::tests(4 passed)cargo clippy -p victory-gpu --all-targets -- -D warnings(clean)check#282)VICTORY_TRIM_BELOW_MB=16000)Related: #276
Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-03T11:05:25Z.
3-Gate Verification Summary (
4c9bde6)check):PASS(4m06s)VERIFIED CLEAN (0 P0, 0 P1)—[P1]scan-to-unlock TOCTOU race eliminated viaOPEN_LOCK+STATE_GEN+ per-chunkVirtualQueryre-verification (5fe71eb), andshadow::write_combined_regionscontract preserved (4c9bde6).VICTORY_TRIM_BELOW_MB=24000):PASS— 3 active gentleVirtualUnlocktrim passes mid-gameplay,0DRED,00x887A0005, peak dedicated VRAM5529 / 6736 MiB, crisp visuals.Ready for merge!