perf(gpu/ahead,host): bounded 8 MiB L0 SharedPool sub-allocator with residency pressure trimming #27

Closed
github-bot wants to merge 1 commit from gh-pr/27/head into gh-pr/27/base
Owner

@⁠justadudeinbulgaria on GitHub · 2026-12-01 18:16 UTC · original
justadudeinbulgaria:pr/bounded-l0-shared-pool → main · +606 −14 · 3 files · 1 commits · closed without merging

Summary

Ports the L0 (WRITE_BACK) shared-buffer heap pool from Androtim/MiniVI#289 with strict memory/residency guardrails for 16–32 GB RAM and 8 GB VRAM GPUs, while intentionally omitting CardBumpPool:

  • Why L0 SharedPool only (no CardBumpPool): On 8 GB GPUs, bump-pooling DEFAULT VRAM buffers co-mingles permanent/long-lived buffers with short-lived scratch UAVs from uav_pool, preventing sweep_uav_spare() and VICTORY_CARD_PRESSURE from reclaiming VRAM cleanly.
  • Bounded 8 MiB L0 blocks (crates/victory-gpu/src/ahead.rs):
    • Sub-allocates <= 2 MiB CPU-visible WRITE_BACK L0 buffers (Host::shared_buffer_now) inside 8 MiB (128 × 64 KiB slot) ID3D12Heap blocks (VICTORY_BUFFER_POOL=0 restores committed allocations).
    • Tracks virgin vs recycled slots (ever_used skips zeroing fresh OS pages; recycled slots are zeroed after a 2500 ms REST_MS cooldown via a SetPrivateDataInterface COM IUnknown reclaim hook).
    • Hard block cap (64 × 8 MiB = 512 MiB on <= 32 GiB hosts, 128 × 8 MiB on > 32 GiB hosts) and refuses new pool heaps whenever residency::shared_pressed() || residency::critical_commit() is true (falling back cleanly to exact-size CreateCommittedResource).
  • Wired into all pressure/trim paths (ahead.rs, host.rs, residency.rs):
    • ahead::trim_shared_pool() runs in ahead::fill(), host::sweep() (so trimming works even with VICTORY_BUFFERS_AHEAD=0), and residency::refresh() when shared_tight triggers.
    • Also adds shared_trim_len / should_refill_shared host-pressure trimming to ahead::fill()'s 64 KiB store.

