Curb host commit thrashing and widen ReBAR BAR headroom on <=16 GiB RAM systems #2671

Open
github-bot wants to merge 9 commits from github-bot/gh-2671 into main AGit
Owner

@⁠shrx404 on GitHub · 2026-11-29 15:49 UTC · original
shrx404:perf/low-ram-rebar-balance → main · +973 −180 · 17 files · 9 commits · open

Fixes #

What it changes

On systems with <= 16 GiB of RAM paired with 6 GiB VRAM / smaller Windows shared-GPU budgets, running titles could push OS commit into pagefile.sys thrashing, hit E_OUTOFMEMORY during buffer/PSO creation, and spill BAR allocations into shared RAM while under-utilizing dedicated VRAM.

At a Glance

Area Before (Default) After (<= 16 GiB RAM / Small Shared GPU) Where
Host idle retention 10s / 5s / 2s 2.5s / 1.5s / 1.0s host.rs
Commit growth / critical floors 1 GiB / 1.5 GiB 1.5 GiB growth, 2.5 GiB soft warm trim (8 lists/preludes), 1.5 GiB hard drain (0) residency.rs, list.rs, host.rs
Pool & scratch caps 512 lists (256 MiB), 256 preludes, 512 batch spares, 128 MiB UAV, 32–64 MiB readbacks 64 lists (32 MiB), 32 preludes, 64 batch spares, 48 MiB UAV (8 MiB floor), 16 MiB readbacks, 1 empty pool block (0 when tight) pool.rs, list.rs, host.rs, host/uav_pool.rs, texback.rs
L0 lookahead & DirectStorage 512 buffers ahead, 256 MiB staging floor 0 base lookahead, 32 MiB staging floor, <= 4 default workers ahead.rs, dstorage.rs
OOM buffer retry Upload retry only (blocking lock) Lock-safe try_lock leaf-pool free_all_spares() on both upload_buffer_own and shared_buffer_own host.rs, pool.rs
Shader compiles & deferrals Unserialized; deferrals logged as permanent PSO failures & retried unguarded 1 gated compile at a time (low_host_ram()); memguard::deferred() returns None for clean retry compilemem.rs, pipeline/host.rs
VRAM & ReBAR accounting Uncapped sparse hole credit; 80% BAR cap Hole credit capped at 256 MiB in let_go_idle/slot_evict; BAR cap 92% (>= 4.5 GiB) / 86% (< 4.5 GiB) on small shared GPUs resource.rs, shadow.rs
Detailed breakdown by crate and file (13 files modified)
  1. Commit pressure & pool shedding (<= 16 GiB host RAM)

    • residency.rs / lib.rs: adds low_host_ram() (<= 16 GiB), exports victory_gpu::low_host_ram(), raises has_growth_reserve_for() (1.5 GiB) and critical_commit_floor() (2.5 GiB), and adds hard_critical_commit() (< 1.5 GiB or recent OOM).
    • ahead.rs / dstorage.rs: sets default VICTORY_BUFFERS_AHEAD base to 0, lowers default VICTORY_DSTORAGE_STAGING_MB floor from 256 MiB to 32 MiB, and caps default DirectStorage workers at .min(4) when low_host_ram() is active.
    • pool.rs / list.rs / host.rs / host/uav_pool.rs / texback.rs: tightens idle caps and ram_idle_for_host(), adds trim_idle_blocks(), trim_idle_to(), trim_preludes_to(), and trim_batch_spares() (keeping an 8-entry list/prelude floor at 1.5–2.5 GiB to avoid allocator churn), shares non-blocking try_lock leaf-pool free_all_spares() across upload_buffer_own() and shared_buffer_own(), and isolates pool::tests from global &SPARES.
  2. Shader compile serialization & memguard deferrals

    • compilemem.rs: serializes gated compiles (State::try_start_for(..., low_ram)) to one concurrent compile on <= 16 GiB RAM hosts to prevent multi-GB overlapping driver commit spikes.
    • pipeline/host.rs: adds refusal_dxils() across compute, mesh, and graphics paths so memguard::deferred() (E_OUTOFMEMORY) returns None for Pending::make_with retry instead of recording a permanent failure or calling refused::retry.
  3. Sparse heap eviction & small-shared ReBAR headroom

    • resource.rs: adds pool_hole_credit() (256 MiB cap on <= 16 GiB hosts) in let_go_idle() and slot_evict() so fragmented 64 MiB blocks still trigger eviction while keeping full texture_room() in room() so hole reuse stays unblocked.
    • shadow.rs: widens mapped_card_headroom_pct() on residency::shared_is_small() GPUs (92% for >= 4.5 GiB budgets, 86% below 4.5 GiB, vs 80% elsewhere) and defaults low-RAM shadow Vec pool retention to 64 MiB.

