watch: single-pass ask_once, refusal cache, part_runs coalescing, and bounded open wait #177

Closed
github-bot wants to merge 1 commit from gh-pr/177/head into gh-pr/177/base
Owner

@⁠Androtim on GitHub · 2026-11-30 00:51 UTC · original
Androtim:feat/iter174-watch-hotpath-and-texture-journal → main · +445 −81 · 3 files · 1 commits · closed without merging

Summary

Reduces CPU overhead in the write-watch, page-part coalescing, and texture-refresh journal paths across watch.rs, texture.rs, and shadow.rs:

  1. Skip journal page collection for texture refreshes (crates/victory-gpu/src/watch.rs, texture.rs):

    • Adds watch::writes_since / writes_with so callers that only need to know whether any page changed since a timestamp avoid allocating and collecting a per-page Vec<(usize, u64)>.
    • Switches Staging::refresh in texture.rs to writes_since.
  2. Coalesce contiguous 4 KiB written parts (crates/victory-gpu/src/watch.rs, shadow.rs):

    • Adds watch::part_runs(parts: u16) and uses it in Tracked::take and shadow::by_parts so adjacent dirty 4 KiB sub-pages merge into single copy runs cleanly.
  3. Cache kernel write-watch refusals (crates/victory-gpu/src/watch.rs):

    • Adds VICTORY_REFUSED_KEEP (on by default; 0 disables) so ranges refused by GetWriteWatch are cached per thread across a 64-frame epoch (refusals_stand) and invalidated via refusals_given when title_memory_allocated overlaps the bucketed MiB footprint.
  4. Single-pass ask_once & lock-free is_kept() fast paths (crates/victory-gpu/src/watch.rs):

    • Collapses ask_once into one pass using ask_run_all, handling both clustered and lone ranges under one Asking::hold_all() guard and avoiding duplicate interval coalescing/sorting.
    • Uses atomic is_kept() fast-path checks in ask_ahead, ask_ahead_done, ask_once_end, and wrote.
  5. QPC-free bounded opening fault wait (crates/victory-gpu/src/watch.rs):

    • Extracts wait_open_done / wait_open_done_with so the default !fault_asks() wait performs a bounded 8x64 pause spin without Instant::now() / QPC overhead before falling back to cooperative yielding up to 2,000 us.
  6. Unit tests (crates/victory-gpu/src/watch.rs):

    • Adds tests covering part_runs, writes_since, single_pass_ask_once, refusals_cache_clears_when_title_memory_allocated, and wait_open_done_with transitions.

Verification

  • Policy & Static Checks:
    • cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy: asset policy: 311 files ok
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu watch:: -- --test-threads=1: 56 passed
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu shadow:: -- --test-threads=1: pass
    • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu texture:: -- --test-threads=1: pass
    • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings: pass
    • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings: pass
  • Live GPU Verification (RTX 4060 Ti 8 GB, --release --features diagnostics, DLSS quality, 75s in-world off origin/main, D:\victory-data\cache-minivi-pr165):
    • Series S (LowVram): 13.0 fps median (76.85 ms, min_fps=5.5, preparing=35.25 ms, copyback=11.8 ms), 61,494 textures uploaded (final_waiting=1,791), used_max=6399 MB / budget_min=6871 MB (over=0 MB), 15/24 lit (luma=105.49, edge_energy=7.12, magenta=0.0%), crashes=0.
    • Series X (1440p, PlayParity, LowVram): 10.8 fps median (92.8 ms, max_draws=14,346), used_max=6608 MB / budget_min=6855 MB (over=0 MB, room_false=88.9%), 18/24 lit (luma=104.67, edge_energy=7.19, magenta=0.0%), crashes=0.