Verification

  • Zero shader-cache invalidation (crates/victory-shader/* and shader_cache.rs untouched).
  • Unit tests on origin/main (48413c9): ahead:: (3/3 passed, including live D3D12 placed-buffer allocation + sentinel zero-on-recycle test) & residency:: (4/4 passed).
  • Live gameplay (i5-10600K + RTX 2060 SUPER 8 GB + 32 GB RAM):
    • 10,000 shared buffers served from only 51 bounded 8 MiB heaps (196x fewer WDDM kernel allocations; heap count plateaued flat at 51 between 8,000 and 10,000 buffers in recycling steady state).
    • Boot-to-3D-world dropped from 113 s to 72 s (-41 s), with pressured=false, 7.2–8.4 GiB free physical RAM, 15.2 GiB commit headroom, and 31 MB texture staging.
**@⁠justadudeinbulgaria** on GitHub · 2026-12-01 18:16 UTC · [original](https://github.com/ToLIManl/VIctory-Hydra/pull/27) `justadudeinbulgaria:pr/bounded-l0-shared-pool` → `main` · +606 −14 · 3 files · 1 commits · closed without merging ## Summary Ports the `L0` (`WRITE_BACK`) shared-buffer heap pool from `Androtim/MiniVI#289` with strict memory/residency guardrails for 16–32 GB RAM and 8 GB VRAM GPUs, while **intentionally omitting `CardBumpPool`**: - **Why `L0 SharedPool` only (no `CardBumpPool`)**: On 8 GB GPUs, bump-pooling `DEFAULT` VRAM buffers co-mingles permanent/long-lived buffers with short-lived scratch UAVs from `uav_pool`, preventing `sweep_uav_spare()` and `VICTORY_CARD_PRESSURE` from reclaiming VRAM cleanly. - **Bounded 8 MiB `L0` blocks (`crates/victory-gpu/src/ahead.rs`)**: - Sub-allocates `<= 2 MiB` CPU-visible `WRITE_BACK` `L0` buffers (`Host::shared_buffer_now`) inside 8 MiB (`128 × 64 KiB` slot) `ID3D12Heap` blocks (`VICTORY_BUFFER_POOL=0` restores committed allocations). - Tracks virgin vs recycled slots (`ever_used` skips zeroing fresh OS pages; recycled slots are zeroed after a `2500 ms` `REST_MS` cooldown via a `SetPrivateDataInterface` COM `IUnknown` reclaim hook). - Hard block cap (`64 × 8 MiB = 512 MiB` on `<= 32 GiB` hosts, `128 × 8 MiB` on `> 32 GiB` hosts) and refuses new pool heaps whenever `residency::shared_pressed() || residency::critical_commit()` is true (falling back cleanly to exact-size `CreateCommittedResource`). - **Wired into all pressure/trim paths (`ahead.rs`, `host.rs`, `residency.rs`)**: - `ahead::trim_shared_pool()` runs in `ahead::fill()`, `host::sweep()` (so trimming works even with `VICTORY_BUFFERS_AHEAD=0`), and `residency::refresh()` when `shared_tight` triggers. - Also adds `shared_trim_len` / `should_refill_shared` host-pressure trimming to `ahead::fill()`'s 64 KiB store. ## Verification - **Zero shader-cache invalidation** (`crates/victory-shader/*` and `shader_cache.rs` untouched). - **Unit tests** on `origin/main` (`48413c9`): `ahead::` (**3/3 passed**, including live D3D12 placed-buffer allocation + sentinel zero-on-recycle test) & `residency::` (**4/4 passed**). - **Live gameplay (i5-10600K + RTX 2060 SUPER 8 GB + 32 GB RAM)**: - **`10,000` shared buffers served from only `51` bounded 8 MiB heaps** (`196x` fewer WDDM kernel allocations; heap count plateaued flat at `51` between `8,000` and `10,000` buffers in recycling steady state). - Boot-to-3D-world dropped from **`113 s` to `72 s` (`-41 s`)**, with `pressured=false`, `7.2–8.4 GiB` free physical RAM, `15.2 GiB` commit headroom, and `31 MB` texture staging.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 17:09:14 +00:00
github-bot closed this pull request 2026-12-02 17:09:14 +00:00
Author
Owner

@⁠ToLIManl on GitHub · 2026-12-02 12:54 UTC · original

Thank you @⁠justadudeinbulgaria — great work on this one! Integrated onto v2.0 main in commit 5d7f3ef with full Co-authored-by credit:

  • Ported the bounded 8 MiB L0 SharedPool sub-allocator (alloc_pooled_shared, trim_shared_pool, SharedBlock, SharedPool, SharedReclaim COM reclaim hook) into ahead.rs while preserving v2.0's adaptive(), RetryGate, and ram_pressure/card_pressure.
  • Wired trim_shared_pool into host.rs::sweep and residency.rs::refresh.
  • Wired alloc_pooled_shared into host.rs::shared_buffer_now right after pool::cpu_buffer so 8–16 GB VRAM/RAM systems get bounded 8 MiB L0 pooling and pressure trimming without regressing 32 GB+ hosts.

Built, unit-tested (victory-gpu ahead::* 6/6 passed), and shipped in the refreshed VIctory-Hydra-v2.0-Stage17.zip release. Closing since the PR targeted pre-v2.0 history and is now landed on main.

**@⁠ToLIManl** on GitHub · 2026-12-02 12:54 UTC · [original](https://github.com/ToLIManl/VIctory-Hydra/pull/27#issuecomment-7346063703) Thank you @⁠justadudeinbulgaria — great work on this one! Integrated onto v2.0 `main` in commit `5d7f3ef` with full `Co-authored-by` credit: - Ported the bounded 8 MiB `L0 SharedPool` sub-allocator (`alloc_pooled_shared`, `trim_shared_pool`, `SharedBlock`, `SharedPool`, `SharedReclaim` COM reclaim hook) into `ahead.rs` while preserving v2.0's `adaptive()`, `RetryGate`, and `ram_pressure`/`card_pressure`. - Wired `trim_shared_pool` into `host.rs::sweep` and `residency.rs::refresh`. - Wired `alloc_pooled_shared` into `host.rs::shared_buffer_now` right after `pool::cpu_buffer` so 8–16 GB VRAM/RAM systems get bounded 8 MiB L0 pooling and pressure trimming without regressing 32 GB+ hosts. Built, unit-tested (`victory-gpu` `ahead::*` 6/6 passed), and shipped in the refreshed `VIctory-Hydra-v2.0-Stage17.zip` release. Closing since the PR targeted pre-v2.0 history and is now landed on `main`.

Pull request closed

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