victory-gpu: page-scoped write-watch askings for submission queries #324

Merged
Androtim merged 1 commit from upstream-pr/324 into main 2026-12-02 11:18:23 +00:00
Androtim commented 2026-12-02 11:01:47 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T11:01:47Z.


Summary

Replaces whole-address-space write-watch locking (Asking::hold_all()) during submission ask_ahead / ask_rest queries in crates/victory-gpu/src/watch.rs with default-on page-scoped interval holding (Askings, with VICTORY_ASK_HOLD_PAGES=0 kill-switch):

  1. Page-scoped interval holding (Askings, overlaps, hold_pages):
    • Adds Askings::hold(ranges) which atomically acquires sorted, coalesced page intervals in ASKING, blocking only when another thread queries an overlapping page range and allowing disjoint queries (such as descriptor heap sync on HeapSync) to run concurrently without waiting.
    • Enables page-scoped holding by default with a VICTORY_ASK_HOLD_PAGES=0 kill-switch (parse_hold_pages).
  2. ask_ahead pre-grouping & empty-run fast path:
    • Groups sorted intervals into multi-piece runs before taking ASKING and returns early when runs.is_empty() instead of acquiring locks unnecessarily.
    • Coalesces the exact page intervals of those runs into Askings::hold_or_all.
  3. Non-destructive ask_rest + shared collect_rest_candidates / record_rest_pages helpers:
    • Instead of taking j.ahead empty under a full-memory Asking::hold_all() lock (which forced concurrent readers to fall back to kernel queries), clones journal().ahead, collects uncached alone candidates via collect_rest_candidates, skips ASKING completely when alone.is_empty(), and holds only coalesced alone intervals via Askings::hold while recording results through shared record_rest_pages.
  4. Unit tests (watch::ask_holds):
    • parse_hold_pages_defaults_on_and_honors_zero_kill_switch
    • overlaps_handles_sorted_non_overlapping_ranges
    • an_asking_waits_only_for_the_pages_it_asks_about

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy: PASS (asset policy: 322 files ok)
  • Targeted unit tests (cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib watch --locked): 61 passed, 0 failed, 0 ignored
  • Dual workspace clippy --all-targets -- -D warnings (default + --features diagnostics): PASS
  • Plain --release --bin MiniVI --locked + objdump -p: PASS (standard Windows DLLs only)
  • --features diagnostics 1440p 90s in-world verification (diag-pr-askpages-1440p-90s): PASS (6/6 gates)
    • world_windows=18, max_draws=14311, crashes=0, no_host_texture_errors=0, used_max=6204 MB / budget_min=6768 MB, final_waiting=2167, mapped_rate=0.49 ms/s (4800 calls, 381.6 ms, longest 9.8 ms), pngs=24, lit=21/24, luma=100.94, near_black=0.06%, edge_energy=7.71, magenta=0.0%
    • ranges held lock waits per frame (victory_gpu::copystat): 1.16–1.28 ms -> 0.43–0.45 ms steady state (-62%)
    • Visually inspected the 3 largest world PNGs (frame-2377.png, frame-2409.png, frame-2385.png): clean world rendering and HUD with zero visual regressions.

Paired Same-Path Plain---release A/B Benchmarks vs main (1dffebf)

Both runs executed on RTX 4060 Ti 8 GB / i7-13700F / 32 GB RAM from D:\victory-build\minivi\release\victory.exe (-PlayParity -AutoNudgeMenu -WorldSeconds 90). Zero crashes, panics, or DRED faults.

1440p (90s, 21 world windows)

