gpu: opt-in reaction to shared (NON_LOCAL) memory pressure #103

Closed
github-bot wants to merge 1 commit from github-bot/gh-102 into main AGit
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 12:19 UTC · original
SovietBearz0r:razda-segment-tight → main · +75 −1 · 1 files · 1 commits · closed without merging

Opt-in reaction to shared-memory (NON_LOCAL) pressure: VICTORY_SEGMENT_TIGHT=<percent> (default 92, 0 disables).

Why

When a card's own VRAM is oversubscribed, the driver spills into the shared (NON_LOCAL) aperture. Submissions sent ahead then hold command allocators and intermediate allocations that the title's own allocations need, and the title can fail an allocation or stall under the pressure. We already sample the adapter's shared budget/usage (it is in the F3 VRAM panel), but we only react to commit pressure, not to the shared aperture being nearly full.

What

  • Host::shared_tight: samples [own budget, own used, shared budget, shared used] at most every 100 ms; tight when shared used is above VICTORY_SEGMENT_TIGHT percent of the shared budget (default 92). Hysteresis: once tight, it must fall below pct - 10 before it says recovered, so a single sample either way cannot flap it. Crossing either way is logged once with the shared MB/budget.
  • When tight, send_late:
    • trims idle lists (crate::list::trim_idle) and preludes (preludes::trim),
    • and settles the flights in the air before returning, even when the relay count is below late_most(), so the title's next allocations are not held up behind command allocators of work sent ahead.
  • 0 disables the reaction entirely; unset gives the 92 / 82 hysteresis. On a 16 GB card the line may never be crossed — the target is 8–12 GB cards, where the shared aperture actually gets used.

Verification

  • cargo test -p victory-gpu --lib shared_memory: the hysteresis unit test passes (919/921 at 92%, 829/819 recovery at 82%, zero budget not tight).
  • cargo check -p victory-gpu clean.
  • No in-game soak was possible here on a card that spills (RX 9070 XT, 16 GB): the meaningful check is a long session with VRAM oversubscription on an 8–12 GB AMD card, looking for the two log lines and for fewer WDDM allocation stalls; say so before merging.

Source: crossducking/RAZDA4A-ENGINE (dev @ 0e4b3782), crates/victory-gpu/src/host.rs shared_tight, used from send_late (Wave 14 changelog "16 GB RAM pool protection").

**@⁠SovietBearz0r** on GitHub · 2026-12-05 12:19 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/102) `SovietBearz0r:razda-segment-tight` → `main` · +75 −1 · 1 files · 1 commits · closed without merging Opt-in reaction to shared-memory (NON_LOCAL) pressure: `VICTORY_SEGMENT_TIGHT=<percent>` (default 92, `0` disables). ## Why When a card's own VRAM is oversubscribed, the driver spills into the shared (NON_LOCAL) aperture. Submissions sent ahead then hold command allocators and intermediate allocations that the title's own allocations need, and the title can fail an allocation or stall under the pressure. We already sample the adapter's shared budget/usage (it is in the F3 VRAM panel), but we only react to *commit* pressure, not to the shared aperture being nearly full. ## What - `Host::shared_tight`: samples `[own budget, own used, shared budget, shared used]` at most every 100 ms; tight when shared used is above `VICTORY_SEGMENT_TIGHT` percent of the shared budget (default 92). Hysteresis: once tight, it must fall below `pct - 10` before it says recovered, so a single sample either way cannot flap it. Crossing either way is logged once with the shared MB/budget. - When tight, `send_late`: - trims idle lists (`crate::list::trim_idle`) and preludes (`preludes::trim`), - and settles the flights in the air before returning, even when the relay count is below `late_most()`, so the title's next allocations are not held up behind command allocators of work sent ahead. - `0` disables the reaction entirely; unset gives the 92 / 82 hysteresis. On a 16 GB card the line may never be crossed — the target is 8–12 GB cards, where the shared aperture actually gets used. ## Verification - `cargo test -p victory-gpu --lib shared_memory`: the hysteresis unit test passes (919/921 at 92%, 829/819 recovery at 82%, zero budget not tight). - `cargo check -p victory-gpu` clean. - No in-game soak was possible here on a card that spills (RX 9070 XT, 16 GB): the meaningful check is a long session with VRAM oversubscription on an 8–12 GB AMD card, looking for the two log lines and for fewer WDDM allocation stalls; say so before merging. Source: crossducking/RAZDA4A-ENGINE (`dev` @ `0e4b3782`), `crates/victory-gpu/src/host.rs` `shared_tight`, used from `send_late` (Wave 14 changelog "16 GB RAM pool protection").
A card whose own memory is oversubscribed spills into the shared aperture.
Samples of [own budget, own used, shared budget, shared used] are taken at
most every 100 ms; above VICTORY_SEGMENT_TIGHT percent (default 92) the
flight path trims idle lists and preludes and settles the flights in the air
before returning, so the title's allocations do not queue behind command
allocators of work sent ahead. Recovery below pct-10 (hysteresis); 0 off.

From crossducking/RAZDA4A-ENGINE (Wave 14, host.rs shared_tight).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-05 12:22:36 +00:00
Author
Owner

@⁠ReTerryDavis on GitHub · 2026-12-05 17:37 UTC · original

Closing this one — although titled opt-in, VICTORY_SEGMENT_TIGHT actually defaults ON at 92% (host.rs:6393) and hasn't been soaked in-game on a card that spills to NON_LOCAL.

