perf(gpu): reduce host RAM footprint via VM decommit and pool/shader trimming #205

Open
Vladimir-Human wants to merge 1 commit from upstream-pr/205 into main
Vladimir-Human commented 2026-11-26 11:30:46 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Vladimir-Human on 2026-11-26T11:30:46Z.


Selective port of host System RAM reduction and Windows MEM_DECOMMIT VM reclamation from xceless/victory-fork#1286 onto vatarmanz/VIctory-7900XTX.

Summary

  • VM reservation / decommit & tier policy (crates/victory-gpu/src/ram_trim.rs, copystat.rs, lib.rs):
    • Introduces TrimPolicy (Tight16 / Standard32 / Large, 250 ms cached, pressure-aware, opt-in VICTORY_RAM_TRIM=1) and SnapshotBuffer / VmBlock using MEM_DECOMMIT over preserved MEM_RESERVE VA ranges with erify_safe_for_decommit (GetWriteWatch / mapped view guard).
    • Emits per-second RAM trim counters in copystat.rs diagnostics output.
  • VIctory-7900XTX pool, command-list, host, and texture trims (pool.rs, list.rs, host.rs, exture.rs):
    • pool::trim_idle_with &
      oom(): tracks Block::last_used_ms and releases aged whole-free 64 MiB upload STAGING (and under pressure/panic, TEXTURES) blocks outside pool mutexes even when VICTORY_RESIDENCY=1 is off, clamping SPARES so Ripe::now() / ake_ripe() does not immediately reallocate.
    • list::let_go_idle_with & host::HostList::take_idle_caches: drains cold idle lists and collects oversized indirect_args (>= 1 MiB) and surplus atch_args COM buffers, dropping COM references outside locks.
    • host::sweep: wires Spare::trim ( rim_spare_with), CardWork::fetched_ms + rim_card_work_with, and shrinks oversized states/ wins/
      otes buffers on HostList::reset.
    • exture.rs: shrinks > 4 MiB thread-local READ scratch past 4x spikes and drops idle Staging COM refs outside STAGING lock scaled by TrimPolicy.
  • Shadow VM reclamation & remap hooks (shadow.rs, watch.rs):
    • Moves POOL and Shadow::before onto SnapshotBuffer with nsure_commit across ind_all, writing, copy_back_with,
      elay_merge, merge_under_writes, placed_copy, and land_back.
    • Wires watch::{title_memory_remapped, title_memory_unmapping, title_memory_freed} outside GUARDS (resolving MEM_RELEASE len == 0 outside lock) to retire/decommit dead shadow pages while preserving monotonic EXACT.0, releases CPU efore snapshots when promoted to card, and provides opt-in cold/zero trim under strict pending -> before -> kept ordering.
  • Shader DXIL release & container compression (pipeline.rs, pipeline/host.rs, pipeline/known.rs):
    • Adds lock-free ContainerBlob (zlib-rs), DxilPin around PSO compilation,
      elease_dxil(), and rim_shaders_with across graphics and compute pipelines with transparent reload via shader_cache::host_shader.

Verification (CARGO_TARGET_DIR='D:\cargo-targets\xtx-base', CARGO_BUILD_JOBS=2)

  • cargo clippy -p victory-gpu --all-targets -- -D warnings (default & --all-features): 0 warnings.
  • VICTORY_D3D12_DEBUG=1 (--features diagnostics):
    am_trim 13/13 passed, pool::tests::trim_idle 2/2, host::spare 2/2, idle_trim 1/1 (0 D3D12 debug errors).
  • cargo test -p victory-gpu -- --test-threads=1: 387 passed; 0 failed; 34 ignored (
    am_trim OS commit stress via K32GetProcessMemoryInfo PagefileUsage: 267.3 -> 10.8 MiB, -256.5 MiB across rounds 0..2).
  • cargo test -p victory-gpu --features diagnostics -- --test-threads=1: 439 passed; 0 failed; 34 ignored +
    eplay 1/1 (
    am_trim OS commit stress: 356.9 -> 100.4 MiB, -256.5 MiB across rounds 0..2).
  • cargo test -p xtask: 9/9; cargo run -p xtask -- policy --staged: 265 files ok; git diff --cached --check: clean; git merge-tree --write-tree origin/main HEAD: clean.