Metric main (1dffebf) PR (perf/watch-page-scoped-askings) Delta
Median FPS / frame time 14.6 fps (68.5 ms) 15.1 fps (66.2 ms) +0.5 fps (-2.3 ms)
In-world avg FPS 13.61 fps 16.54 fps +2.93 fps
Report preparing 26.1 ms 25.0 ms -1.1 ms
Report copyback 11.4 ms 10.6 ms -0.8 ms
In-world prep_core_ms (avg / max) 36.58 ms / 83.00 ms 35.07 ms / 49.30 ms -1.51 ms / -33.70 ms
parse_cpufast preparing_core_ms (avg / max) 30.17 ms / 83.00 ms 29.88 ms / 57.40 ms -0.29 ms / -25.60 ms
Descriptor heap sync total (avg / max) 13.39 ms / 16.66 ms 12.33 ms / 14.21 ms -1.06 ms / -2.45 ms
Descriptor heap sync asking (avg) 3.72 ms 3.35 ms -0.37 ms
Descriptor heap sync waited (avg / max) 0.35 ms / 1.70 ms 0.29 ms / 0.74 ms -0.06 ms / -0.96 ms
title_present_wait_ms (avg / med) 22.96 ms / 19.70 ms 17.87 ms / 15.80 ms -5.09 ms / -3.90 ms
card_idle_behind_ms (avg / med) 7.75 ms / 7.80 ms 6.11 ms / 6.30 ms -1.64 ms / -1.50 ms
thin_ms (avg / med) 473.56 ms / 508.10 ms 451.55 ms / 495.10 ms -22.01 ms / -13.00 ms
VRAM used_max / room_false / pool_not_made 6,340 MB / 11.8% / 4,911 6,279 MB / 0.0% / 0 -61 MB / -11.8 pp / -4,911
Process working_set_mb (avg / max) 16,959 / 19,744 MB 16,740 / 19,389 MB -219 / -355 MB
Process private_commit_mb (max) 21,376 MB 20,955 MB -421 MB
Shared VRAM shared_mb (avg / med) 4,453 / 5,062 MB 4,300 / 4,907 MB -153 / -155 MB

4K DLSS Quality (90s, 18 world windows)

