GPU/watch: batch GetWriteWatch queries by memory reservation #1365

Open
github-bot wants to merge 1 commit from github-bot/gh-1365 into main AGit
Owner

@⁠spk-c on GitHub · 2026-11-26 18:48 UTC · original
spk-c:submit/watch-reservation → main · +473 −5 · 3 files · 1 commits · open

Scope

Opt-in VICTORY_WATCH_RESERVATION=1 with ask-once. Classify requests by Windows allocation, deduplicate/sort, group bounded queries within reservations, journal dirty gap pages, and invalidate cached coverage at commit/remap. Completed external writes publish a fresh epoch and invalidate stale 4 KiB masks. Existing global mapping read permit and ordinary fallback retained; no fork-only remap/UMA dependencies. VICTORY_WATCH_STATS=1 reports call/page/region counts. Related to #1279 and #958, but this targets reservation boundaries of GetWriteWatch calls, not VirtualProtect/guard interval batching.

Validation on upstream 52ac4ec + this patch (Windows 10)

Locked offline workspace all-target/all-feature cargo check and Clippy -D warnings passed; staged asset policy and diff checks passed. reservation_gaps_and_racing_writes and explicitly enabled reservation_parallel_readers_and_completed_storage passed. Both modes of the synthetic 12-case matrix (100/1000/10000 requests, contiguous/fragmented, single/multiple reservations) passed with byte-exact results.

One fresh debug A/B pair for 10,000 fragmented ranges / 100 reservations: GetWriteWatch 1307 -> 100 (plus 100 region queries), 4 KiB pages queried 3,895,136 -> 476,800, asking 15.639 -> 8.814 ms, total 39.197 -> 24.207 ms, identical 5,853,184 copied bytes. Single-reservation fragmented case regressed in this pair (5.983 -> 9.433 ms asking). Timing is a single sample, not a median or gameplay claim. Remains opt-in; upstream CI/review pending.

Reproduce with VICTORY_ASK_ONCE=1, VICTORY_WATCH_STATS=1 and VICTORY_WATCH_RESERVATION=0 or 1 in fresh processes: cargo test -p victory-gpu reservation_matrix -- --ignored --test-threads=1 --nocapture.

AI-assisted adaptation from Kelvaroq 1270c42, patch 0045 and fork 4f29a77; GPL-3.0-or-later. No proprietary assets.

