feat(hle,gpu): report live title-own memory and bound CPU snapshot pool under pressure #303

Manually merged
github merged 1 commit from github-bot/gh-303 into gh-pr/303/base 2026-12-02 02:49:25 +00:00 AGit
Owner

@⁠Androtim on GitHub · 2026-12-02 02:41 UTC · original
Androtim:feat/xmem-title-used-and-snapshot-pressure → main · +395 −48 · 2 files · 1 commits · merged 2026-12-02 02:49 UTC

Summary

Reports live title-own memory usage in XMemGetWorkingSetStatistics and keeps the CPU write-watch snapshot pool bounded under host memory pressure, reducing peak system RAM working set and private commit without hurting frame rate or visuals.

Refs #276

Changes

  • crates/victory-hle/src/modules/xmem.rs
    • Replaced whole-process PagefileUsage reporting in XMemGetWorkingSetStatistics with default-on live title-own accounting (TITLE_PAGES + LIVE + TITLE_HEAP, capped at process commit), with a VICTORY_XMEM_TITLE_USED=0 kill-switch to fall back to process commit.
    • Added LiveRanges / LiveCommit and free_tracked to track distinct committed host-page spans across XMemVirtualAlloc, VirtualFree, and 32-bit XMemFreeDefault, plus live physical page (TITLE_PAGES) and host heap (TITLE_HEAP) atomics.
    • Expanded the title asks how much memory it uses log with process_mb, pages_mb, live_mb, and heap_mb.
  • crates/victory-gpu/src/shadow.rs
    • Added snapshot_pressure_budget and excess_snapshots and wired give_back to enforce residency::pressured() (4 / 16 MiB) and residency::critical_commit() (0 / 0) caps instead of refilling POOL up to 128–512 MiB between 1 s pressure sweeps.
    • Under host memory pressure, oversized snapshot buffers are skipped so smaller warm buffers remain usable within the 16 MiB cap.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: 320 files ok
  • Targeted unit tests (--locked):
    • victory-hle modules::xmem::tests: 33 passed, 0 failed (1 ignored benchmark)
    • victory-gpu shadow::hash_pool_tests (snapshot, excess_snapshots): 3 passed, 0 failed
  • Dual workspace clippy --workspace --all-targets --locked -- -D warnings (default + --features diagnostics): passed
  • Plain --release build (--bin MiniVI --locked) + objdump -p: standard Windows DLLs only

Paired Plain --release 90s A/B Benchmarks (RTX 4060 Ti 8 GB / 32 GB RAM, vs origin/main 0a9eca4)

1440p (-PlayParity -Res 1440, 90s in-world):

Metric origin/main (0a9eca4) PR Delta
FPS (all / steady median) 10.55 / 10.80 fps 10.60 / 11.25 fps +0.45 fps steady
dedicated_mb (2nd-half med / max) 5,980 / 6,195 MB 5,943 / 6,037 MB -158 MB max
shared_mb (2nd-half med / final) 5,742 / 6,023 MB 5,663 / 5,827 MB -196 MB final
working_set_mb (2nd-half med / max) 20,454 / 20,688 MB 19,634 / 20,053 MB -820 MB med (-635 MB max)
private_commit_mb (2nd-half med / max) 21,861 / 22,237 MB 21,402 / 21,855 MB -459 MB med (-382 MB max)
free_ram_mb (2nd-half med) 1,114 MB 2,158 MB +1,044 MB
First host memory pressure frame 1529 frame 3477 delayed +12 s
Crashes / DRED / Panics 0 0 clean

4K (-PlayParity -Res 4k, 90s in-world):

Metric origin/main (0a9eca4) PR Delta
FPS median 5.90 fps 6.00 fps +0.10 fps
Preparing / Copyback median 31.75 / 19.75 ms 30.10 / 16.60 ms -1.65 / -3.15 ms
shared_mb (2nd-half med / max) 6,075 / 6,174 MB 5,989 / 6,029 MB -145 MB max
private_commit_mb (2nd-half med / max) 22,397 / 22,686 MB 22,359 / 22,443 MB -243 MB max
free_ram_mb (2nd-half med) 903 MB 1,130 MB +227 MB
mapped() stall rate (longest) 18.9 ms/s (37.5 ms) 1.87 ms/s (12.8 ms) -90% stall rate
Crashes / DRED / Panics 0 0 clean

Diagnostics Visual Check (--features diagnostics, 1440p, 90s):

  • pngs=24, lit=12/24, luma=93.36, near_black=0.06%, edge_energy=7.8, magenta=0.0%, crashes=0, bakes=8, failed=0, showed_another_view=0.
  • Inspected captured gameplay frames (frame-2561.png, frame-2577.png, frame-2593.png): clean geometry, sky, textures, lighting, and HUD.
