fix(gpu/host): preserve FetchWatermark shrink target, replace numeric reaper knob, and raise critical spare floor #298

Manually merged
github merged 1 commit from github-bot/gh-298 into gh-pr/298/base 2026-12-01 23:52:29 +00:00 AGit
Owner

@⁠Androtim on GitHub · 2026-12-01 23:22 UTC · original
Androtim:fix/host-fetch-watermark-and-reaper-killswitch → main · +53 −39 · 1 files · 1 commits · merged 2026-12-01 23:48 UTC

Summary

Follow-up fixes to crates/victory-gpu/src/host.rs:

  1. Preserve FetchWatermark shrink target (target.max(needed)):

    • FetchWatermark::should_shrink previously returned bool and discarded target = self.peak_bytes.max(floor), causing RelayFetch::buffer and CardWork::fetched to reallocate with self.fetch_buffer(total). When the quiet/pressure shrink window fired on a small fetch (e.g. 64 KiB), it shrank the buffer below floor (16 MiB / 4 MiB) and peak_bytes, causing immediate reallocation on the next multi-MiB fetch.
    • Now returns Option<u64> (Some(target.max(needed))), and both callers allocate self.fetch_buffer(bytes) on growth (None/< total) or shrink (Some(bytes)). Updated fetch_watermark_shrinks_oversized_buffer_after_quiet_window_or_pressure to assert exact returned byte targets.
  2. Replace numeric reaper knob with a =0 kill-switch:

    • Removed VICTORY_REAPER_LIMIT (parse_reaper_limit); drop_aside keeps an internal 256-entry bounded sync_channel with VICTORY_REAPER=0 (reaper_enabled) as the safety kill-switch.
  3. Raise SPARE_CRITICAL_FLOOR from 8 MiB to 16 MiB:

    • Preserves a warmer scratch floor for concurrent list resets under critical_commit() without exceeding SPARE_PRESSURE_FLOOR (32 MiB) or SPARE_MOST (128 MiB).

Verification (100% Measured After Final Edit)

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: asset policy: 319 files ok
  • victory-gpu host::tests::: 69 passed; 0 failed
  • victory-gpu list_upload_pool_tests::: 9 passed; 0 failed
  • Dual workspace clippy --workspace --locked --all-targets -- -D warnings: 0 warnings (default and --features diagnostics)
  • Plain --release --bin MiniVI --locked: compiled cleanly, objdump -p imports standard Windows DLLs only

Matched-Scene 90s Plain --release 1440p A/B (PlayParity, LowVram, DLSS quality, -AutoNudgeMenu) vs origin/main (b2b072e)

Both runs sampled 20 in-world windows at matched draw peaks (max_draws = 7,336 vs 7,346) with 2 s OS memory polling (PrivateMemorySize64, WorkingSet64, Win32_OperatingSystem.FreeVirtualMemory over the 60 s in-world tail):

