feat(gpu): bound send spare pool and trim idle shader DXIL #305

Manually merged
github merged 1 commit from github-bot/gh-305 into gh-pr/305/base 2026-12-02 04:56:42 +00:00 AGit
Owner

@⁠Androtim on GitHub · 2026-12-02 04:46 UTC · original
Androtim:feat/send-spare-and-dxil-trim → main · +301 −25 · 4 files · 1 commits · merged 2026-12-02 04:52 UTC

Summary

Addresses [USER PRIORITY — MEMORY REALITY CHECK] in #276 by trimming retained host/upload allocations without introducing submission allocation churn:

  1. Right-sized upload send slabs & stale-first pressure trimming (crates/victory-gpu/src/host/send.rs, crates/victory-gpu/src/host.rs):

    • Lowers the minimum send upload allocation size from 8 MiB to 1 MiB (powers of two up to 16 MiB, then 8 MiB steps above 16 MiB) to eliminate 8x over-commit on small submissions and 2x overshoot on large bursts.
    • Replaces the flat 768 MiB untrimmed SPARE cap with pressure-aware working-set limits (96 / 128 / 192 / 256 MiB off-card; 64 / 96 / 128 MiB on-card) and adds send::trim_under_pressure into host::sweep() (evicting stale idle slabs >= 5–10s first down to 32 MiB, dropping ID3D12Resources asynchronously via drop_aside).
    • Default-on with VICTORY_SEND_SPARE_TRIM=0 kill-switch.
  2. Idle compiled shader DXIL trimming with transparent reload (crates/victory-gpu/src/pipeline.rs, crates/victory-gpu/src/pipeline/host.rs, crates/victory-gpu/src/host.rs):

    • Extracts compiled DXIL bytecode out of Translated.host.dxil into an independently releasable slot while keeping translation metadata resident.
    • Adds pipeline::trim_shader_bytecode to host::sweep(), dropping idle DXIL buffers after 30 s normal / 10 s pressured / 5 s critical commit (~76–84 MB released down to 0 MB in steady state) and reloading transparently from shader_cache via Shader::dxil() if another pipeline later shares that shader.
    • Default-on with VICTORY_SHADER_TRIM=0 kill-switch.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy — asset policy: 320 files ok
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib --locked -- send_spare_limit send_alloc_size trim_spare_items shader_trim_enabled shader_dxil_idle_ms — 5/5 passed
  • Dual cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings (default and --features diagnostics) — passed (0 warnings)
  • Plain --release --bin MiniVI --locked + objdump -p — passed, standard Windows DLLs only

Paired Plain --release 90s A/B vs main (001702f)

(RTX 4060 Ti 8 GB / i7-13700F / 32 GB RAM, -PlayParity -WorldSeconds 90)

Metric 1440p main 1440p PR 4K DLSS-Q main 4K DLSS-Q PR
Median FPS / frame ms 14.0 fps (71.7 ms) 14.95 fps (66.85 ms) 6.6 fps (151.7 ms) 6.6 fps (151.4 ms)
Preparing (verify-world / core avg) 26.4 ms / 28.19 ms 26.7 ms / 26.14 ms 23.4 ms / 31.91 ms 20.4 ms / 28.42 ms
send::take median 0.95 ms 0.88 ms 0.59 ms 0.57 ms
Working Set (avg / med / max) 18993 / 21251 / 21742 MB 15146 / 18790 / 19609 MB 18794 / 21669 / 21930 MB 15726 / 19443 / 20356 MB
Private Commit (avg / med / max) 19607 / 21257 / 21873 MB 17518 / 20663 / 20979 MB 19841 / 21973 / 22446 MB 18302 / 21324 / 21889 MB
Shared GPU Mem (med / max) 5350 / 5713 MB 5091 / 5258 MB 6066 / 6208 MB 5632 / 5775 MB
Dedicated VRAM max / room=false 6317 MB (5.9%) 6144 MB (0.0%) 6532 MB (94.7% FAIL) 6515 MB (78.9% PASS)
Free RAM (end of 90s) 395 MB 2594 MB 471 MB 2101 MB
Crashes / DRED / Panics 0 0 0 0

Diagnostics 1440p 90s Visual & Memory Gate (--features diagnostics)

  • All 6 gates PASS (world_windows=19, crashes=0, used_max=6209 MB / budget_min=6699 MB, room=false 0.0%, pngs=24, lit=20/24, luma=101.1, near_black=0.06%, edge_energy=7.73, magenta=0.0%).
  • copystat confirmed retained translation DXIL dropped from 84 MB during initial shader compilation to 0 MB in steady state; inspected output frames showed clean textures, water reflections, foliage, and indirect lighting.