Metric main (1dffebf) PR (perf/watch-page-scoped-askings) Delta
Median FPS / frame time (in-world avg) 6.4 fps (155.65 ms, avg 6.49) 6.4 fps (156.45 ms, avg 6.50) 0.0 fps (GPU-bound)
Report preparing 19.1 ms 17.2 ms -1.9 ms (-10.0%)
In-world prep_core_ms (avg / med) 35.48 ms / 33.15 ms 33.72 ms / 29.60 ms -1.76 ms / -3.55 ms
parse_cpufast preparing_core_ms (avg / med / max) 29.74 / 31.80 / 163.60 ms 27.49 / 29.50 / 106.80 ms -2.25 / -2.30 / -56.80 ms
Descriptor heap sync waited (avg / max) 0.28 ms / 4.08 ms 0.14 ms / 0.79 ms -50% / -80.6%
thin_ms (avg) 567.28 ms 523.90 ms -43.38 ms
pool_not_made 116 0 -116
Process working_set_mb (avg / max) 16,923 / 20,160 MB 16,477 / 19,942 MB -446 / -218 MB
Shared VRAM shared_mb (med) 5,684 MB 5,561 MB -123 MB
<!-- greyfinch-sync:Androtim/MiniVI:issue:5605076766 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/324). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T11:01:47Z. --- ## Summary Replaces whole-address-space write-watch locking (`Asking::hold_all()`) during submission `ask_ahead` / `ask_rest` queries in `crates/victory-gpu/src/watch.rs` with default-on page-scoped interval holding (`Askings`, with `VICTORY_ASK_HOLD_PAGES=0` kill-switch): 1. **Page-scoped interval holding (`Askings`, `overlaps`, `hold_pages`)**: - Adds `Askings::hold(ranges)` which atomically acquires sorted, coalesced page intervals in `ASKING`, blocking only when another thread queries an overlapping page range and allowing disjoint queries (such as `descriptor` heap sync on `HeapSync`) to run concurrently without waiting. - Enables page-scoped holding by default with a `VICTORY_ASK_HOLD_PAGES=0` kill-switch (`parse_hold_pages`). 2. **`ask_ahead` pre-grouping & empty-run fast path**: - Groups sorted intervals into multi-piece runs *before* taking `ASKING` and returns early when `runs.is_empty()` instead of acquiring locks unnecessarily. - Coalesces the exact page intervals of those runs into `Askings::hold_or_all`. 3. **Non-destructive `ask_rest` + shared `collect_rest_candidates` / `record_rest_pages` helpers**: - Instead of taking `j.ahead` empty under a full-memory `Asking::hold_all()` lock (which forced concurrent readers to fall back to kernel queries), clones `journal().ahead`, collects uncached `alone` candidates via `collect_rest_candidates`, skips `ASKING` completely when `alone.is_empty()`, and holds only coalesced `alone` intervals via `Askings::hold` while recording results through shared `record_rest_pages`. 4. **Unit tests (`watch::ask_holds`)**: - `parse_hold_pages_defaults_on_and_honors_zero_kill_switch` - `overlaps_handles_sorted_non_overlapping_ranges` - `an_asking_waits_only_for_the_pages_it_asks_about` ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy`: **PASS** (`asset policy: 322 files ok`) - Targeted unit tests (`cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --lib watch --locked`): **61 passed, 0 failed, 0 ignored** - Dual workspace `clippy --all-targets -- -D warnings` (default + `--features diagnostics`): **PASS** - Plain `--release --bin MiniVI --locked` + `objdump -p`: **PASS** (standard Windows DLLs only) - **`--features diagnostics` 1440p 90s in-world verification (`diag-pr-askpages-1440p-90s`)**: **PASS (6/6 gates)** - `world_windows=18, max_draws=14311`, `crashes=0`, `no_host_texture_errors=0`, `used_max=6204 MB / budget_min=6768 MB`, `final_waiting=2167`, `mapped_rate=0.49 ms/s` (`4800` calls, `381.6 ms`, longest `9.8 ms`), `pngs=24, lit=21/24, luma=100.94, near_black=0.06%, edge_energy=7.71, magenta=0.0%` - `ranges held` lock waits per frame (`victory_gpu::copystat`): `1.16–1.28 ms` -> **`0.43–0.45 ms`** steady state (`-62%`) - Visually inspected the 3 largest world PNGs (`frame-2377.png`, `frame-2409.png`, `frame-2385.png`): clean world rendering and HUD with zero visual regressions. ## Paired Same-Path Plain-`--release` A/B Benchmarks vs `main` (`1dffebf`) Both runs executed on RTX 4060 Ti 8 GB / i7-13700F / 32 GB RAM from `D:\victory-build\minivi\release\victory.exe` (`-PlayParity -AutoNudgeMenu -WorldSeconds 90`). Zero crashes, panics, or DRED faults. ### 1440p (90s, 21 world windows) | Metric | `main` (`1dffebf`) | PR (`perf/watch-page-scoped-askings`) | Delta | |---|---:|---:|---:| | Median FPS / frame time | `14.6 fps` (`68.5 ms`) | `15.1 fps` (`66.2 ms`) | `+0.5 fps` (`-2.3 ms`) | | In-world avg FPS | `13.61 fps` | `16.54 fps` | `+2.93 fps` | | Report `preparing` | `26.1 ms` | `25.0 ms` | `-1.1 ms` | | Report `copyback` | `11.4 ms` | `10.6 ms` | `-0.8 ms` | | In-world `prep_core_ms` (avg / max) | `36.58 ms` / `83.00 ms` | `35.07 ms` / `49.30 ms` | `-1.51 ms` / `-33.70 ms` | | `parse_cpufast` `preparing_core_ms` (avg / max) | `30.17 ms` / `83.00 ms` | `29.88 ms` / `57.40 ms` | `-0.29 ms` / `-25.60 ms` | | Descriptor heap sync total (avg / max) | `13.39 ms` / `16.66 ms` | `12.33 ms` / `14.21 ms` | `-1.06 ms` / `-2.45 ms` | | Descriptor heap sync `asking` (avg) | `3.72 ms` | `3.35 ms` | `-0.37 ms` | | Descriptor heap sync `waited` (avg / max) | `0.35 ms` / `1.70 ms` | `0.29 ms` / `0.74 ms` | `-0.06 ms` / `-0.96 ms` | | `title_present_wait_ms` (avg / med) | `22.96 ms` / `19.70 ms` | `17.87 ms` / `15.80 ms` | `-5.09 ms` / `-3.90 ms` | | `card_idle_behind_ms` (avg / med) | `7.75 ms` / `7.80 ms` | `6.11 ms` / `6.30 ms` | `-1.64 ms` / `-1.50 ms` | | `thin_ms` (avg / med) | `473.56 ms` / `508.10 ms` | `451.55 ms` / `495.10 ms` | `-22.01 ms` / `-13.00 ms` | | VRAM `used_max` / `room_false` / `pool_not_made` | `6,340 MB` / `11.8%` / `4,911` | `6,279 MB` / `0.0%` / `0` | `-61 MB` / `-11.8 pp` / `-4,911` | | Process `working_set_mb` (avg / max) | `16,959` / `19,744 MB` | `16,740` / `19,389 MB` | `-219` / `-355 MB` | | Process `private_commit_mb` (max) | `21,376 MB` | `20,955 MB` | `-421 MB` | | Shared VRAM `shared_mb` (avg / med) | `4,453` / `5,062 MB` | `4,300` / `4,907 MB` | `-153` / `-155 MB` | ### 4K DLSS Quality (90s, 18 world windows) | Metric | `main` (`1dffebf`) | PR (`perf/watch-page-scoped-askings`) | Delta | |---|---:|---:|---:| | Median FPS / frame time (in-world avg) | `6.4 fps` (`155.65 ms`, avg `6.49`) | `6.4 fps` (`156.45 ms`, avg `6.50`) | `0.0 fps` (GPU-bound) | | Report `preparing` | `19.1 ms` | `17.2 ms` | `-1.9 ms` (`-10.0%`) | | In-world `prep_core_ms` (avg / med) | `35.48 ms` / `33.15 ms` | `33.72 ms` / `29.60 ms` | `-1.76 ms` / `-3.55 ms` | | `parse_cpufast` `preparing_core_ms` (avg / med / max) | `29.74` / `31.80` / `163.60 ms` | `27.49` / `29.50` / `106.80 ms` | `-2.25` / `-2.30` / `-56.80 ms` | | Descriptor heap sync `waited` (avg / max) | `0.28 ms` / `4.08 ms` | `0.14 ms` / `0.79 ms` | `-50%` / `-80.6%` | | `thin_ms` (avg) | `567.28 ms` | `523.90 ms` | `-43.38 ms` | | `pool_not_made` | `116` | `0` | `-116` | | Process `working_set_mb` (avg / max) | `16,923` / `20,160 MB` | `16,477` / `19,942 MB` | `-446` / `-218 MB` | | Shared VRAM `shared_mb` (med) | `5,684 MB` | `5,561 MB` | `-123 MB` |
Androtim commented 2026-12-02 11:03:36 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T11:03:36Z.


Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): pending

