Watch: avoid VirtualQuery in write-fault waits using OPEN_DONE (VICTORY_FAULT_ASK) #1908

Manually merged
github merged 1 commit from github-bot/gh-1908 into main 2026-11-29 08:20:45 +00:00 AGit
Owner

@⁠Nosheboo on GitHub · 2026-11-29 02:14 UTC · original
Nosheboo:port/foxhound-fault-ask → main · +141 −11 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC

Fixes #

What it changes

Ports VICTORY_FAULT_ASK (OPEN_DONE, AGAIN, again, again_at, and open_unlocked / settle / install fast retry path) from readmet3xt-lab/foxhound commit 4349ab56 (GPL-3.0-or-later) into crates/victory-gpu/src/watch.rs.

  • Tracks blocks currently being opened under the guard lock in OPEN_DONE (cleared in both normal and !took paths of settle()).
  • In the write-fault handler (install()), lets a faulted thread spin briefly without blocking on the guard lock or asking Windows via VirtualQuery until OPEN_DONE shows the block is settled, with per-thread rapid-retry capping (again() / again_at(), max 1 rapid retry per address within 1 ms before falling back to writable(at)).
  • Opt-out / legacy behavior switch: set VICTORY_FAULT_ASK=1 (via crate::asked_for!("VICTORY_FAULT_ASK")) to ask Windows directly inside the 100 µs spin loop as before.
  • Scope is strictly limited to crates/victory-gpu/src/watch.rs.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): NVIDIA GeForce RTX 4070 Ti (12 GiB), Windows 11 — unit tests, clippy, and rustfmt verified locally; live in-game telemetry A/B pending after merge/release testing.
  • Before: Guard-contention write faults fell back to VirtualQuery (writable(at)) inside the 100 µs fault-wait loop.
  • After: OPEN_DONE lets settling finish lock-free on the hot path and again() / again_at() bounds rapid same-address retries to avoid spinning forever if memory stays read-only; verified by new unit test watch::ask_holds::fault_again_caps_rapid_retries_and_resets_across_addresses_or_delay (including std::thread::spawn per-thread AGAIN isolation).
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (no shader changes).
  • cargo test passed for the crates it touches: yes
    • cargo test -p victory-gpu --lib --locked -- --test-threads=1 on 7fcac7f: 590 passed; 0 failed; 44 ignored (--test-threads=1 used due to pre-existing parallel watch flake #724; VICTORY_HOME/LOCALAPPDATA isolated, VICTORY_STREAMLINE_DIR unset).
    • cargo clippy -p victory-gpu --no-deps --all-targets --locked: 0 warnings in crates/victory-gpu/src/watch.rs (only pre-existing baseline warnings elsewhere in victory-gpu).
    • rustfmt --edition 2024 --config-path rustfmt.toml: 0 formatting diffs on touched lines in crates/victory-gpu/src/watch.rs.
    • Note: cargo xtask policy fails on pre-existing untouched crates/victory-shader/src/emit/lower.rs (> 655,360 bytes) already present on main (#1460/#1493/#1527).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. No duplicate open PR ports VICTORY_FAULT_ASK / OPEN_DONE in crates/victory-gpu/src/watch.rs.

Council review

Reviewer Model Round 1 Round 2 Verdict
Concurrency & Safety Auditor gpt-6-luna (xhigh) 8/10 9/10 APPROVE
Performance & Modernization Architect gpt-6-luna (xhigh) 8/10 (nosh-perf) 8/10 (verified) APPROVE
Upstream PR Hygiene & Test Critic gpt-6-luna (xhigh) 6/10 (H1 baseline, H2–H3, H5) 9/10 (H1 acknowledged baseline, H2–H5 resolved) APPROVE

Created with Gemini Pro Orchestrator (Neon) and reviewed by GPT-6 Luna (xhigh) in T3 Code.

**@⁠Nosheboo** on GitHub · 2026-11-29 02:14 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1908) `Nosheboo:port/foxhound-fault-ask` → `main` · +141 −11 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC Fixes # ## What it changes Ports `VICTORY_FAULT_ASK` (`OPEN_DONE`, `AGAIN`, `again`, `again_at`, and `open_unlocked` / `settle` / `install` fast retry path) from `readmet3xt-lab/foxhound` commit `4349ab56` (GPL-3.0-or-later) into `crates/victory-gpu/src/watch.rs`. - Tracks blocks currently being opened under the guard lock in `OPEN_DONE` (cleared in both normal and `!took` paths of `settle()`). - In the write-fault handler (`install()`), lets a faulted thread spin briefly without blocking on the guard lock or asking Windows via `VirtualQuery` until `OPEN_DONE` shows the block is settled, with per-thread rapid-retry capping (`again()` / `again_at()`, max 1 rapid retry per address within 1 ms before falling back to `writable(at)`). - Opt-out / legacy behavior switch: set `VICTORY_FAULT_ASK=1` (via `crate::asked_for!("VICTORY_FAULT_ASK")`) to ask Windows directly inside the 100 µs spin loop as before. - Scope is strictly limited to `crates/victory-gpu/src/watch.rs`. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): NVIDIA GeForce RTX 4070 Ti (12 GiB), Windows 11 — unit tests, `clippy`, and `rustfmt` verified locally; live in-game telemetry A/B pending after merge/release testing. - Before: Guard-contention write faults fell back to `VirtualQuery` (`writable(at)`) inside the 100 µs fault-wait loop. - After: `OPEN_DONE` lets settling finish lock-free on the hot path and `again()` / `again_at()` bounds rapid same-address retries to avoid spinning forever if memory stays read-only; verified by new unit test `watch::ask_holds::fault_again_caps_rapid_retries_and_resets_across_addresses_or_delay` (including `std::thread::spawn` per-thread `AGAIN` isolation). - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A (no shader changes). - `cargo test` passed for the crates it touches: yes - `cargo test -p victory-gpu --lib --locked -- --test-threads=1` on `7fcac7f`: `590 passed; 0 failed; 44 ignored` (`--test-threads=1` used due to pre-existing parallel watch flake #724; `VICTORY_HOME`/`LOCALAPPDATA` isolated, `VICTORY_STREAMLINE_DIR` unset). - `cargo clippy -p victory-gpu --no-deps --all-targets --locked`: 0 warnings in `crates/victory-gpu/src/watch.rs` (only pre-existing baseline warnings elsewhere in `victory-gpu`). - `rustfmt --edition 2024 --config-path rustfmt.toml`: 0 formatting diffs on touched lines in `crates/victory-gpu/src/watch.rs`. - Note: `cargo xtask policy` fails on pre-existing untouched `crates/victory-shader/src/emit/lower.rs` (> 655,360 bytes) already present on `main` (`#1460`/`#1493`/`#1527`). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. No duplicate open PR ports `VICTORY_FAULT_ASK` / `OPEN_DONE` in `crates/victory-gpu/src/watch.rs`. ## Council review | Reviewer | Model | Round 1 | Round 2 | Verdict | | --- | --- | --- | --- | --- | | Concurrency & Safety Auditor | `gpt-6-luna` (`xhigh`) | 8/10 | 9/10 | APPROVE | | Performance & Modernization Architect | `gpt-6-luna` (`xhigh`) | 8/10 (`nosh-perf`) | 8/10 (verified) | APPROVE | | Upstream PR Hygiene & Test Critic | `gpt-6-luna` (`xhigh`) | 6/10 (`H1` baseline, `H2`–`H3`, `H5`) | 9/10 (`H1` acknowledged baseline, `H2`–`H5` resolved) | APPROVE | Created with Gemini Pro Orchestrator (Neon) and reviewed by GPT-6 Luna (xhigh) in T3 Code.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 02:17:28 +00:00
github-bot changed title from [pr-performance] Watch: avoid VirtualQuery in write-fault waits using OPEN_DONE (VICTORY_FAULT_ASK) to Watch: avoid VirtualQuery in write-fault waits using OPEN_DONE (VICTORY_FAULT_ASK) 2026-11-29 02:28:41 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-29 03:36 UTC · original · approved these changes

Tested locally merged onto main (568c5e5).

  • Merge: Clean merge in crates/victory-gpu/src/watch.rs.
  • Tests: cargo test -p victory-gpu --lib watch -- --test-threads=1 passed (53 passed; 0 failed, including ask_holds::an_asking_waits_only_for_the_pages_it_asks_about, fault_again_caps_rapid_retries_and_resets_across_addresses_or_delay, and ranges_are_merged_in_order_and_told_apart) with 0 warnings in watch.rs.

Clean OPEN_DONE fault-wait path avoiding unnecessary VirtualQuery syscalls. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-29 03:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1908#pullrequestreview-6101260288) · **approved these changes** Tested locally merged onto `main` (`568c5e5`). - **Merge**: Clean merge in `crates/victory-gpu/src/watch.rs`. - **Tests**: `cargo test -p victory-gpu --lib watch -- --test-threads=1` passed (`53 passed; 0 failed`, including `ask_holds::an_asking_waits_only_for_the_pages_it_asks_about`, `fault_again_caps_rapid_retries_and_resets_across_addresses_or_delay`, and `ranges_are_merged_in_order_and_told_apart`) with 0 warnings in `watch.rs`. Clean `OPEN_DONE` fault-wait path avoiding unnecessary `VirtualQuery` syscalls. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠eleboucher on GitHub · 2026-11-29 07:36 UTC · original

PC result: RTX 4070 Ti SUPER 16 GB, Ryzen 7 9800X3D, 16 GB RAM, Windows 11, native 1440p, VICTORY_BVH_BUILDER=1 VICTORY_ACTIVATE_RAYS=1, diagnostics build of main 568c5e5d plus this PR and several others (one exe, one switch per run), 10-minute runs, medians after 200 s. Same exe without the switch: 24.3 fps (p10 23.5), preparing 30.6 ms.

With the new path (no VirtualQuery in fault waits): 25.4 fps (p10 24.6), preparing 29.2 ms, about +1.1 fps, the best of the five switches tried in this batch. No crash.

**@⁠eleboucher** on GitHub · 2026-11-29 07:36 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1908#issuecomment-7252573490) PC result: RTX 4070 Ti SUPER 16 GB, Ryzen 7 9800X3D, 16 GB RAM, Windows 11, native 1440p, `VICTORY_BVH_BUILDER=1 VICTORY_ACTIVATE_RAYS=1`, diagnostics build of main 568c5e5d plus this PR and several others (one exe, one switch per run), 10-minute runs, medians after 200 s. Same exe without the switch: 24.3 fps (p10 23.5), preparing 30.6 ms. With the new path (no `VirtualQuery` in fault waits): 25.4 fps (p10 24.6), preparing 29.2 ms, about +1.1 fps, the best of the five switches tried in this batch. No crash.
github manually merged commit 6060042957 into main 2026-11-29 08:20:45 +00:00
Author
Owner

@⁠Bazovsky on GitHub · 2026-11-29 11:00 UTC · original

A measurement from after the merge, in case it helps: on a Ryzen 9 9950X3D + RTX 5090 the new default costs the submitting thread about half a millisecond a frame against VICTORY_FAULT_ASK=1, in one of the frame line's parts.

2560x1440, DLSS Quality, frame generation off, started with victory play; e1f2eb6 with this PR merged in, 190 s runs in turn. A loaded save standing in the first playable scene (about 4,800 draws a frame), seconds 60 to 140 of 3D counted. The frame line's "putting the title's bytes under flights' writes":

runs a frame (median, range of the runs' medians)
this PR's default 20 1.45 ms (1.2 to 1.7)
VICTORY_FAULT_ASK=1 7 0.9 ms (0.8 to 1.0)
builds without this PR 9 0.8 ms (0.7 to 0.9)
  • The default's runs do not overlap those of the other two groups. The frame rate does not separate beyond the spread of the runs (medians 38.3, 37.2 and 38.9 frames a second).
  • On main at 829188e the same direction showed in two runs (1.2 against 0.8 ms), but those ran while the PC was short of memory, so I would not lean on them.
  • I did not look for the cause. In these runs the process was on the V-Cache half (the default at that commit), eight cores for everything, which may be where a spin costs more than the query it saves.

Measured unattended by an AI assistant (Claude Code) on my PC.

**@⁠Bazovsky** on GitHub · 2026-11-29 11:00 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1908#issuecomment-7254821196) A measurement from after the merge, in case it helps: on a Ryzen 9 9950X3D + RTX 5090 the new default costs the submitting thread about half a millisecond a frame against `VICTORY_FAULT_ASK=1`, in one of the frame line's parts. 2560x1440, DLSS Quality, frame generation off, started with `victory play`; `e1f2eb6` with this PR merged in, 190 s runs in turn. A loaded save standing in the first playable scene (about 4,800 draws a frame), seconds 60 to 140 of 3D counted. The frame line's "putting the title's bytes under flights' writes": | | runs | a frame (median, range of the runs' medians) | |---|---|---| | this PR's default | 20 | 1.45 ms (1.2 to 1.7) | | `VICTORY_FAULT_ASK=1` | 7 | 0.9 ms (0.8 to 1.0) | | builds without this PR | 9 | 0.8 ms (0.7 to 0.9) | - The default's runs do not overlap those of the other two groups. The frame rate does not separate beyond the spread of the runs (medians 38.3, 37.2 and 38.9 frames a second). - On main at `829188e` the same direction showed in two runs (1.2 against 0.8 ms), but those ran while the PC was short of memory, so I would not lean on them. - I did not look for the cause. In these runs the process was on the V-Cache half (the default at that commit), eight cores for everything, which may be where a spin costs more than the query it saves. Measured unattended by an AI assistant (Claude Code) on my PC.
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/trustno1-coder--VIctory-NVIDIA!1908
No description provided.