More importantly, once shared usage crosses 92% (staying latched down to 82%), calling self.settle(&mut submitted, WHY_MOST) on every Host::send_late submission forces synchronous GPU drains on every submit and will tank pipelining on 8–12 GB GPUs / 16 GB RAM hosts, alongside polling DXGI video_memory() on the hot submit path. (It also strips the UTF-8 BOM from host.rs.) If revisited later, it should be strictly off by default and verified with real frame-time data on a spilling GPU.

**@⁠ReTerryDavis** on GitHub · 2026-12-05 17:37 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/102#issuecomment-7442338563) Closing this one — although titled opt-in, `VICTORY_SEGMENT_TIGHT` actually defaults **ON at 92%** (`host.rs:6393`) and hasn't been soaked in-game on a card that spills to `NON_LOCAL`. More importantly, once shared usage crosses 92% (staying latched down to 82%), calling `self.settle(&mut submitted, WHY_MOST)` on every `Host::send_late` submission forces synchronous GPU drains on every submit and will tank pipelining on 8–12 GB GPUs / 16 GB RAM hosts, alongside polling DXGI `video_memory()` on the hot submit path. (It also strips the UTF-8 BOM from `host.rs`.) If revisited later, it should be strictly off by default and verified with real frame-time data on a spilling GPU.
github-bot closed this pull request 2026-12-05 17:43:17 +00:00
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 18:07 UTC · original

Addendum pushed: README now documents \VICTORY_SEGMENT_TIGHT\ (92% armed, recovered below 82%, sampled every 100 ms, \

**@⁠SovietBearz0r** on GitHub · 2026-12-05 18:07 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/102#issuecomment-7442854979) Addendum pushed: README now documents \VICTORY_SEGMENT_TIGHT\ (92% armed, recovered below 82%, sampled every 100 ms, \
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 18:21 UTC · original

Reopened with the review addressed. Branch force-pushed to a single clean commit on current main (6096c21):

  • Strictly off by default. VICTORY_SEGMENT_TIGHT arms only when explicitly set to 1..=100; unset/0/anything else is off, and when off the function returns before any clock read or DXGI video_memory() query (unwrap_or(92) is gone). README says off by default, 92 as the design point, 85 for the 8 GB safe preset, 0 disables.
  • No settle on every send_late. The reaction is rate-limited while latched tight: at most once per 250 ms and never twice for the same submission; other submissions trim idle lists/preludes (no GPU wait) and pipeline normally. The one-per-crossing log line stays.
  • Hot path: DXGI query only when armed and the 100 ms window elapsed; hysteresis kept (armed at pct, recovered below pct−10; zero-budget cannot falsely recover). Sampling/rate-limit are a pure tested state machine (pct, sample, react).
  • BOM restored on host.rs (no reformat otherwise).
  • Tests: victory-gpu --lib 719 passed / 0 failed / 21 ignored (+3 new: default-off, hysteresis, rate-limit incl. 10 submissions in one window → 1 settle); clippy -D warnings green (default + all-features); cargo xtask policy 442 files; cargo test -p xtask 9/9.

Still the gate you named: no in-game soak on a spilling 8–12 GB card. I cannot run the title here; the request is to A/B frame times unset vs =92 vs =85 on such a card and watch the two crossing lines and settle counts. If you would rather keep the code out of tree until someone with that hardware can soak it, that's fair — the branch is ready when that run exists.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 18:21 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/102#issuecomment-7443061699) Reopened with the review addressed. Branch force-pushed to a single clean commit on current `main` (`6096c21`): - **Strictly off by default.** `VICTORY_SEGMENT_TIGHT` arms only when explicitly set to `1..=100`; unset/`0`/anything else is off, and when off the function returns before any clock read or DXGI `video_memory()` query (`unwrap_or(92)` is gone). README says off by default, 92 as the design point, 85 for the 8 GB safe preset, `0` disables. - **No `settle` on every `send_late`.** The reaction is rate-limited while latched tight: at most once per 250 ms and never twice for the same submission; other submissions trim idle lists/preludes (no GPU wait) and pipeline normally. The one-per-crossing log line stays. - **Hot path:** DXGI query only when armed and the 100 ms window elapsed; hysteresis kept (armed at pct, recovered below pct−10; zero-budget cannot falsely recover). Sampling/rate-limit are a pure tested state machine (`pct`, `sample`, `react`). - **BOM restored** on `host.rs` (no reformat otherwise). - Tests: `victory-gpu --lib` 719 passed / 0 failed / 21 ignored (+3 new: default-off, hysteresis, rate-limit incl. 10 submissions in one window → 1 settle); clippy `-D warnings` green (default + all-features); `cargo xtask policy` 442 files; `cargo test -p xtask` 9/9. **Still the gate you named:** no in-game soak on a spilling 8–12 GB card. I cannot run the title here; the request is to A/B frame times unset vs `=92` vs `=85` on such a card and watch the two crossing lines and settle counts. If you would rather keep the code out of tree until someone with that hardware can soak it, that's fair — the branch is ready when that run exists.
Author
Owner

@⁠SovietBearz0r on GitHub · 2026-12-05 18:27 UTC · original

Review addressed and resubmitted as #161 (I can't reopen this one: GitHub doesn't let the author reopen a PR closed by the maintainer). The new PR is rebased on current main and its body lists point-by-point what changed; closed this thread is fine, please use the new one.

**@⁠SovietBearz0r** on GitHub · 2026-12-05 18:27 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/102#issuecomment-7443145723) Review addressed and resubmitted as #161 (I can't reopen this one: GitHub doesn't let the author reopen a PR closed by the maintainer). The new PR is rebased on current main and its body lists point-by-point what changed; closed this thread is fine, please use the new one.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.