**@⁠Androtim** on GitHub · 2026-11-30 00:51 UTC · [original](https://github.com/Androtim/MiniVI/pull/177) `Androtim:feat/iter174-watch-hotpath-and-texture-journal` → `main` · +445 −81 · 3 files · 1 commits · closed without merging ### Summary Reduces CPU overhead in the write-watch, page-part coalescing, and texture-refresh journal paths across `watch.rs`, `texture.rs`, and `shadow.rs`: 1. **Skip journal page collection for texture refreshes (`crates/victory-gpu/src/watch.rs`, `texture.rs`):** - Adds `watch::writes_since` / `writes_with` so callers that only need to know whether any page changed since a timestamp avoid allocating and collecting a per-page `Vec<(usize, u64)>`. - Switches `Staging::refresh` in `texture.rs` to `writes_since`. 2. **Coalesce contiguous 4 KiB written parts (`crates/victory-gpu/src/watch.rs`, `shadow.rs`):** - Adds `watch::part_runs(parts: u16)` and uses it in `Tracked::take` and `shadow::by_parts` so adjacent dirty 4 KiB sub-pages merge into single copy runs cleanly. 3. **Cache kernel write-watch refusals (`crates/victory-gpu/src/watch.rs`):** - Adds `VICTORY_REFUSED_KEEP` (on by default; `0` disables) so ranges refused by `GetWriteWatch` are cached per thread across a 64-frame epoch (`refusals_stand`) and invalidated via `refusals_given` when `title_memory_allocated` overlaps the bucketed MiB footprint. 4. **Single-pass `ask_once` & lock-free `is_kept()` fast paths (`crates/victory-gpu/src/watch.rs`):** - Collapses `ask_once` into one pass using `ask_run_all`, handling both clustered and lone ranges under one `Asking::hold_all()` guard and avoiding duplicate interval coalescing/sorting. - Uses atomic `is_kept()` fast-path checks in `ask_ahead`, `ask_ahead_done`, `ask_once_end`, and `wrote`. 5. **QPC-free bounded opening fault wait (`crates/victory-gpu/src/watch.rs`):** - Extracts `wait_open_done` / `wait_open_done_with` so the default `!fault_asks()` wait performs a bounded `8x64` pause spin without `Instant::now()` / QPC overhead before falling back to cooperative yielding up to 2,000 us. 6. **Unit tests (`crates/victory-gpu/src/watch.rs`):** - Adds tests covering `part_runs`, `writes_since`, `single_pass_ask_once`, `refusals_cache_clears_when_title_memory_allocated`, and `wait_open_done_with` transitions. ### Verification - **Policy & Static Checks:** - `cargo +1.98.1-x86_64-pc-windows-gnu run -p xtask -- policy`: `asset policy: 311 files ok` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu watch:: -- --test-threads=1`: 56 passed - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu shadow:: -- --test-threads=1`: pass - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu texture:: -- --test-threads=1`: pass - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings`: pass - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings`: pass - **Live GPU Verification (`RTX 4060 Ti 8 GB`, `--release --features diagnostics`, `DLSS quality`, `75s` in-world off `origin/main`, `D:\victory-data\cache-minivi-pr165`):** - **Series S (`LowVram`):** **`13.0 fps`** median (`76.85 ms`, `min_fps=5.5`, `preparing=35.25 ms`, `copyback=11.8 ms`), `61,494` textures uploaded (`final_waiting=1,791`), `used_max=6399 MB / budget_min=6871 MB` (`over=0 MB`), `15/24` lit (`luma=105.49`, `edge_energy=7.12`, `magenta=0.0%`), `crashes=0`. - **Series X (`1440p`, `PlayParity`, `LowVram`):** **`10.8 fps`** median (`92.8 ms`, `max_draws=14,346`), `used_max=6608 MB / budget_min=6855 MB` (`over=0 MB`, `room_false=88.9%`), `18/24` lit (`luma=104.67`, `edge_energy=7.19`, `magenta=0.0%`), `crashes=0`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:16:04 +00:00
github-bot closed this pull request 2026-12-01 20:16:04 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-11-30 01:04 UTC · original · edited 2026-11-30 15:02 UTC

Automated triage for the maintainers (not an approval).

Verdict: needs-rebase · CI (check): passing

This PR no longer merges cleanly into main.

To change the verdict: Rebase onto current main and resolve conflicts; CI and triage will run again automatically.


Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-11-30 01:04 UTC · [original](https://github.com/Androtim/MiniVI/pull/177#issuecomment-7265821053) · edited 2026-11-30 15:02 UTC <!-- minivi-triage v1 head=78ed49b33cb52c5411109835f00599e9f6a5ece7 verdict=needs-rebase ci=passing at=2026-11-30T15:02:50Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-rebase` · **CI (`check`):** `passing` This PR no longer merges cleanly into `main`. **To change the verdict:** Rebase onto current `main` and resolve conflicts; CI and triage will run again automatically. --- _Generated with Antigravity CLI (`agy`)._
Author
Owner

@⁠Androtim on GitHub · 2026-11-30 08:12 UTC · original

GitHub reports merge conflicts against current \main\ (\98c171). Please rebase on \main\ so we can re-verify on hardware.

**@⁠Androtim** on GitHub · 2026-11-30 08:12 UTC · [original](https://github.com/Androtim/MiniVI/pull/177#issuecomment-7272607273) GitHub reports merge conflicts against current \main\ (\98c171\). Please rebase on \main\ so we can re-verify on hardware.
Author
Owner

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

Closing stale/conflicted backlog PR per #276. Superseded by the active root-architecture replacement pillars with isolated plain --release A/B verification.

**@⁠Androtim** on GitHub · 2026-12-01 01:38 UTC · [original](https://github.com/Androtim/MiniVI/pull/177#issuecomment-7297734761) Closing stale/conflicted backlog PR per #276. Superseded by the active root-architecture replacement pillars with isolated plain --release A/B verification.

Pull request closed

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!177
No description provided.