victory-gpu: overlap write-watch ask_once, parallel preludes, and Batch write dedup #309

Manually merged
github merged 1 commit from github-bot/gh-309 into gh-pr/309/base 2026-12-02 08:49:34 +00:00 AGit
Owner

@⁠Androtim on GitHub · 2026-12-02 08:34 UTC · original
Androtim:perf/async-ask-once-and-parallel-preludes → main · +604 −212 · 3 files · 1 commits · merged 2026-12-02 08:49 UTC

Summary

Addresses Issue #276 Rank 2 (parallelizing CPU submission preparing work on the main queue thread):

  1. Overlapped write-watch querying (crates/victory-gpu/src/watch.rs, host.rs):
    • Adds a persistent victory-ask worker (begin_ask_once, AskedOnce, ask_once_extend) default-on (VICTORY_ASK_OVERLAP=0 kill-switch).
    • Starts ask_once on runs's asked_ahead spans before card_steps, overlaps OS GetWriteWatch cost with command-planning/heaps work, then incrementally merges any late own.list() Step::Refresh ranges via Batch::extend_copy_spans + watch::ask_once_extend without re-scanning runs or duplicating ask_once.
  2. Parallel HostList prelude recording (crates/victory-gpu/src/host/prelude.rs, host.rs):
    • Extracts prelude planning/recording into host/prelude.rs (PreludePlan, HostList::plan_prelude, HostList::record_prelude, record_all) default-on (VICTORY_PARALLEL_PRELUDES=0 kill-switch).
    • Prepares distinct HostList command list preludes in parallel across land::each_under workers.
  3. Fused Batch write deduplication & early flush_one (crates/victory-gpu/src/host.rs):
    • Adds AheadRanges::covering_span and Batch::{last_ahead, seen_writes, declared_places, declared} with Batch::note_write / take_declared to skip redundant covering-range lookups and deduplicate contiguous GPU writes during step iteration.
    • Keeps host.rs below the 655,360-byte xtask policy file limit (654,043 bytes).

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: PASS (asset policy: 321 files ok, host.rs 654,043 bytes < 655,360 limit)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib --locked -- parse_ask_overlap begin_ask_once ahead_ranges_covering_span parse_parallel_preludes: PASS (4/4 passed)
  • 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
  • Plain --release build + objdump -p: standard Windows DLLs only (KERNEL32.dll, d3d12.dll, dxgi.dll, etc.)

Paired Same-Path Plain---release A/B (D:\victory-build\minivi\release\victory.exe, 90s world runs)

Measured from the identical executable path to eliminate NVIDIA DXCache per-path cold shader compilation skew (main 79e8487 vs PR branch):

Resolution Metric main (79e8487) PR Delta
1440p (-PlayParity -Res 1440 -DlssMode quality) preparing (report median) 28.0 ms 24.8 ms -3.2 ms (-11.4%)
1440p preparing_core_ms avg / med 31.96 / 35.70 ms 30.07 / 34.70 ms -1.89 / -1.00 ms
1440p asking_watch_ms avg / med 3.85 / 4.80 ms 2.48 / 3.00 ms -35.6% / -37.5%
1440p thin_ms avg 506.94 ms 476.55 ms -30.39 ms
1440p Median FPS / frame time 14.6 fps (68.6 ms) 14.6 fps (68.5 ms) -0.1 ms
1440p mapped() stall rate 12.1 ms/s 7.28 ms/s -4.82 ms/s
4K (-PlayParity -Res 4k -DlssMode quality) preparing (report median) 20.0 ms 17.5 ms -2.5 ms (-12.5%)
4K preparing_core_ms avg / med 28.66 / 31.50 ms 26.32 / 28.40 ms -2.34 / -3.10 ms (-9.8%)
4K asking_watch_ms avg / med 2.88 / 3.50 ms 1.91 / 2.10 ms -33.7% / -40.0%
4K thin_ms avg / med 533.26 / 647.20 ms 519.49 / 622.60 ms -13.77 / -24.60 ms
4K Median FPS / frame time 6.7 fps (149.8 ms) 6.4 fps (155.2 ms) GPU-bound (112.05 vs 122.2 ms)
  • Zero crashes, zero panics, zero DRED events, zero mapped() stalls in all 4 runs.

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

  • Exit 0 — All 6 gates PASS:
    • Reached real 3D world: world_windows=20, max_draws=12380
    • Zero crashes / DRED / panics: crashes=0, no_host_texture_errors=0, untranslated=6
    • VRAM within card budget: used_max=6303 MB, budget_min=6686 MB, over=0 MB, room_false=0.0%
    • Texture streaming healthy: final_waiting=2106, max_waiting=35556
    • Residency stalls bounded: mapped_rate=11.07 ms/world_sec (4000 calls, 364.2 ms total, max 9.8 ms)
    • Visual lighting & texture detail: pngs=24, lit=21/24, luma=99.76, near_black=0.06%, edge_energy=7.85, magenta=0.0%
  • Inspected frame-2049.png, frame-2057.png, and frame-2073.png directly — full world lighting, textures, reflections, and crisp HUD overlay with zero artifacts.