How it was tested

  • GPU and profile: NVIDIA GeForce RTX 4050 Laptop GPU (5,920 MB VRAM / 5,152 MB DXGI local budget / ~5,449 MB shared cap), 12 GB (11.73 GiB) RAM, Series S profile (1280x720, DLSS off, Frame Gen off, Ray Tracing off).
Metric Baseline (Before) Mid-Tuning After (Final Profile)
Run Outcome Crashed (clean=False) 22928: Crashed / 4672: Clean Clean exit (title suspended; ending the title)
OOM / Device-Removed Errors 1,612–1,637 OOMs / 638–6,820 dev-removed 42 dev-removed → 0 0 OOMs, 0 dev-removed, 0 PSO failures
In-Game World FPS (>500 draws/frame) 0.1–0.8 fps median (2.7–3.9 fps max) 2.5–3.8 fps median (5.5–5.9 fps max) 7.4 fps median / 14.8 fps max (8.0–8.4 fps at end, n=94)
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (no victory-shader translation changes).
  • cargo test passed for the crates it touches: yes (follow-up audit refinements applied atop the validated profile; unit tests re-verified below)
    • victory-hle: 423 passed; 0 failed; 5 ignored (--lib) + 2 passed; 0 failed (no_dll_planting)
    • victory: 78 + 1 + 2 passed; 0 failed
    • victory-gpu (pool::tests, shadow::window_tests, parallel): 49 passed; 0 failed; 3 ignored
    • victory-gpu (--lib, --test-threads=1): 915 passed; 2 failed; 57 ignored (two texback pool tests tripped upstream sticky residency::pressured() on this busy 12 GB machine late in the single-process run; both pass 4 passed; 0 failed when texback::tests runs standalone)
    • Note: untouched victory-formats had 3 pre-existing bcpack::tests::oracle_parity_* failures locally.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #
**@⁠shrx404** on GitHub · 2026-11-29 15:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2671) `shrx404:perf/low-ram-rebar-balance` → `main` · +973 −180 · 17 files · 9 commits · open Fixes # ## What it changes On systems with `<= 16 GiB` of RAM paired with 6 GiB VRAM / smaller Windows shared-GPU budgets, running titles could push OS commit into `pagefile.sys` thrashing, hit `E_OUTOFMEMORY` during buffer/PSO creation, and spill BAR allocations into shared RAM while under-utilizing dedicated VRAM. ### At a Glance | Area | Before (Default) | After (`<= 16 GiB` RAM / Small Shared GPU) | Where | |---|---|---|---| | Host idle retention | `10s / 5s / 2s` | `2.5s / 1.5s / 1.0s` | `host.rs` | | Commit growth / critical floors | `1 GiB` / `1.5 GiB` | `1.5 GiB` growth, `2.5 GiB` soft warm trim (`8` lists/preludes), `1.5 GiB` hard drain (`0`) | `residency.rs`, `list.rs`, `host.rs` | | Pool & scratch caps | `512` lists (`256 MiB`), `256` preludes, `512` batch spares, `128 MiB` UAV, `32–64 MiB` readbacks | `64` lists (`32 MiB`), `32` preludes, `64` batch spares, `48 MiB` UAV (`8 MiB` floor), `16 MiB` readbacks, `1` empty pool block (`0` when tight) | `pool.rs`, `list.rs`, `host.rs`, `host/uav_pool.rs`, `texback.rs` | | L0 lookahead & DirectStorage | `512` buffers ahead, `256 MiB` staging floor | `0` base lookahead, `32 MiB` staging floor, `<= 4` default workers | `ahead.rs`, `dstorage.rs` | | OOM buffer retry | Upload retry only (blocking lock) | Lock-safe `try_lock` leaf-pool `free_all_spares()` on both `upload_buffer_own` and `shared_buffer_own` | `host.rs`, `pool.rs` | | Shader compiles & deferrals | Unserialized; deferrals logged as permanent PSO failures & retried unguarded | `1` gated compile at a time (`low_host_ram()`); `memguard::deferred()` returns `None` for clean retry | `compilemem.rs`, `pipeline/host.rs` | | VRAM & ReBAR accounting | Uncapped sparse hole credit; `80%` BAR cap | Hole credit capped at `256 MiB` in `let_go_idle`/`slot_evict`; BAR cap `92%` (`>= 4.5 GiB`) / `86%` (`< 4.5 GiB`) on small shared GPUs | `resource.rs`, `shadow.rs` | <details> <summary>Detailed breakdown by crate and file (13 files modified)</summary> 1. **Commit pressure & pool shedding (`<= 16 GiB` host RAM)** - `residency.rs` / `lib.rs`: adds `low_host_ram()` (`<= 16 GiB`), exports `victory_gpu::low_host_ram()`, raises `has_growth_reserve_for()` (`1.5 GiB`) and `critical_commit_floor()` (`2.5 GiB`), and adds `hard_critical_commit()` (`< 1.5 GiB` or recent OOM). - `ahead.rs` / `dstorage.rs`: sets default `VICTORY_BUFFERS_AHEAD` base to `0`, lowers default `VICTORY_DSTORAGE_STAGING_MB` floor from `256 MiB` to `32 MiB`, and caps default DirectStorage workers at `.min(4)` when `low_host_ram()` is active. - `pool.rs` / `list.rs` / `host.rs` / `host/uav_pool.rs` / `texback.rs`: tightens idle caps and `ram_idle_for_host()`, adds `trim_idle_blocks()`, `trim_idle_to()`, `trim_preludes_to()`, and `trim_batch_spares()` (keeping an `8`-entry list/prelude floor at `1.5–2.5 GiB` to avoid allocator churn), shares non-blocking `try_lock` leaf-pool `free_all_spares()` across `upload_buffer_own()` and `shared_buffer_own()`, and isolates `pool::tests` from global `&SPARES`. 2. **Shader compile serialization & `memguard` deferrals** - `compilemem.rs`: serializes gated compiles (`State::try_start_for(..., low_ram)`) to one concurrent compile on `<= 16 GiB` RAM hosts to prevent multi-GB overlapping driver commit spikes. - `pipeline/host.rs`: adds `refusal_dxils()` across `compute`, `mesh`, and `graphics` paths so `memguard::deferred()` (`E_OUTOFMEMORY`) returns `None` for `Pending::make_with` retry instead of recording a permanent failure or calling `refused::retry`. 3. **Sparse heap eviction & small-shared ReBAR headroom** - `resource.rs`: adds `pool_hole_credit()` (`256 MiB` cap on `<= 16 GiB` hosts) in `let_go_idle()` and `slot_evict()` so fragmented `64 MiB` blocks still trigger eviction while keeping full `texture_room()` in `room()` so hole reuse stays unblocked. - `shadow.rs`: widens `mapped_card_headroom_pct()` on `residency::shared_is_small()` GPUs (`92%` for `>= 4.5 GiB` budgets, `86%` below `4.5 GiB`, vs `80%` elsewhere) and defaults low-RAM shadow `Vec` pool retention to `64 MiB`. </details> ## How it was tested - **GPU and profile**: NVIDIA GeForce RTX 4050 Laptop GPU (`5,920 MB` VRAM / `5,152 MB` DXGI local budget / `~5,449 MB` shared cap), `12 GB` (`11.73 GiB`) RAM, Series S profile (`1280x720`, DLSS off, Frame Gen off, Ray Tracing off). | Metric | Baseline (Before) | Mid-Tuning | After (Final Profile) | |---|---|---|---| | Run Outcome | Crashed (`clean=False`) | `22928`: Crashed / `4672`: Clean | **Clean exit** (`title suspended; ending the title`) | | OOM / Device-Removed Errors | `1,612–1,637` OOMs / `638–6,820` dev-removed | `42` dev-removed → `0` | **`0` OOMs, `0` dev-removed, `0` PSO failures** | | In-Game World FPS (`>500 draws/frame`) | `0.1–0.8 fps` median (`2.7–3.9 fps` max) | `2.5–3.8 fps` median (`5.5–5.9 fps` max) | **`7.4 fps` median / `14.8 fps` max** (`8.0–8.4 fps` at end, `n=94`) | - **For shader changes, the wave sizes tested (32 and/or 64 lanes)**: N/A (no `victory-shader` translation changes). - **`cargo test` passed for the crates it touches**: yes *(follow-up audit refinements applied atop the validated profile; unit tests re-verified below)* - `victory-hle`: `423 passed; 0 failed; 5 ignored` (`--lib`) + `2 passed; 0 failed` (`no_dll_planting`) - `victory`: `78 + 1 + 2 passed; 0 failed` - `victory-gpu` (`pool::tests`, `shadow::window_tests`, parallel): `49 passed; 0 failed; 3 ignored` - `victory-gpu` (`--lib`, `--test-threads=1`): `915 passed; 2 failed; 57 ignored` (two `texback` pool tests tripped upstream sticky `residency::pressured()` on this busy 12 GB machine late in the single-process run; both pass `4 passed; 0 failed` when `texback::tests` runs standalone) - *Note*: untouched `victory-formats` had 3 pre-existing `bcpack::tests::oracle_parity_*` failures locally. ## Checked for overlap - [ ] I searched the open pull requests for the same issue and for the files this touches. Related: #
On hosts with <= 16 GiB physical RAM (detected via low_host_ram()), large idle pools, L0 lookahead, and DirectStorage staging buffers drive pagefile commit spikes and E_OUTOFMEMORY allocation failures.