**@⁠Androtim** on GitHub · 2026-12-02 02:41 UTC · [original](https://github.com/Androtim/MiniVI/pull/303) `Androtim:feat/xmem-title-used-and-snapshot-pressure` → `main` · +395 −48 · 2 files · 1 commits · merged 2026-12-02 02:49 UTC ### Summary Reports live title-own memory usage in `XMemGetWorkingSetStatistics` and keeps the CPU write-watch snapshot pool bounded under host memory pressure, reducing peak system RAM working set and private commit without hurting frame rate or visuals. Refs #276 ### Changes - **`crates/victory-hle/src/modules/xmem.rs`** - Replaced whole-process `PagefileUsage` reporting in `XMemGetWorkingSetStatistics` with default-on live title-own accounting (`TITLE_PAGES + LIVE + TITLE_HEAP`, capped at process commit), with a `VICTORY_XMEM_TITLE_USED=0` kill-switch to fall back to process commit. - Added `LiveRanges` / `LiveCommit` and `free_tracked` to track distinct committed host-page spans across `XMemVirtualAlloc`, `VirtualFree`, and 32-bit `XMemFreeDefault`, plus live physical page (`TITLE_PAGES`) and host heap (`TITLE_HEAP`) atomics. - Expanded `the title asks how much memory it uses` log with `process_mb`, `pages_mb`, `live_mb`, and `heap_mb`. - **`crates/victory-gpu/src/shadow.rs`** - Added `snapshot_pressure_budget` and `excess_snapshots` and wired `give_back` to enforce `residency::pressured()` (`4` / `16 MiB`) and `residency::critical_commit()` (`0` / `0`) caps instead of refilling `POOL` up to 128–512 MiB between 1 s pressure sweeps. - Under host memory pressure, oversized snapshot buffers are skipped so smaller warm buffers remain usable within the 16 MiB cap. ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: `320 files ok` - Targeted unit tests (`--locked`): - `victory-hle` `modules::xmem::tests`: `33 passed, 0 failed` (`1 ignored` benchmark) - `victory-gpu` `shadow::hash_pool_tests` (`snapshot`, `excess_snapshots`): `3 passed, 0 failed` - Dual workspace `clippy --workspace --all-targets --locked -- -D warnings` (default + `--features diagnostics`): passed - Plain `--release` build (`--bin MiniVI --locked`) + `objdump -p`: standard Windows DLLs only ### Paired Plain `--release` 90s A/B Benchmarks (RTX 4060 Ti 8 GB / 32 GB RAM, vs `origin/main` `0a9eca4`) **1440p (`-PlayParity -Res 1440`, 90s in-world):** | Metric | `origin/main` (`0a9eca4`) | PR | Delta | |---|---:|---:|---:| | FPS (all / steady median) | `10.55 / 10.80 fps` | `10.60 / 11.25 fps` | `+0.45 fps` steady | | `dedicated_mb` (2nd-half med / max) | `5,980 / 6,195 MB` | `5,943 / 6,037 MB` | `-158 MB` max | | `shared_mb` (2nd-half med / final) | `5,742 / 6,023 MB` | `5,663 / 5,827 MB` | `-196 MB` final | | `working_set_mb` (2nd-half med / max) | `20,454 / 20,688 MB` | `19,634 / 20,053 MB` | **`-820 MB` med** (`-635 MB` max) | | `private_commit_mb` (2nd-half med / max) | `21,861 / 22,237 MB` | `21,402 / 21,855 MB` | **`-459 MB` med** (`-382 MB` max) | | `free_ram_mb` (2nd-half med) | `1,114 MB` | `2,158 MB` | **`+1,044 MB`** | | First `host memory pressure` | frame `1529` | frame `3477` | delayed `+12 s` | | Crashes / DRED / Panics | `0` | `0` | clean | **4K (`-PlayParity -Res 4k`, 90s in-world):** | Metric | `origin/main` (`0a9eca4`) | PR | Delta | |---|---:|---:|---:| | FPS median | `5.90 fps` | `6.00 fps` | `+0.10 fps` | | Preparing / Copyback median | `31.75 / 19.75 ms` | `30.10 / 16.60 ms` | **`-1.65 / -3.15 ms`** | | `shared_mb` (2nd-half med / max) | `6,075 / 6,174 MB` | `5,989 / 6,029 MB` | `-145 MB` max | | `private_commit_mb` (2nd-half med / max) | `22,397 / 22,686 MB` | `22,359 / 22,443 MB` | `-243 MB` max | | `free_ram_mb` (2nd-half med) | `903 MB` | `1,130 MB` | `+227 MB` | | `mapped()` stall rate (longest) | `18.9 ms/s` (`37.5 ms`) | `1.87 ms/s` (`12.8 ms`) | **`-90%`** stall rate | | Crashes / DRED / Panics | `0` | `0` | clean | **Diagnostics Visual Check (`--features diagnostics`, 1440p, 90s):** - `pngs=24, lit=12/24, luma=93.36, near_black=0.06%, edge_energy=7.8, magenta=0.0%, crashes=0, bakes=8, failed=0, showed_another_view=0`. - Inspected captured gameplay frames (`frame-2561.png`, `frame-2577.png`, `frame-2593.png`): clean geometry, sky, textures, lighting, and HUD.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 02:44:03 +00:00
github-bot changed target branch from main to gh-pr/303/base 2026-12-02 02:49:23 +00:00
github manually merged commit 610ed1e83a into gh-pr/303/base 2026-12-02 02:49:25 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-02 02:49 UTC · original

Audited full diff (610ed1e8, +395 -48 across crates/victory-hle/src/modules/xmem.rs and crates/victory-gpu/src/shadow.rs), both 90s plain---release A/B pairs (1440p and 4K), 5 s memory telemetry logs, and --features diagnostics visual PNGs:

  • Code & policy: Clean kernel-ordered LiveRanges/LiveCommit tracking + TITLE_PAGES/TITLE_HEAP atomics in xmem.rs (VICTORY_XMEM_TITLE_USED=0 safety kill-switch only), and pressure-aware snapshot_pressure_budget/excess_snapshots in shadow.rs::give_back preventing snapshot pool refills between pressure sweeps. Zero new opt-in switches; 36 targeted unit tests + dual clippy + asset policy: 320 files ok.
  • 1440p plain---release 90s A/B vs main (0a9eca4): 10.55 -> 10.60 fps (steady 10.80 -> 11.25 fps), -158 MB peak VRAM (over=0 MB, room_false=0.0%), final_waiting 4,762 -> 2,735 (-42.6%), working_set_mb -820 MB med, private_commit_mb -459 MB med, free_ram_mb +1,044 MB med, shared_mb -196 MB final, 0 crashes, untranslated 4 -> 4.
  • 4K plain---release 90s A/B vs main (0a9eca4): 5.90 -> 6.00 fps, preparing 33.7 -> 31.5 ms, copyback 19.2 -> 16.5 ms, final_waiting 12,556 -> 12,152, mapped() 18.9 -> 1.87 ms/s (-90%), private_commit_mb -243 MB max, shared_mb -145 MB max, over=0 MB, 0 crashes, untranslated 6 -> 6.
  • Direct --features diagnostics PNG inspection: Inspected frame-2585.png and frame-2593.png directly — crisp outdoor lighting, clean geometry/textures, luma=93.36, near_black=0.06%, edge_energy=7.8, magenta=0.0%, showed_another_view=0.
  • Disjoint from #300/#302, CI green (46796991108). Merging now.
**@⁠Androtim** on GitHub · 2026-12-02 02:49 UTC · [original](https://github.com/Androtim/MiniVI/pull/303#issuecomment-7333226606) Audited full diff (`610ed1e8`, `+395 -48` across `crates/victory-hle/src/modules/xmem.rs` and `crates/victory-gpu/src/shadow.rs`), both 90s plain-`--release` A/B pairs (1440p and 4K), 5 s `memory telemetry` logs, and `--features diagnostics` visual PNGs: - **Code & policy:** Clean kernel-ordered `LiveRanges`/`LiveCommit` tracking + `TITLE_PAGES`/`TITLE_HEAP` atomics in `xmem.rs` (`VICTORY_XMEM_TITLE_USED=0` safety kill-switch only), and pressure-aware `snapshot_pressure_budget`/`excess_snapshots` in `shadow.rs::give_back` preventing snapshot pool refills between pressure sweeps. Zero new opt-in switches; 36 targeted unit tests + dual clippy + `asset policy: 320 files ok`. - **1440p plain-`--release` 90s A/B vs `main` (`0a9eca4`):** `10.55 -> 10.60 fps` (steady `10.80 -> 11.25 fps`), `-158 MB` peak VRAM (`over=0 MB`, `room_false=0.0%`), **`final_waiting` `4,762 -> 2,735` (`-42.6%`)**, **`working_set_mb -820 MB` med**, **`private_commit_mb -459 MB` med**, **`free_ram_mb +1,044 MB` med**, `shared_mb -196 MB` final, `0` crashes, `untranslated 4 -> 4`. - **4K plain-`--release` 90s A/B vs `main` (`0a9eca4`):** `5.90 -> 6.00 fps`, `preparing 33.7 -> 31.5 ms`, `copyback 19.2 -> 16.5 ms`, `final_waiting 12,556 -> 12,152`, `mapped() 18.9 -> 1.87 ms/s` (`-90%`), `private_commit_mb -243 MB` max, `shared_mb -145 MB` max, `over=0 MB`, `0` crashes, `untranslated 6 -> 6`. - **Direct `--features diagnostics` PNG inspection:** Inspected `frame-2585.png` and `frame-2593.png` directly — crisp outdoor lighting, clean geometry/textures, `luma=93.36`, `near_black=0.06%`, `edge_energy=7.8`, `magenta=0.0%`, `showed_another_view=0`. - Disjoint from `#300`/`#302`, CI green (`46796991108`). Merging now.
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Androtim--MiniVI!303
No description provided.