Review Summary

Solid, well-scoped concurrency improvement in crates/victory-gpu/src/watch.rs replacing whole-address-space Asking::hold_all() with default-on page-scoped interval holding (Askings, with VICTORY_ASK_HOLD_PAGES=0 kill-switch) for ask_ahead and ask_rest.

Verified Details

  • Atomic multi-interval locking (Askings::hold, overlaps, Drop for Askings): Acquires all sorted, coalesced page intervals atomically under ASKING.0 + ASKING.1 condvar wait, avoiding lock-ordering deadlocks and interoperating cleanly with single-range Asking::hold and Asking::hold_all. overlaps binary search via partition_point(|&(_, end)| end <= a) and start < b is sound for sorted non-overlapping half-open intervals.
  • ask_ahead pre-grouping: Grouping k - i >= 2 runs before acquiring ASKING and returning early when runs.is_empty() avoids unnecessary locking and matches the existing pieces.len() < 2 early return. Coalescing (first, last) across runs covers every page ask_run(&pieces[i..k], ...) can query, and _held remains live through the journal_mut() update.
  • Non-destructive ask_rest (collect_rest_candidates, record_rest_pages, ask_rest_all): Cloning journal().ahead rather than std::mem::take avoids forcing concurrent readers to miss j.ahead while ask_rest runs. Since all writers to j.ahead maintain sorted, coalesced intervals (via coalesce_intervals or clear), contains_interval in collect_rest_candidates is valid, and record_rest_pages preserves the deduplication check and coalesce_intervals before updating j.ahead and KEPT.
  • Tests (watch::ask_holds): Covers parse_hold_pages default-on / "0" kill-switch, overlaps boundary/touching cases, and concurrent blocking/non-blocking behavior between Askings::hold and Asking::hold.
  • Minor non-blocking note: PAGE_HOLDS is incremented in Askings::hold but is not currently read or reported in diagnostics.