**@⁠Androtim** on GitHub · 2026-12-02 08:34 UTC · [original](https://github.com/Androtim/MiniVI/pull/309) `Androtim:perf/async-ask-once-and-parallel-preludes` → `main` · +604 −212 · 3 files · 1 commits · merged 2026-12-02 08:49 UTC ## Summary Addresses Issue #276 Rank 2 (parallelizing CPU submission `preparing` work on the main queue thread): 1. **Overlapped write-watch querying (`crates/victory-gpu/src/watch.rs`, `host.rs`):** - Adds a persistent `victory-ask` worker (`begin_ask_once`, `AskedOnce`, `ask_once_extend`) default-on (`VICTORY_ASK_OVERLAP=0` kill-switch). - Starts `ask_once` on `runs`'s `asked_ahead` spans before `card_steps`, overlaps OS `GetWriteWatch` cost with command-planning/heaps work, then incrementally merges any late `own.list()` `Step::Refresh` ranges via `Batch::extend_copy_spans` + `watch::ask_once_extend` without re-scanning `runs` or duplicating `ask_once`. 2. **Parallel `HostList` prelude recording (`crates/victory-gpu/src/host/prelude.rs`, `host.rs`):** - Extracts prelude planning/recording into `host/prelude.rs` (`PreludePlan`, `HostList::plan_prelude`, `HostList::record_prelude`, `record_all`) default-on (`VICTORY_PARALLEL_PRELUDES=0` kill-switch). - Prepares distinct `HostList` command list preludes in parallel across `land::each_under` workers. 3. **Fused `Batch` write deduplication & early `flush_one` (`crates/victory-gpu/src/host.rs`):** - Adds `AheadRanges::covering_span` and `Batch::{last_ahead, seen_writes, declared_places, declared}` with `Batch::note_write` / `take_declared` to skip redundant covering-range lookups and deduplicate contiguous GPU writes during step iteration. - Keeps `host.rs` below the 655,360-byte `xtask policy` file limit (`654,043` bytes). ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: **PASS** (`asset policy: 321 files ok`, `host.rs` `654,043` bytes < `655,360` limit) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib --locked -- parse_ask_overlap begin_ask_once ahead_ranges_covering_span parse_parallel_preludes`: **PASS** (4/4 passed) - `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** - Plain `--release` build + `objdump -p`: standard Windows DLLs only (`KERNEL32.dll`, `d3d12.dll`, `dxgi.dll`, etc.) ### Paired Same-Path Plain-`--release` A/B (`D:\victory-build\minivi\release\victory.exe`, 90s world runs) Measured from the identical executable path to eliminate NVIDIA `DXCache` per-path cold shader compilation skew (`main` `79e8487` vs PR branch): | Resolution | Metric | `main` (`79e8487`) | PR | Delta | |---|---|---:|---:|---:| | **1440p** (`-PlayParity -Res 1440 -DlssMode quality`) | `preparing` (report median) | `28.0 ms` | **`24.8 ms`** | **`-3.2 ms` (`-11.4%`)** | | **1440p** | `preparing_core_ms` avg / med | `31.96` / `35.70 ms` | **`30.07` / `34.70 ms`** | **`-1.89` / `-1.00 ms`** | | **1440p** | `asking_watch_ms` avg / med | `3.85` / `4.80 ms` | **`2.48` / `3.00 ms`** | **`-35.6%` / `-37.5%`** | | **1440p** | `thin_ms` avg | `506.94 ms` | **`476.55 ms`** | **`-30.39 ms`** | | **1440p** | Median FPS / frame time | `14.6 fps` (`68.6 ms`) | `14.6 fps` (`68.5 ms`) | `-0.1 ms` | | **1440p** | `mapped()` stall rate | `12.1 ms/s` | `7.28 ms/s` | `-4.82 ms/s` | | **4K** (`-PlayParity -Res 4k -DlssMode quality`) | `preparing` (report median) | `20.0 ms` | **`17.5 ms`** | **`-2.5 ms` (`-12.5%`)** | | **4K** | `preparing_core_ms` avg / med | `28.66` / `31.50 ms` | **`26.32` / `28.40 ms`** | **`-2.34` / `-3.10 ms` (`-9.8%`)** | | **4K** | `asking_watch_ms` avg / med | `2.88` / `3.50 ms` | **`1.91` / `2.10 ms`** | **`-33.7%` / `-40.0%`** | | **4K** | `thin_ms` avg / med | `533.26` / `647.20 ms` | **`519.49` / `622.60 ms`** | **`-13.77` / `-24.60 ms`** | | **4K** | Median FPS / frame time | `6.7 fps` (`149.8 ms`) | `6.4 fps` (`155.2 ms`) | GPU-bound (`112.05` vs `122.2 ms`) | - Zero crashes, zero panics, zero DRED events, zero `mapped()` stalls in all 4 runs. ### `--features diagnostics` Visual Verification (`diag-pr-askprelude-1440p-90s`, 1440p) - **Exit 0 — All 6 gates PASS:** - `Reached real 3D world`: `world_windows=20`, `max_draws=12380` - `Zero crashes / DRED / panics`: `crashes=0`, `no_host_texture_errors=0`, `untranslated=6` - `VRAM within card budget`: `used_max=6303 MB`, `budget_min=6686 MB`, `over=0 MB`, `room_false=0.0%` - `Texture streaming healthy`: `final_waiting=2106`, `max_waiting=35556` - `Residency stalls bounded`: `mapped_rate=11.07 ms/world_sec` (`4000` calls, `364.2 ms` total, max `9.8 ms`) - `Visual lighting & texture detail`: `pngs=24`, `lit=21/24`, `luma=99.76`, `near_black=0.06%`, `edge_energy=7.85`, `magenta=0.0%` - Inspected `frame-2049.png`, `frame-2057.png`, and `frame-2073.png` directly — full world lighting, textures, reflections, and crisp HUD overlay with zero artifacts.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 08:38:47 +00:00
github-bot changed target branch from main to gh-pr/309/base 2026-12-02 08:49:30 +00:00
github manually merged commit c2dc61bd7f into gh-pr/309/base 2026-12-02 08:49:34 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-12-02 08:49 UTC · original

Autonomous architectural audit PASSED on c2dc61bd (CI GREEN):

  • Code review: Clean default-on CPU submission parallelism (VICTORY_ASK_OVERLAP=0 and VICTORY_PARALLEL_PRELUDES=0 kill-switches only):
    • Overlapped victory-ask worker safely joins before ask_once re-query when settled_before_prep runs and incrementally merges late own.list() ranges via extend_copy_spans + ask_once_extend.
    • HostList::plan_prelude preserves exact sequential texture.state / twin.behind ordering before prelude::record_all parallelizes D3D12 command recording only across strictly distinct HostList pointers.
    • Batch::note_write / take_declared matches declared_writes(runs) semantics while eliminating duplicate Shadow::writing locks and keeping host.rs below the xtask policy size cap.
  • Plain --release A/B (0 crashes / 0 DRED):
    • 1440p 90s: preparing 28.0 -> 24.8 ms (-3.2 ms / -11.4%), asking_watch_ms -35.6% / -37.5%, thin_ms -30.39 ms, mapped() 12.1 -> 7.28 ms/s, median FPS 14.6 -> 14.6 fps (68.6 -> 68.5 ms).
    • 4K 90s: preparing 20.0 -> 17.5 ms (-2.5 ms / -12.5%), preparing_core_ms -2.34 / -3.10 ms (-9.8%), asking_watch_ms -33.7% / -40.0%, thin_ms -13.77 / -24.60 ms.
  • Diagnostics (1440p 90s): All 6 gates PASS (over=0 MB, room_false=0.0%, final_waiting=2,106, untranslated=6).

Squash-merging into main.

**@⁠Androtim** on GitHub · 2026-12-02 08:49 UTC · [original](https://github.com/Androtim/MiniVI/pull/309#issuecomment-7339974150) Autonomous architectural audit **PASSED** on `c2dc61bd` (CI GREEN): - **Code review:** Clean default-on CPU submission parallelism (`VICTORY_ASK_OVERLAP=0` and `VICTORY_PARALLEL_PRELUDES=0` kill-switches only): - Overlapped `victory-ask` worker safely joins before `ask_once` re-query when `settled_before_prep` runs and incrementally merges late `own.list()` ranges via `extend_copy_spans` + `ask_once_extend`. - `HostList::plan_prelude` preserves exact sequential `texture.state` / `twin.behind` ordering before `prelude::record_all` parallelizes D3D12 command recording only across strictly distinct `HostList` pointers. - `Batch::note_write` / `take_declared` matches `declared_writes(runs)` semantics while eliminating duplicate `Shadow::writing` locks and keeping `host.rs` below the `xtask policy` size cap. - **Plain `--release` A/B (`0` crashes / `0` DRED):** - **1440p 90s:** `preparing` `28.0 -> 24.8 ms` (`-3.2 ms` / `-11.4%`), `asking_watch_ms` `-35.6% / -37.5%`, `thin_ms` `-30.39 ms`, `mapped()` `12.1 -> 7.28 ms/s`, median FPS `14.6 -> 14.6 fps` (`68.6 -> 68.5 ms`). - **4K 90s:** `preparing` `20.0 -> 17.5 ms` (`-2.5 ms` / `-12.5%`), `preparing_core_ms` `-2.34 / -3.10 ms` (`-9.8%`), `asking_watch_ms` `-33.7% / -40.0%`, `thin_ms` `-13.77 / -24.60 ms`. - **Diagnostics (`1440p` 90s):** All 6 gates PASS (`over=0 MB`, `room_false=0.0%`, `final_waiting=2,106`, `untranslated=6`). Squash-merging into `main`.
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!309
No description provided.