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

Open
shrx404 wants to merge 9 commits from upstream-pr/2671 into main
shrx404 commented 2026-11-29 15:49:04 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by shrx404 on 2026-11-29T15:49:04Z.


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: #
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5552368428 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2671). Originally posted by [shrx404](https://github.com/shrx404) on 2026-11-29T15:49:04Z. --- 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: #
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/2671:upstream-pr/2671'
git switch 'upstream-pr/2671'

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/2671'
git switch 'upstream-pr/2671'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2671'
git switch 'upstream-pr/2671'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2671'
git switch 'main'
git merge --squash 'upstream-pr/2671'
git switch 'main'
git merge --ff-only 'upstream-pr/2671'
git switch 'main'
git merge 'upstream-pr/2671'
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
trustno1-coder/VIctory-NVIDIA!2671
No description provided.