pool.rs: scale spares() by remaining DXGI VRAM headroom instead of fixed 4 GiB #94

Open
opened 2026-11-26 03:32:06 +00:00 by github-bot · 0 comments
Owner

@⁠Matt1x-T1x on GitHub · 2026-11-26 03:15 UTC · original

Ref: #76 (comment by @⁠endangeredd and 8 GB test by @⁠lorenzopincinato), #65

Problem

On 8 GB and 16 GB GPUs, the texture pool can reserve up to 4 GiB of empty blocks (SPARE_KEPT = 64 × 64 MiB), pushing VRAM over the DXGI budget (causing PCIe paging / ~1 fps on 16 GB cards as measured in #76, and costing ~1–1.5 GB VRAM on 8 GB cards).

The overshoot comes from spares() in crates/victory-gpu/src/pool.rs (lines 48–53):

fn spares(memory: Option<[u64; 4]>, keep: bool) -> usize {
    match memory {
        Some([budget, used, ..]) if keep && u128::from(used) * 100 < u128::from(budget) * 85 => SPARE_KEPT,
        _ => SPARE,
    }
}

Because this check is binary, any GPU below 85% usage immediately allows keeping up to 64 empty blocks (4 GiB), regardless of how much headroom is actually left before reaching 85%.

Suggested fix

Pool::rested() already trims excess empty blocks when SPARES drops, and Ripe::now() already clamps ahead to SPARES. Scaling spares() by the actual remaining headroom below 85% avoids overshooting on 8–16 GB cards without affecting 24 GB cards:

fn spares(memory: Option<[u64; 4]>, keep: bool) -> usize {
    let Some([budget, used, ..]) = memory else {
        return SPARE;
    };
    if !keep {
        return SPARE;
    }
    let ceiling = (u128::from(budget) * 85 / 100) as u64;
    let headroom = ceiling.saturating_sub(used);
    let fit = (headroom / 2 / BLOCK) as usize;
    fit.clamp(SPARE, SPARE_KEPT)
}

Expected behavior

GPU VRAM Example state Before After
24 GB (7900 XTX) 10 GB / 24 GB budget 64 blocks (4 GiB) 64 blocks (4 GiB) — unchanged
16 GB (6800 XT) 12 GB / 15.3 GB budget 64 blocks (4 GiB) ~8 blocks (~512 MiB)
8 GB (RX 7600 / RTX 3070) 5.5 GB / 7.25 GB budget 64 blocks (4 GiB) ~5 blocks (~320 MiB)
≥ 85% / keep == false / None — 2 blocks (128 MiB) 2 blocks (128 MiB) — unchanged
**@⁠Matt1x-T1x** on GitHub · 2026-11-26 03:15 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/94) Ref: #76 (comment by @⁠endangeredd and 8 GB test by @⁠lorenzopincinato), #65 ### Problem On 8 GB and 16 GB GPUs, the texture pool can reserve up to 4 GiB of empty blocks (`SPARE_KEPT = 64` × 64 MiB), pushing VRAM over the DXGI budget (causing PCIe paging / ~1 fps on 16 GB cards as measured in #76, and costing ~1–1.5 GB VRAM on 8 GB cards). The overshoot comes from `spares()` in `crates/victory-gpu/src/pool.rs` (lines 48–53): ```rust fn spares(memory: Option<[u64; 4]>, keep: bool) -> usize { match memory { Some([budget, used, ..]) if keep && u128::from(used) * 100 < u128::from(budget) * 85 => SPARE_KEPT, _ => SPARE, } } ``` Because this check is binary, any GPU below 85% usage immediately allows keeping up to 64 empty blocks (4 GiB), regardless of how much headroom is actually left before reaching 85%. ### Suggested fix `Pool::rested()` already trims excess empty blocks when `SPARES` drops, and `Ripe::now()` already clamps `ahead` to `SPARES`. Scaling `spares()` by the actual remaining headroom below 85% avoids overshooting on 8–16 GB cards without affecting 24 GB cards: ```rust fn spares(memory: Option<[u64; 4]>, keep: bool) -> usize { let Some([budget, used, ..]) = memory else { return SPARE; }; if !keep { return SPARE; } let ceiling = (u128::from(budget) * 85 / 100) as u64; let headroom = ceiling.saturating_sub(used); let fit = (headroom / 2 / BLOCK) as usize; fit.clamp(SPARE, SPARE_KEPT) } ``` ### Expected behavior | GPU VRAM | Example state | Before | After | |---|---|---|---| | **24 GB** (7900 XTX) | 10 GB / 24 GB budget | 64 blocks (4 GiB) | **64 blocks (4 GiB)** — unchanged | | **16 GB** (6800 XT) | 12 GB / 15.3 GB budget | 64 blocks (4 GiB) | **~8 blocks (~512 MiB)** | | **8 GB** (RX 7600 / RTX 3070) | 5.5 GB / 7.25 GB budget | 64 blocks (4 GiB) | **~5 blocks (~320 MiB)** | | **≥ 85% / `keep == false` / `None`** | — | 2 blocks (128 MiB) | **2 blocks (128 MiB)** — unchanged |
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:32:06 +00:00
This discussion has been locked. Commenting is limited to contributors.
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/avatarmanz--VIctory-7900XTX#94
No description provided.