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

Open
github-bot wants to merge 1 commit from github-bot/gh-205 into main AGit
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 11:30 UTC · original
Vladimir-Human:perf/ram-footprint-decommit → main · +3350 −252 · 12 files · 1 commits · open

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** on GitHub · 2026-11-26 11:30 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/205) `Vladimir-Human:perf/ram-footprint-decommit` → `main` · +3350 −252 · 12 files · 1 commits · open 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.
Port host system RAM reclamation and Windows MEM_DECOMMIT virtual-memory
lifecycle management from fxceless/victory-fork#1286 onto VIctory-7900XTX:

- Add ram_trim.rs: TrimPolicy (Tight16/Standard32/Large + aggressive
  VICTORY_RAM_TRIM=1 + panic mode), non-resetting GetWriteWatch VM safety
  guard, VmBlock/SnapshotBuffer with 64 KiB MEM_DECOMMIT/MEM_COMMIT over
  preserved MEM_RESERVE VA, scratch shrink helper, and copystat telemetry.
- pool.rs, list.rs, host.rs, texture.rs: add Block::last_used_ms and
  pool::trim_idle_with to evict cold 64 MiB upload staging/texture blocks
  outside pool mutexes even when VICTORY_RESIDENCY=1 is off (clamping
  SPARES on pressure/panic), reclaim cold idle lists and per-list
  indirect_args/batch_args COM caches, wire Spare::trim and
  CardWork::fetched_ms, shrink oversized HostList collections and >4 MiB
  texture READ scratch vecs.
- shadow.rs, watch.rs: back POOL/SnapshotBuffer with VmBlock MEM_DECOMMIT,
  add ensure_commit across all snapshot consumers, clamp give_back_with slot 0,
  wire title_memory_remapped/unmapping/freed outside GUARDS (resolving
  MEM_RELEASE len==0 outside lock), drop CPU before snapshots upon card
  promotion, and add opt-in cold/zero trim under pending -> before -> kept.
- pipeline.rs, pipeline/{host,known}.rs: zlib-compress cold guest containers,
  add DxilPin + release_dxil + trim_shaders_with with transparent reload.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:37:18 +00:00
github-bot force-pushed github-bot/gh-205 from 5a26c94b59 to 40090b2613 2026-11-26 14:13:01 +00:00 Compare
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-26 14:11 UTC · original

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).
**@⁠Vladimir-Human** on GitHub · 2026-11-26 14:11 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/205#issuecomment-7194413857) 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 can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/205/head:github-bot/gh-205'
git switch 'github-bot/gh-205'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-205'
git switch 'github-bot/gh-205'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-205'
git switch 'github-bot/gh-205'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-205'
git switch 'main'
git merge --squash 'github-bot/gh-205'
git switch 'main'
git merge --ff-only 'github-bot/gh-205'
git switch 'main'
git merge 'github-bot/gh-205'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.