Metric origin/main (b2b072e) This PR (db8fffb) Delta
Median FPS (frame_ms) 10.35 fps (96.45 ms) 11.45 fps (87.45 ms) +1.10 fps (+10.6% / -9.00 ms)
Peak VRAM (used_max / budget) 6,308 / 6,514 MB (room_false=17.6%, pool not_made=2,208) 6,120 / 6,519 MB (room_false=6.2%, pool not_made=0) -188 MB peak
Texture queue (final_waiting / uploaded) 11,287 / 69,680 7,610 / 78,194 -3,677 (-32.6%)
Process Private Bytes (in-world median / max) 21,299.9 MiB / 22,212.5 MiB 20,825.9 MiB / 22,147.7 MiB -474.0 MiB median
Process Working Set (in-world median) 19,790.8 MiB 19,402.6 MiB -388.2 MiB
OS Commit Left (in-world median / min) 1,389.5 MiB / 460.3 MiB 1,744.3 MiB / 405.5 MiB +354.8 MiB median
Median preparing / copyback 36.25 ms / 9.25 ms 37.2 ms / 11.0 ms +0.95 ms / +1.75 ms
Crashes / VRAM overage 0 / 0 MB 0 / 0 MB Clean
**@⁠Androtim** on GitHub · 2026-12-01 23:22 UTC · [original](https://github.com/Androtim/MiniVI/pull/298) `Androtim:fix/host-fetch-watermark-and-reaper-killswitch` → `main` · +53 −39 · 1 files · 1 commits · merged 2026-12-01 23:48 UTC ### Summary Follow-up fixes to `crates/victory-gpu/src/host.rs`: 1. **Preserve `FetchWatermark` shrink target (`target.max(needed)`):** - `FetchWatermark::should_shrink` previously returned `bool` and discarded `target = self.peak_bytes.max(floor)`, causing `RelayFetch::buffer` and `CardWork::fetched` to reallocate with `self.fetch_buffer(total)`. When the quiet/pressure shrink window fired on a small fetch (e.g. `64 KiB`), it shrank the buffer below `floor` (`16 MiB` / `4 MiB`) and `peak_bytes`, causing immediate reallocation on the next multi-MiB fetch. - Now returns `Option<u64>` (`Some(target.max(needed))`), and both callers allocate `self.fetch_buffer(bytes)` on growth (`None`/`< total`) or shrink (`Some(bytes)`). Updated `fetch_watermark_shrinks_oversized_buffer_after_quiet_window_or_pressure` to assert exact returned byte targets. 2. **Replace numeric reaper knob with a `=0` kill-switch:** - Removed `VICTORY_REAPER_LIMIT` (`parse_reaper_limit`); `drop_aside` keeps an internal `256`-entry bounded `sync_channel` with `VICTORY_REAPER=0` (`reaper_enabled`) as the safety kill-switch. 3. **Raise `SPARE_CRITICAL_FLOOR` from `8 MiB` to `16 MiB`:** - Preserves a warmer scratch floor for concurrent list resets under `critical_commit()` without exceeding `SPARE_PRESSURE_FLOOR` (`32 MiB`) or `SPARE_MOST` (`128 MiB`). --- ### Verification (100% Measured After Final Edit) - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: `asset policy: 319 files ok` - `victory-gpu` `host::tests::`: `69 passed; 0 failed` - `victory-gpu` `list_upload_pool_tests::`: `9 passed; 0 failed` - Dual workspace `clippy --workspace --locked --all-targets -- -D warnings`: 0 warnings (default and `--features diagnostics`) - Plain `--release --bin MiniVI --locked`: compiled cleanly, `objdump -p` imports standard Windows DLLs only #### Matched-Scene 90s Plain `--release` 1440p A/B (`PlayParity`, `LowVram`, `DLSS quality`, `-AutoNudgeMenu`) vs `origin/main` (`b2b072e`) Both runs sampled `20` in-world windows at matched draw peaks (`max_draws = 7,336` vs `7,346`) with 2 s OS memory polling (`PrivateMemorySize64`, `WorkingSet64`, `Win32_OperatingSystem.FreeVirtualMemory` over the 60 s in-world tail): | Metric | `origin/main` (`b2b072e`) | This PR (`db8fffb`) | Delta | |---|---:|---:|---:| | **Median FPS (`frame_ms`)** | `10.35 fps` (`96.45 ms`) | **`11.45 fps` (`87.45 ms`)** | **+1.10 fps (+10.6% / -9.00 ms)** | | **Peak VRAM (`used_max / budget`)** | `6,308 / 6,514 MB` (`room_false=17.6%`, `pool not_made=2,208`) | **`6,120 / 6,519 MB`** (`room_false=6.2%`, **`pool not_made=0`**) | **-188 MB peak** | | **Texture queue (`final_waiting` / `uploaded`)** | `11,287` / `69,680` | **`7,610`** / `78,194` | **-3,677 (-32.6%)** | | **Process Private Bytes (in-world median / max)** | `21,299.9 MiB` / `22,212.5 MiB` | **`20,825.9 MiB` / `22,147.7 MiB`** | **-474.0 MiB median** | | **Process Working Set (in-world median)** | `19,790.8 MiB` | **`19,402.6 MiB`** | **-388.2 MiB** | | **OS Commit Left (in-world median / min)** | `1,389.5 MiB` / `460.3 MiB` | **`1,744.3 MiB`** / `405.5 MiB` | **+354.8 MiB median** | | **Median `preparing` / `copyback`** | `36.25 ms` / `9.25 ms` | `37.2 ms` / `11.0 ms` | `+0.95 ms` / `+1.75 ms` | | **Crashes / VRAM overage** | `0` / `0 MB` | **`0` / `0 MB`** | Clean |
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 23:26:08 +00:00
github-bot changed target branch from main to gh-pr/298/base 2026-12-01 23:52:27 +00:00
github manually merged commit db8fffb49c into gh-pr/298/base 2026-12-01 23:52:29 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-01 23:48 UTC · original

Audited full diff (db8fffb4, +53 -39 in crates/victory-gpu/src/host.rs) and matched-scene 90s plain---release A/B:

  • Bugfix & policy compliance: FetchWatermark::should_shrink now returns Option<u64> (Some(target.max(needed))) with unit tests asserting exact targets (16 MiB / 20 MiB / 4 MiB on 64 KiB calls), eliminating the under-allocation churn on main. Replaces the numeric VICTORY_REAPER_LIMIT knob with an internal 256 bound + VICTORY_REAPER=0 kill-switch, and raises SPARE_CRITICAL_FLOOR to 16 MiB.
  • Plain --release 90s A/B (20 windows, matched draws 7,336 vs 7,346): +1.10 fps (10.35 -> 11.45 fps, -9.0 ms frame time), -188 MB peak VRAM (pool not_made: 2,208 -> 0, over=0 MB), -3,677 final_waiting (-32.6%), -474.0 MiB median private RAM, +354.8 MiB median OS commit left, 0 crashes. (preparing/copyback sit within main's own 9.25–11.5 ms run-to-run spread; dbe161b4 main measured 11.5 ms copyback vs 11.0 ms here, and none of the three changes add hot-path overhead.)
  • Disjoint from dbe161b4 (watch.rs), CI green (46769150433). Merging now.
**@⁠Androtim** on GitHub · 2026-12-01 23:48 UTC · [original](https://github.com/Androtim/MiniVI/pull/298#issuecomment-7329793184) Audited full diff (`db8fffb4`, `+53 -39` in `crates/victory-gpu/src/host.rs`) and matched-scene 90s plain-`--release` A/B: - **Bugfix & policy compliance:** `FetchWatermark::should_shrink` now returns `Option<u64>` (`Some(target.max(needed))`) with unit tests asserting exact targets (`16 MiB` / `20 MiB` / `4 MiB` on `64 KiB` calls), eliminating the under-allocation churn on `main`. Replaces the numeric `VICTORY_REAPER_LIMIT` knob with an internal `256` bound + `VICTORY_REAPER=0` kill-switch, and raises `SPARE_CRITICAL_FLOOR` to `16 MiB`. - **Plain `--release` 90s A/B (`20` windows, matched draws `7,336` vs `7,346`):** `+1.10 fps` (`10.35 -> 11.45 fps`, `-9.0 ms` frame time), `-188 MB` peak VRAM (`pool not_made: 2,208 -> 0`, `over=0 MB`), `-3,677` `final_waiting` (`-32.6%`), `-474.0 MiB` median private RAM, `+354.8 MiB` median OS commit left, `0` crashes. (`preparing`/`copyback` sit within `main`'s own `9.25–11.5 ms` run-to-run spread; `dbe161b4` `main` measured `11.5 ms` copyback vs `11.0 ms` here, and none of the three changes add hot-path overhead.) - Disjoint from `dbe161b4` (`watch.rs`), CI green (`46769150433`). Merging now.
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!298
No description provided.