**@⁠spk-c** on GitHub · 2026-11-26 18:48 UTC · [original](https://github.com/fxceless/victory-fork/pull/1365) `spk-c:submit/watch-reservation` → `main` · +473 −5 · 3 files · 1 commits · open ## Scope Opt-in `VICTORY_WATCH_RESERVATION=1` with ask-once. Classify requests by Windows allocation, deduplicate/sort, group bounded queries within reservations, journal dirty gap pages, and invalidate cached coverage at commit/remap. Completed external writes publish a fresh epoch and invalidate stale 4 KiB masks. Existing global mapping read permit and ordinary fallback retained; no fork-only remap/UMA dependencies. `VICTORY_WATCH_STATS=1` reports call/page/region counts. Related to #1279 and #958, but this targets reservation boundaries of GetWriteWatch calls, not VirtualProtect/guard interval batching. ## Validation on upstream 52ac4ec + this patch (Windows 10) Locked offline workspace all-target/all-feature cargo check and Clippy -D warnings passed; staged asset policy and diff checks passed. `reservation_gaps_and_racing_writes` and explicitly enabled `reservation_parallel_readers_and_completed_storage` passed. Both modes of the synthetic 12-case matrix (100/1000/10000 requests, contiguous/fragmented, single/multiple reservations) passed with byte-exact results. One fresh debug A/B pair for 10,000 fragmented ranges / 100 reservations: GetWriteWatch 1307 -> 100 (plus 100 region queries), 4 KiB pages queried 3,895,136 -> 476,800, asking 15.639 -> 8.814 ms, total 39.197 -> 24.207 ms, identical 5,853,184 copied bytes. Single-reservation fragmented case regressed in this pair (5.983 -> 9.433 ms asking). Timing is a single sample, not a median or gameplay claim. Remains opt-in; upstream CI/review pending. Reproduce with `VICTORY_ASK_ONCE=1`, `VICTORY_WATCH_STATS=1` and `VICTORY_WATCH_RESERVATION=0` or `1` in fresh processes: `cargo test -p victory-gpu reservation_matrix -- --ignored --test-threads=1 --nocapture`. AI-assisted adaptation from [Kelvaroq 1270c42, patch 0045](https://github.com/stellarr-studio/kelvaroq/tree/1270c422adaef1e0f369f670138d8d29d8f6f4c3/native/patches) and fork 4f29a77; GPL-3.0-or-later. No proprietary assets.
AI-assisted; adapted from Kelvaroq 1270c42 patch 0045 and fork 4f29a77. Preserve upstream global mapping lock and default path.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:52:21 +00:00
Author
Owner

@⁠Filip722 on GitHub · 2026-11-26 20:35 UTC · original · edited 2026-11-26 20:45 UTC

The exact d230d52 fixture reproduced a Proton compatibility failure here. The dirty-gap regression failed at its first coverage assertion. Wine's allocation query returns valid reservation bounds and leaves RegionType zero, so the batching path classifies the allocation as non-private. Wine revision used by GE-Proton11-14

The follow-up uses VirtualQuery only when the flags are zero, verifies the same allocation base and requires MEM_PRIVATE before grouping. The original dirty-gap regression, the concurrent readers/completed-write test and both 12-case matrices passed on the same Bazzite and GE-Proton11-14 environment. In one 10,000-request fragmented, multi-reservation sample, GetWriteWatch calls fell from 1,299 to 100, plus 200 allocation queries. End-to-end time was 9.53 vs 5.92 ms and both copied 5,853,184 bytes. Windows MSVC Clippy with warnings denied and the staged asset policy passed. Tested follow-up commit

In the paired Series S replay on an RTX 5060 Laptop 8 GB, the same 40% launcher and seed rendered the same stationary doorway with both settings. In the common 54-second window the mode changed median GetWriteWatch calls from 389.8 to 350.3 per frame, pages queried from 386,187 to 352,343, and added 63.1 allocation queries per frame. DXGI throughput was 5.537 vs 5.690 FPS and p95 interval was 206 vs 193 ms. The enabled run's earlier geometry-matched window gave 5.302 FPS. Draw counts and storage activity differed, so the gameplay sample shows fewer write-watch calls and a small timing difference that needs repetition.

Assisted by Codex (GPT-6.2-Sol High).

**@⁠Filip722** on GitHub · 2026-11-26 20:35 UTC · [original](https://github.com/fxceless/victory-fork/pull/1365#issuecomment-7202858616) · edited 2026-11-26 20:45 UTC The exact d230d52 fixture reproduced a Proton compatibility failure here. The dirty-gap regression failed at its first coverage assertion. Wine's allocation query returns valid reservation bounds and leaves RegionType zero, so the batching path classifies the allocation as non-private. [Wine revision used by GE-Proton11-14](https://github.com/ValveSoftware/wine/blob/a47c73f52fd7b2efafc1c560710f3a5099ae51e0/dlls/ntdll/unix/virtual.c#L5687-L5694) The follow-up uses VirtualQuery only when the flags are zero, verifies the same allocation base and requires MEM_PRIVATE before grouping. The original dirty-gap regression, the concurrent readers/completed-write test and both 12-case matrices passed on the same Bazzite and GE-Proton11-14 environment. In one 10,000-request fragmented, multi-reservation sample, GetWriteWatch calls fell from 1,299 to 100, plus 200 allocation queries. End-to-end time was 9.53 vs 5.92 ms and both copied 5,853,184 bytes. Windows MSVC Clippy with warnings denied and the staged asset policy passed. [Tested follow-up commit](https://github.com/Filip722/victory-fork/commit/7225f0f0d369247881e92832114b487453d7353d) In the paired Series S replay on an RTX 5060 Laptop 8 GB, the same 40% launcher and seed rendered the same stationary doorway with both settings. In the common 54-second window the mode changed median GetWriteWatch calls from 389.8 to 350.3 per frame, pages queried from 386,187 to 352,343, and added 63.1 allocation queries per frame. DXGI throughput was 5.537 vs 5.690 FPS and p95 interval was 206 vs 193 ms. The enabled run's earlier geometry-matched window gave 5.302 FPS. Draw counts and storage activity differed, so the gameplay sample shows fewer write-watch calls and a small timing difference that needs repetition. Assisted by Codex (GPT-6.2-Sol High).
Author
Owner

@⁠BitWuehler on GitHub · 2026-11-26 23:07 UTC · original

In-world Linux/Proton corroboration of @⁠Filip722's Wine RegionType == 0 finding above (CachyOS, GE-Proton11-14 / Wine 11.0 Staging, RTX 5080 16 GB, Series X profile, d230d52 merged onto 52ac4ec):

  • Comparing Prologue world runs before (e4245f3 base) and after merging d230d52, copystat's per-frame GetWriteWatch granularity stayed unchanged: 1,748–1,794 watches/frame for 4.31–4.41 GB checked before (~2.45 MB/call) vs. 2,461–2,515 watches/frame for 5.99–6.71 GB checked with d230d52 (~2.55 MB/call).
  • This confirms in live play that Wine's zero RegionType leaves d230d52's reservation batching inactive under GE-Proton11-14 (while falling back safely with 0 page faults across 4 world runs), so the VirtualQuery-gated follow-up is needed for Wine/Proton to take the batched path.

(AI-assisted testing, log analysis, and summary.)

**@⁠BitWuehler** on GitHub · 2026-11-26 23:07 UTC · [original](https://github.com/fxceless/victory-fork/pull/1365#issuecomment-7205281420) In-world Linux/Proton corroboration of @⁠Filip722's Wine `RegionType == 0` finding above (CachyOS, GE-Proton11-14 / Wine 11.0 Staging, RTX 5080 16 GB, Series X profile, `d230d52` merged onto `52ac4ec`): - Comparing Prologue world runs before (`e4245f3` base) and after merging `d230d52`, `copystat`'s per-frame `GetWriteWatch` granularity stayed unchanged: **1,748–1,794 watches/frame** for `4.31–4.41 GB` checked before (~2.45 MB/call) vs. **2,461–2,515 watches/frame** for `5.99–6.71 GB` checked with `d230d52` (~2.55 MB/call). - This confirms in live play that Wine's zero `RegionType` leaves `d230d52`'s reservation batching inactive under GE-Proton11-14 (while falling back safely with `0 page faults` across 4 world runs), so the `VirtualQuery`-gated follow-up is needed for Wine/Proton to take the batched path. *(AI-assisted testing, log analysis, and summary.)*
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1365/head:github-bot/gh-1365'
git switch 'github-bot/gh-1365'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1365'
git switch 'github-bot/gh-1365'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1365'
git switch 'github-bot/gh-1365'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1365'
git switch 'main'
git merge --squash 'github-bot/gh-1365'
git switch 'main'
git merge --ff-only 'github-bot/gh-1365'
git switch 'main'
git merge 'github-bot/gh-1365'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.