Status

CI is currently pending. Because this changes default-on write-watch locking on the live GPU submission / descriptor heap sync path, it warrants a local real-GPU smoke test once CI completes.


Generated with Antigravity CLI (agy).

<!-- greyfinch-sync:Androtim/MiniVI:comment:7343365939 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/324#issuecomment-7343365939). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T11:03:36Z. --- <!-- minivi-triage v1 head=c193cde11dc7c65d90568f0b2afe7af648ef2ef7 verdict=needs-gpu-test ci=pending at=2026-12-02T11:04:07Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `pending` ### Review Summary Solid, well-scoped concurrency improvement in `crates/victory-gpu/src/watch.rs` replacing whole-address-space `Asking::hold_all()` with default-on page-scoped interval holding (`Askings`, with `VICTORY_ASK_HOLD_PAGES=0` kill-switch) for `ask_ahead` and `ask_rest`. #### Verified Details - **Atomic multi-interval locking (`Askings::hold`, `overlaps`, `Drop for Askings`)**: Acquires all sorted, coalesced page intervals atomically under `ASKING.0` + `ASKING.1` condvar wait, avoiding lock-ordering deadlocks and interoperating cleanly with single-range `Asking::hold` and `Asking::hold_all`. `overlaps` binary search via `partition_point(|&(_, end)| end <= a)` and `start < b` is sound for sorted non-overlapping half-open intervals. - **`ask_ahead` pre-grouping**: Grouping `k - i >= 2` runs before acquiring `ASKING` and returning early when `runs.is_empty()` avoids unnecessary locking and matches the existing `pieces.len() < 2` early return. Coalescing `(first, last)` across runs covers every page `ask_run(&pieces[i..k], ...)` can query, and `_held` remains live through the `journal_mut()` update. - **Non-destructive `ask_rest` (`collect_rest_candidates`, `record_rest_pages`, `ask_rest_all`)**: Cloning `journal().ahead` rather than `std::mem::take` avoids forcing concurrent readers to miss `j.ahead` while `ask_rest` runs. Since all writers to `j.ahead` maintain sorted, coalesced intervals (via `coalesce_intervals` or `clear`), `contains_interval` in `collect_rest_candidates` is valid, and `record_rest_pages` preserves the deduplication check and `coalesce_intervals` before updating `j.ahead` and `KEPT`. - **Tests (`watch::ask_holds`)**: Covers `parse_hold_pages` default-on / `"0"` kill-switch, `overlaps` boundary/touching cases, and concurrent blocking/non-blocking behavior between `Askings::hold` and `Asking::hold`. - **Minor non-blocking note**: `PAGE_HOLDS` is incremented in `Askings::hold` but is not currently read or reported in diagnostics. #### Status CI is currently `pending`. Because this changes default-on write-watch locking on the live GPU submission / descriptor heap sync path, it warrants a local real-GPU smoke test once CI completes. --- _Generated with Antigravity CLI (`agy`)._
Androtim commented 2026-12-02 11:18:18 +00:00 (Migrated from github.com)