- residency, lib: add low_host_ram() (<= 16 GiB), raise has_growth_reserve_for() to 1.5 GiB, and raise critical_commit_floor() to 2.5 GiB.
- ahead: default VICTORY_BUFFERS_AHEAD base to 0 on <= 16 GiB RAM hosts to keep L0 caches within Windows shared GPU limits.
- pool, list, texback, uav_pool, host: tighten ram_idle_for_host (2.5s/1.5s/1.0s), cap idle pool blocks/lists/preludes/batch spares/scratch spares/UAV spares/read-backs on <= 16 GiB hosts, add trim_idle_blocks() / trim_idle() / emergency_trim(), retry shared/upload allocations once after trimming on E_OUTOFMEMORY, and isolate pool::tests from global SPARES.
- dstorage: lower default VICTORY_DSTORAGE_STAGING_MB floor to 32 MiB and cap default worker threads at 4 on <= 16 GiB RAM hosts.
Overlapping NVIDIA driver pipeline/shader compiles can each commit multiple gigabytes of memory, saturating pagefile.sys and causing E_OUTOFMEMORY during PSO creation on <= 16 GiB RAM hosts. In addition, when compilemem deferred a compile via memguard::refusal() (E_OUTOFMEMORY), HostPipeline treated the deferral as a permanent failure and bypassed the gate with refused::retry.

- compilemem: add try_start_for(..., low_ram) so gated compiles serialize to one at a time on <= 16 GiB RAM hosts (Verdict::Throttle while running is non-empty).
- pipeline/host: add refusal_dxils() so deferred memguard refusals return None immediately for Pending::make_with retry instead of recording a permanent failure or calling refused::retry.
On <= 16 GiB systems with smaller VRAM + small shared-GPU budgets (e.g. 6 GiB ReBAR laptop GPUs), fragmented pooled texture heaps and a low CPU-mapped BAR cap pushed buffers prematurely into shared RAM.

- resource: add pool_hole_credit() capping credited pooled texture holes at 256 MiB on <= 16 GiB RAM hosts in room(), let_go_idle(), and slot_evict() so DXGI budget tracking and eviction reflect sparse heaps accurately.
- shadow: extract mapped_card_headroom_pct() and mapped_card_headroom_ok() to allow CPU-mapped BAR windows/buffers up to 94% (up from 80%) of the local DXGI budget on residency::shared_is_small() GPUs, and default low-RAM shadow Vec pool retention to 64 MiB (+ unit test).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 15:52:39 +00:00
github-bot force-pushed github-bot/gh-2671 from d1bdf0844f to 81f02b01b1 2026-11-29 16:21:16 +00:00 Compare
github-bot force-pushed github-bot/gh-2671 from 81f02b01b1 to 0bab939fb7 2026-12-01 06:37:32 +00:00 Compare
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
  • crates/victory-gpu/src/host/uav_pool.rs
  • crates/victory-gpu/src/pool.rs
  • crates/victory-gpu/src/resource.rs
  • crates/victory-gpu/src/shadow.rs
  • crates/victory-hle/src/modules/dstorage.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2671'
git switch 'github-bot/gh-2671'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2671'
git switch 'github-bot/gh-2671'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2671'
git switch 'main'
git merge --squash 'github-bot/gh-2671'
git switch 'main'
git merge --ff-only 'github-bot/gh-2671'
git switch 'main'
git merge 'github-bot/gh-2671'
git push origin 'main'
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/trustno1-coder--VIctory-NVIDIA!2671
No description provided.