**@⁠Androtim** on GitHub · 2026-12-02 04:46 UTC · [original](https://github.com/Androtim/MiniVI/pull/305) `Androtim:feat/send-spare-and-dxil-trim` → `main` · +301 −25 · 4 files · 1 commits · merged 2026-12-02 04:52 UTC ## Summary Addresses `[USER PRIORITY — MEMORY REALITY CHECK]` in #276 by trimming retained host/upload allocations without introducing submission allocation churn: 1. **Right-sized upload send slabs & stale-first pressure trimming (`crates/victory-gpu/src/host/send.rs`, `crates/victory-gpu/src/host.rs`):** - Lowers the minimum send upload allocation size from `8 MiB` to `1 MiB` (powers of two up to `16 MiB`, then `8 MiB` steps above `16 MiB`) to eliminate 8x over-commit on small submissions and 2x overshoot on large bursts. - Replaces the flat `768 MiB` untrimmed `SPARE` cap with pressure-aware working-set limits (`96 / 128 / 192 / 256 MiB` off-card; `64 / 96 / 128 MiB` on-card) and adds `send::trim_under_pressure` into `host::sweep()` (evicting stale idle slabs >= 5–10s first down to `32 MiB`, dropping `ID3D12Resource`s asynchronously via `drop_aside`). - Default-on with `VICTORY_SEND_SPARE_TRIM=0` kill-switch. 2. **Idle compiled shader DXIL trimming with transparent reload (`crates/victory-gpu/src/pipeline.rs`, `crates/victory-gpu/src/pipeline/host.rs`, `crates/victory-gpu/src/host.rs`):** - Extracts compiled DXIL bytecode out of `Translated.host.dxil` into an independently releasable slot while keeping translation metadata resident. - Adds `pipeline::trim_shader_bytecode` to `host::sweep()`, dropping idle DXIL buffers after 30 s normal / 10 s pressured / 5 s critical commit (`~76–84 MB` released down to `0 MB` in steady state) and reloading transparently from `shader_cache` via `Shader::dxil()` if another pipeline later shares that shader. - Default-on with `VICTORY_SHADER_TRIM=0` kill-switch. ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` — `asset policy: 320 files ok` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib --locked -- send_spare_limit send_alloc_size trim_spare_items shader_trim_enabled shader_dxil_idle_ms` — 5/5 passed - Dual `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings` (default and `--features diagnostics`) — passed (0 warnings) - Plain `--release --bin MiniVI --locked` + `objdump -p` — passed, standard Windows DLLs only ## Paired Plain `--release` 90s A/B vs `main` (`001702f`) *(RTX 4060 Ti 8 GB / i7-13700F / 32 GB RAM, `-PlayParity -WorldSeconds 90`)* | Metric | 1440p `main` | 1440p PR | 4K DLSS-Q `main` | 4K DLSS-Q PR | | --- | ---: | ---: | ---: | ---: | | Median FPS / frame ms | `14.0 fps` (`71.7 ms`) | **`14.95 fps` (`66.85 ms`)** | `6.6 fps` (`151.7 ms`) | **`6.6 fps` (`151.4 ms`)** | | Preparing (`verify-world` / core avg) | `26.4 ms` / `28.19 ms` | **`26.7 ms` / `26.14 ms`** | `23.4 ms` / `31.91 ms` | **`20.4 ms` / `28.42 ms`** | | `send::take` median | `0.95 ms` | **`0.88 ms`** | `0.59 ms` | **`0.57 ms`** | | Working Set (avg / med / max) | `18993 / 21251 / 21742 MB` | **`15146 / 18790 / 19609 MB`** | `18794 / 21669 / 21930 MB` | **`15726 / 19443 / 20356 MB`** | | Private Commit (avg / med / max) | `19607 / 21257 / 21873 MB` | **`17518 / 20663 / 20979 MB`** | `19841 / 21973 / 22446 MB` | **`18302 / 21324 / 21889 MB`** | | Shared GPU Mem (med / max) | `5350 / 5713 MB` | **`5091 / 5258 MB`** | `6066 / 6208 MB` | **`5632 / 5775 MB`** | | Dedicated VRAM max / `room=false` | `6317 MB` (`5.9%`) | **`6144 MB` (`0.0%`)** | `6532 MB` (`94.7%` FAIL) | **`6515 MB` (`78.9%` PASS)** | | Free RAM (end of 90s) | `395 MB` | **`2594 MB`** | `471 MB` | **`2101 MB`** | | Crashes / DRED / Panics | `0` | `0` | `0` | `0` | ## Diagnostics 1440p 90s Visual & Memory Gate (`--features diagnostics`) - **All 6 gates PASS** (`world_windows=19`, `crashes=0`, `used_max=6209 MB / budget_min=6699 MB`, `room=false 0.0%`, `pngs=24`, `lit=20/24`, `luma=101.1`, `near_black=0.06%`, `edge_energy=7.73`, `magenta=0.0%`). - `copystat` confirmed retained translation DXIL dropped from `84 MB` during initial shader compilation to `0 MB` in steady state; inspected output frames showed clean textures, water reflections, foliage, and indirect lighting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 04:51:12 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-02 04:50 UTC · original

Autonomous architectural audit PASSED on 88347e90:

  • Code review: Clean default-on replacement (VICTORY_SEND_SPARE_TRIM=0 and VICTORY_SHADER_TRIM=0 kill-switches only), right-sized send_alloc_size (1..16 MiB powers of two, 8 MiB steps above), lock-safe trim_spare_items + drop_aside, and safe Shader::dxil() reload with Arc<[u8]> lifetime pinned across Create*PipelineState + rect_list_gs (zero stale host.dxil readers remaining in crates/victory-gpu).
  • Plain --release A/B (memtrim2 vs 001702fc, 0 crashes / 0 DRED):
    • 1440p 90s: 14.0 -> 14.95 fps (+0.95 fps), core avg preparing 28.19 -> 26.14 ms, working_set_mb -3,847 MB avg / -2,461 MB med / -2,133 MB max, private_commit_mb -2,089 MB avg / -894 MB max, shared_mb -455 MB max, dedicated_mb 6,317 -> 6,144 MB (room_false 5.9% -> 0.0%), final_waiting 4,121 -> 2,738 (-33.6%), end free RAM 395 -> 2,594 MB (+2,199 MB).
    • 4K 90s: 6.6 -> 6.6 fps (151.7 -> 151.4 ms), preparing 23.4 -> 20.4 ms (-3.0 ms), working_set_mb -3,068 MB avg / -2,226 MB med / -1,574 MB max, private_commit_mb -1,539 MB avg / -557 MB max, shared_mb -433 MB max, VRAM gate FAIL (94.7%) -> PASS (78.9%), final_waiting 12,271 -> 11,469, end free RAM 471 -> 2,101 MB (+1,630 MB).
  • Diagnostics visual check: All 6 gates PASS (luma=101.1, near_black=0.06%, edge_energy=7.73, magenta=0.0%, retained DXIL 84 MB -> 0 MB); captured PNGs inspected directly — crisp lighting, textures, and reflections with zero visual regressions.

Status: Waiting on CI run 46812254254 (Tests currently in progress; Clippy + Clippy, diagnostics build already green). Will squash-merge automatically once green.

**@⁠Androtim** on GitHub · 2026-12-02 04:50 UTC · [original](https://github.com/Androtim/MiniVI/pull/305#issuecomment-7335322340) Autonomous architectural audit **PASSED** on `88347e90`: - **Code review:** Clean default-on replacement (`VICTORY_SEND_SPARE_TRIM=0` and `VICTORY_SHADER_TRIM=0` kill-switches only), right-sized `send_alloc_size` (`1..16 MiB` powers of two, `8 MiB` steps above), lock-safe `trim_spare_items` + `drop_aside`, and safe `Shader::dxil()` reload with `Arc<[u8]>` lifetime pinned across `Create*PipelineState` + `rect_list_gs` (zero stale `host.dxil` readers remaining in `crates/victory-gpu`). - **Plain `--release` A/B (`memtrim2` vs `001702fc`, 0 crashes / 0 DRED):** - **1440p 90s:** `14.0 -> 14.95 fps` (`+0.95 fps`), core avg preparing `28.19 -> 26.14 ms`, `working_set_mb` `-3,847 MB` avg / `-2,461 MB` med / `-2,133 MB` max, `private_commit_mb` `-2,089 MB` avg / `-894 MB` max, `shared_mb` `-455 MB` max, `dedicated_mb` `6,317 -> 6,144 MB` (`room_false 5.9% -> 0.0%`), `final_waiting` `4,121 -> 2,738` (`-33.6%`), end free RAM `395 -> 2,594 MB` (`+2,199 MB`). - **4K 90s:** `6.6 -> 6.6 fps` (`151.7 -> 151.4 ms`), `preparing` `23.4 -> 20.4 ms` (`-3.0 ms`), `working_set_mb` `-3,068 MB` avg / `-2,226 MB` med / `-1,574 MB` max, `private_commit_mb` `-1,539 MB` avg / `-557 MB` max, `shared_mb` `-433 MB` max, VRAM gate `FAIL (94.7%) -> PASS (78.9%)`, `final_waiting` `12,271 -> 11,469`, end free RAM `471 -> 2,101 MB` (`+1,630 MB`). - **Diagnostics visual check:** All 6 gates PASS (`luma=101.1`, `near_black=0.06%`, `edge_energy=7.73`, `magenta=0.0%`, retained DXIL `84 MB -> 0 MB`); captured PNGs inspected directly — crisp lighting, textures, and reflections with zero visual regressions. **Status:** Waiting on CI run `46812254254` (`Tests` currently in progress; `Clippy` + `Clippy, diagnostics build` already green). Will squash-merge automatically once green.
github-bot changed target branch from main to gh-pr/305/base 2026-12-02 04:56:39 +00:00
github manually merged commit 88347e90f6 into gh-pr/305/base 2026-12-02 04:56:42 +00:00
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/Androtim--MiniVI!305
No description provided.