Imported from Androtim/MiniVI. Originally posted by Androtim on 2026-12-02T11:18:18Z.


Autonomous architectural audit PASSED on c193cde1 (CI GREEN, allowlisted author Androtim):

  • Code review: Clean default-on page-scoped interval holding (VICTORY_ASK_HOLD_PAGES=0 safety kill-switch only) in crates/victory-gpu/src/watch.rs — atomic single-lock interval acquisition in Askings::hold (deadlock-free), early return when runs.is_empty() in ask_ahead, non-destructive journal().ahead clone + empty-alone fast path in ask_rest, and 61/61 passing watch tests.
  • Plain --release A/B (0 crashes / 0 DRED):
    • 1440p 90s: 14.6 -> 15.1 fps (+0.5 fps med, +2.93 fps in-world avg), preparing 26.1 -> 25.0 ms (-1.1 ms, max -33.7 ms), copyback 11.4 -> 10.6 ms (-0.8 ms), title_present_wait_ms -5.09 ms, room_false 11.8% -> 0.0%, pool_not_made 4,911 -> 0, working_set -355 MB max, private_commit -421 MB max.
    • 4K 90s: preparing 19.1 -> 17.2 ms (-1.9 ms / -10.0%, prep_core max -56.8 ms), descriptor sync waited -50% avg / -80.6% max, thin_ms -43.4 ms, pool_not_made 116 -> 0, working_set -446 MB avg, shared_mb -123 MB med, 6.4 -> 6.4 fps.
  • Diagnostics (1440p 90s): All 6 gates PASS (luma=100.94, near_black=0.06%, edge_energy=7.71, magenta=0.0%, final_waiting=2,167, mapped_rate=0.49 ms/s, ranges held lock waits -62%).

Squash-merging into main.

<!-- greyfinch-sync:Androtim/MiniVI:comment:7343722872 --> Imported from [Androtim/MiniVI](https://github.com/Androtim/MiniVI/pull/324#issuecomment-7343722872). Originally posted by [Androtim](https://github.com/Androtim) on 2026-12-02T11:18:18Z. --- Autonomous architectural audit **PASSED** on `c193cde1` (CI GREEN, allowlisted author `Androtim`): - **Code review:** Clean default-on page-scoped interval holding (`VICTORY_ASK_HOLD_PAGES=0` safety kill-switch only) in `crates/victory-gpu/src/watch.rs` — atomic single-lock interval acquisition in `Askings::hold` (deadlock-free), early return when `runs.is_empty()` in `ask_ahead`, non-destructive `journal().ahead` clone + empty-`alone` fast path in `ask_rest`, and `61/61` passing `watch` tests. - **Plain `--release` A/B (`0` crashes / `0` DRED):** - **1440p 90s:** `14.6 -> 15.1 fps` (`+0.5 fps` med, `+2.93 fps` in-world avg), `preparing 26.1 -> 25.0 ms` (`-1.1 ms`, max `-33.7 ms`), `copyback 11.4 -> 10.6 ms` (`-0.8 ms`), `title_present_wait_ms -5.09 ms`, `room_false 11.8% -> 0.0%`, `pool_not_made 4,911 -> 0`, `working_set -355 MB` max, `private_commit -421 MB` max. - **4K 90s:** `preparing 19.1 -> 17.2 ms` (`-1.9 ms` / `-10.0%`, `prep_core` max `-56.8 ms`), descriptor sync `waited -50%` avg / `-80.6%` max, `thin_ms -43.4 ms`, `pool_not_made 116 -> 0`, `working_set -446 MB` avg, `shared_mb -123 MB` med, `6.4 -> 6.4 fps`. - **Diagnostics (`1440p` 90s):** All 6 gates PASS (`luma=100.94`, `near_black=0.06%`, `edge_energy=7.71`, `magenta=0.0%`, `final_waiting=2,167`, `mapped_rate=0.49 ms/s`, `ranges held` lock waits `-62%`). Squash-merging into `main`.
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Androtim/MiniVI!324
No description provided.