<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6625717309 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/205). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-26T11:30:46Z. --- Selective port of host System RAM reduction and Windows MEM_DECOMMIT VM reclamation from xceless/victory-fork#1286 onto vatarmanz/VIctory-7900XTX. ### Summary - **VM reservation / decommit & tier policy (crates/victory-gpu/src/ram_trim.rs, copystat.rs, lib.rs):** - Introduces TrimPolicy (Tight16 / Standard32 / Large, 250 ms cached, pressure-aware, opt-in VICTORY_RAM_TRIM=1) and SnapshotBuffer / VmBlock using MEM_DECOMMIT over preserved MEM_RESERVE VA ranges with erify_safe_for_decommit (GetWriteWatch / mapped view guard). - Emits per-second RAM trim counters in copystat.rs diagnostics output. - **VIctory-7900XTX pool, command-list, host, and texture trims (pool.rs, list.rs, host.rs, exture.rs):** - pool::trim_idle_with & oom(): tracks Block::last_used_ms and releases aged whole-free 64 MiB upload STAGING (and under pressure/panic, TEXTURES) blocks outside pool mutexes even when VICTORY_RESIDENCY=1 is off, clamping SPARES so Ripe::now() / ake_ripe() does not immediately reallocate. - list::let_go_idle_with & host::HostList::take_idle_caches: drains cold idle lists and collects oversized indirect_args (>= 1 MiB) and surplus atch_args COM buffers, dropping COM references outside locks. - host::sweep: wires Spare::trim ( rim_spare_with), CardWork::fetched_ms + rim_card_work_with, and shrinks oversized states/ wins/ otes buffers on HostList::reset. - exture.rs: shrinks > 4 MiB thread-local READ scratch past 4x spikes and drops idle Staging COM refs outside STAGING lock scaled by TrimPolicy. - **Shadow VM reclamation & remap hooks (shadow.rs, watch.rs):** - Moves POOL and Shadow::before onto SnapshotBuffer with nsure_commit across ind_all, writing, copy_back_with, elay_merge, merge_under_writes, placed_copy, and land_back. - Wires watch::{title_memory_remapped, title_memory_unmapping, title_memory_freed} outside GUARDS (resolving MEM_RELEASE len == 0 outside lock) to retire/decommit dead shadow pages while preserving monotonic EXACT.0, releases CPU efore snapshots when promoted to card, and provides opt-in cold/zero trim under strict pending -> before -> kept ordering. - **Shader DXIL release & container compression (pipeline.rs, pipeline/host.rs, pipeline/known.rs):** - Adds lock-free ContainerBlob (zlib-rs), DxilPin around PSO compilation, elease_dxil(), and rim_shaders_with across graphics and compute pipelines with transparent reload via shader_cache::host_shader. ### Verification (CARGO_TARGET_DIR='D:\cargo-targets\xtx-base', CARGO_BUILD_JOBS=2) - cargo clippy -p victory-gpu --all-targets -- -D warnings (default & --all-features): **0 warnings**. - VICTORY_D3D12_DEBUG=1 (--features diagnostics): am_trim **13/13 passed**, pool::tests::trim_idle **2/2**, host::spare **2/2**, idle_trim **1/1** (0 D3D12 debug errors). - cargo test -p victory-gpu -- --test-threads=1: **387 passed; 0 failed; 34 ignored** ( am_trim OS commit stress via K32GetProcessMemoryInfo PagefileUsage: 267.3 -> 10.8 MiB, -256.5 MiB across rounds 0..2). - cargo test -p victory-gpu --features diagnostics -- --test-threads=1: **439 passed; 0 failed; 34 ignored** + eplay **1/1** ( am_trim OS commit stress: 356.9 -> 100.4 MiB, -256.5 MiB across rounds 0..2). - cargo test -p xtask: **9/9**; cargo run -p xtask -- policy --staged: **265 files ok**; git diff --cached --check: clean; git merge-tree --write-tree origin/main HEAD: clean.
Vladimir-Human commented 2026-11-26 14:11:52 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by Vladimir-Human on 2026-11-26T14:11:52Z.


Rebased cleanly onto latest main (c9c932c: port/guard + port/journal + README) at 40090b2:

  • Resolved the 1-file conflict in crates/victory-gpu/src/watch.rs, preserving port/guard (cc761bf) forget_views and &g guard handling in title_memory_unmapping/title_memory_freed alongside shadow::title_memory_remapped outside GUARDS, and clearing clippy::unnecessary-mut-passed in title_memory_remapped.
  • crates/victory-gpu/src/host.rs: 518,063 B (< 512 KiB).
  • Re-verified: xtask policy (266 files ok), cargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated (default & --features diagnostics: 0 warnings), and VICTORY_D3D12_DEBUG=1 victory-gpu (398 passed; 0 failed; 34 ignored default; 450 passed; 0 failed; 34 ignored + replay 1/1 with --features diagnostics).
<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:comment:7194413857 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/205#issuecomment-7194413857). Originally posted by [Vladimir-Human](https://github.com/Vladimir-Human) on 2026-11-26T14:11:52Z. --- Rebased cleanly onto latest `main` (`c9c932c`: `port/guard` + `port/journal` + README) at `40090b2`: - Resolved the 1-file conflict in `crates/victory-gpu/src/watch.rs`, preserving `port/guard` (`cc761bf`) `forget_views` and `&g` guard handling in `title_memory_unmapping`/`title_memory_freed` alongside `shadow::title_memory_remapped` outside `GUARDS`, and clearing `clippy::unnecessary-mut-passed` in `title_memory_remapped`. - `crates/victory-gpu/src/host.rs`: `518,063 B` (`< 512 KiB`). - Re-verified: `xtask policy` (`266 files ok`), `cargo clippy -p victory-gpu --all-targets -- -D warnings -A deprecated` (default & `--features diagnostics`: `0` warnings), and `VICTORY_D3D12_DEBUG=1` `victory-gpu` (`398 passed; 0 failed; 34 ignored` default; `450 passed; 0 failed; 34 ignored` + `replay` `1/1` with `--features diagnostics`).
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/205:upstream-pr/205'
git switch 'upstream-pr/205'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/205'
git switch 'upstream-pr/205'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/205'
git switch 'upstream-pr/205'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/205'
git switch 'main'
git merge --squash 'upstream-pr/205'
git switch 'main'
git merge --ff-only 'upstream-pr/205'
git switch 'main'
git merge 'upstream-pr/205'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
avatarmanz/VIctory-7900XTX!205
No description provided.