perf(gpu): offload sweep thread and tighten reclaim lag #363

Manually merged
github merged 1 commit from gh-pr/363/head into gh-pr/363/base 2026-12-02 18:41:13 +00:00
Owner

@⁠Androtim on GitHub · 2026-12-02 17:29 UTC · original
Androtim:perf/async-sweep-and-reclaim-lag → main · +203 −87 · 3 files · 1 commits · merged 2026-12-02 18:33 UTC

Offloads periodic idle-memory sweeping off victory-submit and tightens host/GPU resource reclamation latency (#276).

Changes

  1. Background victory-sweep worker (crates/victory-gpu/src/host/sweep.rs, host.rs)
    • Extracted periodic sweep logic into host/sweep.rs (trigger_sweep / sweep_once), running on a persistent low-priority (THREAD_PRIORITY_BELOW_NORMAL on Windows) victory-sweep worker thread signaled via non-blocking try_lock() so victory-submit never blocks on sweeps (VICTORY_SWEEP_ASYNC=0 kill-switch restores inline sweeps).
    • Removed the 1.5 s synchronous settle() pipeline drain in Host::submit when sweep_async_on() is enabled, since evicted resources retire safely via host::retire() or are already unused.
    • Wrapped sweep_once() in catch_unwind with a warning trace so panics cannot kill the worker.
  2. Submission reclamation lag tuning (crates/victory-gpu/src/host/sweep.rs, host.rs)
    • Normalized bury_lag() default to 16 across all hosts (VICTORY_BURY_LAG overrides) and added landed_lag() (default 8, clamped to bury_lag(), override VICTORY_LANDED_LAG) for line.landed recycling in host::land().
  3. Faster pool block reuse (crates/victory-gpu/src/pool.rs)
    • Lowered pool::REST from 2500 ms to 500 ms so released texture pool pieces recycle across submissions before triggering new block allocations.

Verification Gates

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy -> asset policy: 327 files ok
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu host::sweep::tests --locked -> 2 passed; 0 failed
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu graveyard_tests --locked -> 3 passed; 0 failed
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu pool::tests --locked -> 20 passed; 0 failed; 1 ignored (hardware timing bench)
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings -> pass
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warnings -> pass
  • objdump -p on plain --release build -> standard Windows system DLLs only

Paired Plain --release A/B Benchmarks (vs main @ 80d3ff4, Series X parity, DLSS Quality)

  • 1440p 90s ABBA (ab-main/ab2-main vs ab-pr-sweep/ab2-pr-sweep):
    • ABBA median FPS: 13.93 fps (14.1 / 13.75) -> 14.23 fps (13.65 / 14.8, +0.30 fps)
    • Minimum FPS: 0.6 / 2.8 (avg 1.70 fps) -> 1.4 / 5.4 (avg 3.40 fps)
    • the heaps' records and what is swept: 1.5–2.5 ms/f (8.10 ms max) -> 0.40 ms med / 0.50 ms max
    • waiting for flights: 9.60 ms max -> 3.60 ms max; total_sub mean: 40.53 ms -> 36.30 ms
    • end_heaps max: 16.10 ms -> 2.90 ms
    • final_waiting: 5405 / 2916 -> 2842 / 2952 (Texture streaming healthy gate: FAIL/PASS -> PASS/PASS)
    • crashes=0 across all 4 runs
  • 4K 90s (ab-main-80d3ff4-4k-90s vs ab-pr-sweep-4k-90s):
    • the heaps' records and what is swept: 2.70 ms med (3.05 ms mean, 10.40 ms max) -> 0.40 ms med (0.38 ms mean, 0.60 ms max)
    • total_sub: 153.80 ms med -> 142.75 ms med; wait_flights: 119.35 ms -> 96.30 ms med
    • pool_not_made: 1163 -> 197; no_room_so_far: 34500 -> 23000; showed_another_view: 21 -> 9
    • median_fps: 6.2 fps -> 6.0 fps (max_draws 13577 -> 13848), crashes=0

--features diagnostics Visual Verification (diag-pr-sweep-1440p-90s, 90s 1440p)

  • 6/6 gates PASS: world_windows=19 (max_draws=14299), crashes=0, used_max=6015 MB (over=0 MB, room_false=0.0%), final_waiting=3831, mapped_rate=0.75 ms/s (longest 8.4 ms), pngs=24 (lit=21/24, luma=101.58, near_black=0.06%, edge_energy=7.66, magenta=0.0%).
  • Visually inspected frame-1927.png, frame-1935.png, and frame-1941.png: clean lighting, water reflections, foliage/architectural textures, and HUD text.
**@⁠Androtim** on GitHub · 2026-12-02 17:29 UTC · [original](https://github.com/Androtim/MiniVI/pull/363) `Androtim:perf/async-sweep-and-reclaim-lag` → `main` · +203 −87 · 3 files · 1 commits · merged 2026-12-02 18:33 UTC Offloads periodic idle-memory sweeping off `victory-submit` and tightens host/GPU resource reclamation latency (`#276`). ### Changes 1. **Background `victory-sweep` worker (`crates/victory-gpu/src/host/sweep.rs`, `host.rs`)** - Extracted periodic sweep logic into `host/sweep.rs` (`trigger_sweep` / `sweep_once`), running on a persistent low-priority (`THREAD_PRIORITY_BELOW_NORMAL` on Windows) `victory-sweep` worker thread signaled via non-blocking `try_lock()` so `victory-submit` never blocks on sweeps (`VICTORY_SWEEP_ASYNC=0` kill-switch restores inline sweeps). - Removed the 1.5 s synchronous `settle()` pipeline drain in `Host::submit` when `sweep_async_on()` is enabled, since evicted resources retire safely via `host::retire()` or are already unused. - Wrapped `sweep_once()` in `catch_unwind` with a warning trace so panics cannot kill the worker. 2. **Submission reclamation lag tuning (`crates/victory-gpu/src/host/sweep.rs`, `host.rs`)** - Normalized `bury_lag()` default to `16` across all hosts (`VICTORY_BURY_LAG` overrides) and added `landed_lag()` (default `8`, clamped to `bury_lag()`, override `VICTORY_LANDED_LAG`) for `line.landed` recycling in `host::land()`. 3. **Faster pool block reuse (`crates/victory-gpu/src/pool.rs`)** - Lowered `pool::REST` from `2500 ms` to `500 ms` so released texture pool pieces recycle across submissions before triggering new block allocations. ### Verification Gates - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` -> `asset policy: 327 files ok` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu host::sweep::tests --locked` -> `2 passed; 0 failed` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu graveyard_tests --locked` -> `3 passed; 0 failed` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu pool::tests --locked` -> `20 passed; 0 failed; 1 ignored` (hardware timing bench) - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings` -> pass - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warnings` -> pass - `objdump -p` on plain `--release` build -> standard Windows system DLLs only ### Paired Plain `--release` A/B Benchmarks (vs `main` @ `80d3ff4`, `Series X` parity, DLSS Quality) - **1440p 90s ABBA (`ab-main`/`ab2-main` vs `ab-pr-sweep`/`ab2-pr-sweep`):** - ABBA median FPS: `13.93 fps` (`14.1` / `13.75`) -> **`14.23 fps` (`13.65` / `14.8`, `+0.30 fps`)** - Minimum FPS: `0.6` / `2.8` (avg `1.70 fps`) -> **`1.4` / `5.4` (avg `3.40 fps`)** - `the heaps' records and what is swept`: `1.5–2.5 ms/f` (`8.10 ms` max) -> **`0.40 ms` med / `0.50 ms` max** - `waiting for flights`: `9.60 ms` max -> **`3.60 ms` max**; `total_sub` mean: `40.53 ms` -> **`36.30 ms`** - `end_heaps` max: `16.10 ms` -> **`2.90 ms`** - `final_waiting`: `5405` / `2916` -> **`2842` / `2952`** (`Texture streaming healthy` gate: FAIL/PASS -> PASS/PASS) - `crashes=0` across all 4 runs - **4K 90s (`ab-main-80d3ff4-4k-90s` vs `ab-pr-sweep-4k-90s`):** - `the heaps' records and what is swept`: `2.70 ms` med (`3.05 ms` mean, `10.40 ms` max) -> **`0.40 ms` med (`0.38 ms` mean, `0.60 ms` max)** - `total_sub`: `153.80 ms` med -> **`142.75 ms` med**; `wait_flights`: `119.35 ms` -> **`96.30 ms` med** - `pool_not_made`: `1163` -> **`197`**; `no_room_so_far`: `34500` -> **`23000`**; `showed_another_view`: `21` -> **`9`** - `median_fps`: `6.2 fps` -> `6.0 fps` (`max_draws` `13577` -> `13848`), `crashes=0` ### `--features diagnostics` Visual Verification (`diag-pr-sweep-1440p-90s`, 90s 1440p) - **6/6 gates PASS:** `world_windows=19` (`max_draws=14299`), `crashes=0`, `used_max=6015 MB` (`over=0 MB`, `room_false=0.0%`), `final_waiting=3831`, `mapped_rate=0.75 ms/s` (longest `8.4 ms`), `pngs=24` (`lit=21/24`, `luma=101.58`, `near_black=0.06%`, `edge_energy=7.66`, `magenta=0.0%`). - Visually inspected `frame-1927.png`, `frame-1935.png`, and `frame-1941.png`: clean lighting, water reflections, foliage/architectural textures, and HUD text.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 18:41:11 +00:00
github manually merged commit 60a88573a9 into gh-pr/363/base 2026-12-02 18:41:13 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-02 17:33 UTC · original

Architect Triage: aaeb12f0 currently conflicts with main (after #359/#342 merged into host.rs) and has no CI run yet (checks=[]). Please rebase onto main to resolve the conflict and trigger CI — once CI is green, we will inspect the diag-pr-sweep-1440p-90s PNGs and A/B numbers for merge!

**@⁠Androtim** on GitHub · 2026-12-02 17:33 UTC · [original](https://github.com/Androtim/MiniVI/pull/363#issuecomment-7353417948) Architect Triage: `aaeb12f0` currently conflicts with `main` (after `#359`/`#342` merged into `host.rs`) and has no CI run yet (`checks=[]`). Please rebase onto `main` to resolve the conflict and trigger CI — once CI is green, we will inspect the `diag-pr-sweep-1440p-90s` PNGs and A/B numbers for merge!
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!363
No description provided.