perf(victory-gpu): add opt-in ram_trim foundation (Part 1, default OFF) #350
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/350"
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 LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-26T11:03:31Z.
Summary
Part 1 of the host System RAM trimming split requested in review: adds only the standalone, opt-in (
VICTORY_RAM_TRIM=1, default OFF)ram_trimfoundation on top of currentmain(132da61). No consumer modules (shadow.rs,pool.rs,host.rs,pipeline.rs,texture.rs,list.rs) are modified in this PR.Split & File Layout
third_party/victory/crates/victory-gpu/src/lib.rs(195 lines): exposespub mod ram_trimram_trim.rs(34 lines): module entrypoint & re-exportsram_trim/policy.rs(262 lines): host RAM tier/status and opt-inTrimPolicy(TrimPolicy::cached()returns inert thresholds unlessVICTORY_RAM_TRIMis1/true/on)ram_trim/metrics.rs(118 lines): atomic trim/reload counters & diagnostics lineram_trim/vm.rs(287 lines) &ram_trim/vm_windows.rs(320 lines):MEM_PRIVATEreservation/decommit helpers,verify_safe_for_decommit(non-resettingGetWriteWatch, rejectsMEM_WRITE_WATCH/MEM_MAPPED/MEM_IMAGE), andVmBlockram_trim/snapshot.rs(222 lines):SnapshotBuffer(Small/Large(VmBlock)) with checkedensure_commit,ensure_range_committed,as_slice_committed,read_committed_range, andwrite_committed_rangeram_trim/tests.rs(412 lines): unit tests for default-OFF policy, Win32 range safety guards, anddecommit_all-> read-through restoration on everyensure_commitaccess pathTHIRD_PARTY.md: added French credit row forfxceless/victory-fork#1286(Rule 10)Defaults & Honest Performance Note
VICTORY_RAM_TRIMunset/0-> zero automatic decommit, aging, or trimming).pool/host/listidle trim), Part 3 (shadow/watchopt-in snapshot trim), Part 4 (pipelinepost-PSO DXIL trim + PSO recreation test), each opt-in by default.Verification
Verified locally on Windows 11 (
third_party/victoryworkspace):cargo xtask policy(384 files ok)cargo clippy --no-deps -p victory-gpu --locked --all-targets(default &--features diagnostics: 0 errors, 0 warnings in changed/added lines)cargo test --locked -p victory-gpu --lib ram_trim::tests:: -- --test-threads=1(default &--features diagnostics, both HW and WARPVICTORY_D3D12_WARP=1)Checklist
Source:/Co-authored-by:trailers +THIRD_PARTY.mdrow)<= 320lines for all non-test modules)VICTORY_RAM_TRIM=1off by default)Imported from LooperSalty/AnyXboxX. Originally posted by Skyfrye on 2026-11-26T14:43:00Z.
For information: I tried this PR in an integration build on
mainat2cc6593(after #358 and #377), stacked with #354, #345 and my #278, #279, #292, #307, #360-#362, #381 and #382. It no longer applies tomain. The conflicts are in what the code does, not just neighbouring lines: host.rs (4), pipeline.rs (1: thebuilder_spilledcache against #377's ACCC part), texture.rs (7: the staging pool, which #289 reworked in #358), watch.rs (1). I left it out of that build rather than guess at the merge. A rebase on currentmainwould let it in the next one.🤖 Generated with Claude Code
Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-26T15:16:25Z.
@Skyfrye Rebased onto
mainat26c11d4(post-#358/#289, #377, and #383) at commit69a0a8c.Conflict harmonization summary:
texture.rs: Preserved #289/#358'sStageEntry/VecDequecross-class LRU eviction,[0..bytes)zeroing,zero_upload_tests, andStagePool::trimfull 0-byte idle drain (ram_idle_ms+ 4 frames); layeredram_trim::TrimPolicytightening additively on top whenpanic_memory || pool_idle_ms < upstream_idle_ms, and keptStagingdrops outsideSTAGINGlock.pipeline.rs: Preserved #377'sACCCfallback (victory_shader::emit::nvidia::enabled()) in bothtranslate()and insideof_builder()'s cachedbuilder_spilled.host.rs&host/scratch_tests.rs: Preserved #358's FIFO-evictingSpare::giveandResultRing(trim_card_work_withcheckswork.taken.used() == 0) alongsideSpare::trim/CardWork::fetched_ms, and preserved #383 (step_index,sync_batched,parallel_refresh).shadow.rs&watch.rs: Preserved #377 (after_writer) and #358 (Card::prints/me,note_carded,FLAGGED,window_same,page_writes_mode) cleanly alongsideSnapshotBufferandtitle_memory_remapped.Verified on
69a0a8c:cargo xtask policy(215 files ok),cargo clippy -p victory-gpu --lib --tests(0 new warnings),VICTORY_D3D12_DEBUG=1ram_trim14/14 andtexture::8/8 (victory-gpu --lib: 252 passed default / 265 passed--features diagnostics, with only the 3 pre-existingmainfailures indescriptor::hostandindirect::warp_card_{fetch,patch}). Ready for your next integration build.Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-26T19:19:16Z.
Noting that #409 (
37d4686) replacedthird_party/victorywith the combinedavatarmanz + cool_foxbase, putting this branch inCONFLICTING.The clean
avatarmanz-lineage version is open atavatarmanz/VIctory-7900XTX#205(andfxceless/victory-fork#1286); happy to re-port onto37d4686+once#409settles if you want it here.Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-27T13:02:07Z.
Rebased onto latest
main(b62053f, updatedthird_party/victorybase) inf81e8b9:ram_trim.rs(GlobalMemoryStatusEx/K32GetProcessMemoryInfohost-RAM-aware trim policy,MEM_PRIVATE | MEM_COMMIT+ non-resettingGetWriteWatch(0)safety guard,VmBlock,SnapshotBuffer), cold shadow snapshot / pooled buffer decommit,title_memory_remappeddead-page decommit (outsideGUARDS), aged 64 MiB staging-block reclamation, and post-PSO DXIL drop + cold shader container compression cleanly ontob62053f.--features diagnostics,VICTORY_D3D12_DEBUG=1,--test-threads=1):clippyclean on touched files;xtask policy(290 files ok); HWram_trim13/13,shadow::51/51 (3 ignored),pipeline::29/29 (1 ignored),pool::9/9,texture::6/6 (3 ignored),list::6/6; WARPram_trim13/13.Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-27T13:29:43Z.
Updated rebase onto latest
main(fa6b209) ine5e1696:75296ed's barrier-dedup tests inlist.rs, merged4228f76/1399bff'sdue_ms/copy_bytes/window_victimsaccounting inshadow.rs, and updated1d88f8b'spipeline/list_bench.rsto useTranslated::dxilandShader::with_container.--features diagnostics,VICTORY_D3D12_DEBUG=1,--test-threads=1):clippyclean on touched files;xtask policy(296 files ok); HWram_trim13/13,shadow::55/55 (3 ignored),list::8/8; WARPram_trim13/13.Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-27T21:24:06Z.
Thanks.
MEM_DECOMMITonly touches our own snapshot blocks andverify_safe_for_decommitrejects mapped, image and write-watched ranges, so the main risk is lower than it looked. Before merge:Source:/Co-authored-by:trailers and noTHIRD_PARTY.mdrow.ram_trim.rsat about 1,340 andshadow.rs+1,260: too large to review or bisect as one change (AGENTS.md: files under about 400 lines). Please split it:ram_trimfirst, then each consumer (shadow, pool, pipeline DXIL drop).VICTORY_RAM_TRIM=1is opt-in, but the automaticTrimPolicy, the DXIL drop after PSO creation, container compression and staging-block aging apply by default. Please give before/after RAM and fps, and a test showing a dropped DXIL is never needed again (for example after a PSO is recreated).ensure_commitpath afterdecommit_allwould show that no path reads zeroed pages silently.Imported from LooperSalty/AnyXboxX. Originally posted by Vladimir-Human on 2026-11-28T07:16:38Z.
Rebased on current
main(132da61) and split as requested into Part 1 (am_trim foundation only) at commit
a9ffceb:Source: fxceless/victory-fork #1286 (3f3ec37)andCo-authored-by:trailers plus the French row inTHIRD_PARTY.md.am_trim into focused modules (
am_trim.rs 34L, policy.rs 262L, metrics.rs 118L, snapshot.rs 222L, m.rs 287L, m_windows.rs 320L). Note: pre-split branch is preserved locally only for extracting Part 2–4 later.
TrimPolicy::cached()is completely inert by default (all thresholds/aging off unlessVICTORY_RAM_TRIMis1/true/on). Post-PSO DXIL trim + PSO recreation test and container compression are deferred to the separate pipeline PR (also opt-in default OFF).decommit_all->ensure_commitread-through coverage:ram_trim/tests.rsnow exercisesdecommit_allfollowed by every read/write path (ensure_commit,ensure_range_committed,as_slice_committed,read_committed_range,write_committed_range, cross-piece offsets, and zero-piece decommit) plusverify_safe_for_decommitrejections (MEM_WRITE_WATCH without resetting dirty bits, MEM_MAPPED, MEM_IMAGE).Verified locally with
cargo xtask policy(384 ok), hunk-accurateclippy(default &diagnostics: 0 own warnings), andram_trim::tests::passing on both HW and WARP. Gameplay RAM/FPS remains unmeasured.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.