Refresh registered buffer views through runtime guards #4554

Closed
github-bot wants to merge 7 commits from github-bot/gh-4553 into main AGit
Owner

@⁠vilaris on GitHub · 2026-11-30 22:19 UTC · original
vilaris:perf/registered-guard-refresh → main · +2695 −302 · 26 files · 7 commits · closed without merging

Summary

Use the runtime's existing guards to refresh shadow buffers backed by fully registered physical-memory views, including soft views that Windows still reports as reserved private memory. The path is opt-in with VICTORY_REFRESH_REGISTERED_GUARDS=1.

  • Require full view coverage and a stable, even mapping generation before using the registry to identify a guarded range.
  • Keep clean blocks protected, including blocks written through STORE_BESIDE. Reprotect opened blocks in batches of up to 64 and release the guard lock between batches.
  • Retry selection once after a bounded wait for an in-flight remap. Keep the conservative full-span update if the mapping stays unstable.
  • Use the journal and copy stamps to skip clean spans before taking the shadow copy lock. The guard-first pass publishes writes without building a journal result it would discard.
  • Report registered guards separately and include protection, publication and registry coverage in the first unknown-span sample.

Gameplay A/B

RTX 4070, Series S profile, DLSS Quality at 1080p to 1440p, diagnostics build, the same copied save and roughly 29 seconds per arm. Both arms used REFRESH_WHY=0, STORE_BESIDE=1, SOFT_VIEWS=copies and frame generation off.

Registered guards Frames Sample time Mean FPS Frames over 100 ms
Off 437 28.79 s 15.18 15
On 463 28.84 s 16.06 11

The observed gain was 0.88 FPS (+5.8%). The benchmark's draw-count detector missed gameplay, so the sample was extracted from the frame-time logs. The driver continued sending Enter during both windows. This is one A/B pair on a diagnostics build.

Refresh diagnostics

The earlier 16-block build recorded a median 3.98% odd mapping generation, 364 remap spans and 677 MB of remap traffic per frame, plus 249 MB/frame under unknown pages. The final 64-block build recorded 1.29 ms of query time and 2.55 ms of total decision time at a median 1.04 GiB/frame across 29 comparable-volume reports with WHY=1. The roughly 1 ms target remains open. The diagnostic timings are separate from the FPS comparison above.

Validation and integration

  • 45 watch tests passed with the opt-in path, including coverage for clean and reopened blocks, odd generations and selection retry. The focused regression also passed with STORE_BESIDE=1.
  • The diagnostics and release binaries built successfully on the measured branch.
  • This draft carries the measured prerequisite commits for refresh batching and instrumentation, physical-memory write tracking and the DirectStorage soft-view path. The current upstream main lacks those commits and conflicts with the stack. The rebased result still needs to be built and remeasured.
**@⁠vilaris** on GitHub · 2026-11-30 22:19 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4553) `vilaris:perf/registered-guard-refresh` → `main` · +2695 −302 · 26 files · 7 commits · closed without merging ## Summary Use the runtime's existing guards to refresh shadow buffers backed by fully registered physical-memory views, including soft views that Windows still reports as reserved private memory. The path is opt-in with `VICTORY_REFRESH_REGISTERED_GUARDS=1`. - Require full view coverage and a stable, even mapping generation before using the registry to identify a guarded range. - Keep clean blocks protected, including blocks written through `STORE_BESIDE`. Reprotect opened blocks in batches of up to 64 and release the guard lock between batches. - Retry selection once after a bounded wait for an in-flight remap. Keep the conservative full-span update if the mapping stays unstable. - Use the journal and copy stamps to skip clean spans before taking the shadow copy lock. The guard-first pass publishes writes without building a journal result it would discard. - Report `registered guards` separately and include protection, publication and registry coverage in the first unknown-span sample. ## Gameplay A/B RTX 4070, Series S profile, DLSS Quality at 1080p to 1440p, diagnostics build, the same copied save and roughly 29 seconds per arm. Both arms used `REFRESH_WHY=0`, `STORE_BESIDE=1`, `SOFT_VIEWS=copies` and frame generation off. | Registered guards | Frames | Sample time | Mean FPS | Frames over 100 ms | | --- | ---: | ---: | ---: | ---: | | Off | 437 | 28.79 s | 15.18 | 15 | | On | 463 | 28.84 s | 16.06 | 11 | The observed gain was **0.88 FPS (+5.8%)**. The benchmark's draw-count detector missed gameplay, so the sample was extracted from the frame-time logs. The driver continued sending Enter during both windows. This is one A/B pair on a diagnostics build. ## Refresh diagnostics The earlier 16-block build recorded a median 3.98% odd mapping generation, 364 remap spans and 677 MB of remap traffic per frame, plus 249 MB/frame under unknown pages. The final 64-block build recorded 1.29 ms of query time and 2.55 ms of total decision time at a median 1.04 GiB/frame across 29 comparable-volume reports with `WHY=1`. The roughly 1 ms target remains open. The diagnostic timings are separate from the FPS comparison above. ## Validation and integration - 45 watch tests passed with the opt-in path, including coverage for clean and reopened blocks, odd generations and selection retry. The focused regression also passed with `STORE_BESIDE=1`. - The diagnostics and release binaries built successfully on the measured branch. - This draft carries the measured prerequisite commits for refresh batching and instrumentation, physical-memory write tracking and the DirectStorage soft-view path. The current upstream `main` lacks those commits and conflicts with the stack. The rebased result still needs to be built and remeasured.
Intersect buffer refreshes with write-watch page epochs at the existing
read boundaries. Skip proven-clean references and narrow guarded ranges
when the journal and the copy stamps cover them. Keep conservative
updates for unproven alias coverage or in-flight writes, and invalidate
early refresh decisions when title memory is remapped.

Reuse compacted GPU-write ranges across relay retirements and copy dirty
parts of single-page buffers directly, publishing copy stamps only after
the bytes are in place.

Keep VICTORY_SUBMIT_DIRTY_PAGES=0 as the comparison path. Report discarded
references, selection time, update time and copied KiB in the submission
log, and document how to compare runs with matching settings.

In sessions 13072 and 17296, both at 2x frame generation, median refresh
fell from 25.2 to 20.4 ms and median Preparing from 71.1 to 60.1 ms in
windows with 9,000 to 11,000 candidates. Frames over 100 ms fell from
75/342 to 30/457 in the sampled 30-window tails. The newer session copied
about 12% fewer bytes, so the comparison measures the observed sessions
and does not isolate the patch's effect.

Validation: release build, 13 focused refresh tests, staged asset policy.
- VICTORY_GUARD_FIRST (on): guard refresh spans that only the guards can
  answer once per flush, on the flushing thread, instead of once per span
  under the guards' one lock (same change as PR #4247).
- VICTORY_WATCH_BRANCHES=1 (off): per-branch counter for watch::writes and
  guard's phases, a line a second.
- VICTORY_REFRESH_WHY=1 (off): refresh reasons, phases and per-shadow
  coverage (refresh_stats.rs).
- docs/stuttering: P0 refresh analysis, H4 results and the in-place
  feasibility check on the RTX 4070.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Record completed alias writes in the watch journal and reuse stable descriptor snapshots.
- Coalesce compatible wide fill operations and sample the first unknown refresh span.
- Ignore worktree build output.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 22:24:39 +00:00
Author
Owner

@⁠IRennie74 on GitHub · 2026-11-30 22:39 UTC · original

Two things before this can be measured against main.

  1. Default behaviour changes beyond the opt-in. The description says the path is opt-in (VICTORY_REFRESH_REGISTERED_GUARDS=1), but the stack also adds seven toggled! switches, so they are on unless set to 0: VICTORY_GUARD_FIRST (watch.rs:1073), VICTORY_REFRESH_TRIM_EDGES (watch.rs:1713), VICTORY_DEFER_LIST_RECYCLE (host.rs:5554), VICTORY_SUBMIT_DIRTY_PAGES (host.rs:13010), VICTORY_WIDE_PAGE_SELECTION (host.rs:13036), VICTORY_BATCH_BUFFER_REFRESH (host.rs:13132) and VICTORY_REFRESH_PENDING_RANGES (shadow.rs:6280). The A/B toggles only the registered-guards switch, with all seven on in both arms. So nothing yet shows how the stack as a whole compares with main.
  2. It conflicts with main and carries six prerequisite commits, plus Portuguese notes under docs/stuttering/ and a .gitignore line. Splitting it into the prerequisite PRs, each with its own A/B, would make it reviewable. It would also let others take the part that matters to them.

The part I would most like to see on its own is the guard batching: reprotecting in batches of 64 and releasing the guards' lock between batches, and keeping clean blocks protected. On a Ryzen 5 5600X + RTX 3060 (Series S, DLSS Performance), the write guards cost about 330 faults a frame (22 ms) on the title's threads, 10-13 ms waiting for the guards' lock, and about 19 ms of protection changes. In our runs, resting hot blocks unguarded (VICTORY_GUARD_HOT) only moved that cost onto the submitting thread. Fewer re-arms is what would help there, which is what this aims at. I can run a split-out version of that piece on that PC.

The measured arm also used VICTORY_STORE_BESIDE=1, which #4492 proposes turning on by default. If both land, the defaults this was measured under change with it.

**@⁠IRennie74** on GitHub · 2026-11-30 22:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4553#issuecomment-7294132299) Two things before this can be measured against main. 1. **Default behaviour changes beyond the opt-in.** The description says the path is opt-in (`VICTORY_REFRESH_REGISTERED_GUARDS=1`), but the stack also adds seven `toggled!` switches, so they are on unless set to `0`: `VICTORY_GUARD_FIRST` (`watch.rs:1073`), `VICTORY_REFRESH_TRIM_EDGES` (`watch.rs:1713`), `VICTORY_DEFER_LIST_RECYCLE` (`host.rs:5554`), `VICTORY_SUBMIT_DIRTY_PAGES` (`host.rs:13010`), `VICTORY_WIDE_PAGE_SELECTION` (`host.rs:13036`), `VICTORY_BATCH_BUFFER_REFRESH` (`host.rs:13132`) and `VICTORY_REFRESH_PENDING_RANGES` (`shadow.rs:6280`). The A/B toggles only the registered-guards switch, with all seven on in both arms. So nothing yet shows how the stack as a whole compares with main. 2. **It conflicts with main and carries six prerequisite commits**, plus Portuguese notes under `docs/stuttering/` and a `.gitignore` line. Splitting it into the prerequisite PRs, each with its own A/B, would make it reviewable. It would also let others take the part that matters to them. The part I would most like to see on its own is the guard batching: reprotecting in batches of 64 and releasing the guards' lock between batches, and keeping clean blocks protected. On a Ryzen 5 5600X + RTX 3060 (Series S, DLSS Performance), the write guards cost about 330 faults a frame (22 ms) on the title's threads, 10-13 ms waiting for the guards' lock, and about 19 ms of protection changes. In our runs, resting hot blocks unguarded (`VICTORY_GUARD_HOT`) only moved that cost onto the submitting thread. Fewer re-arms is what would help there, which is what this aims at. I can run a split-out version of that piece on that PC. The measured arm also used `VICTORY_STORE_BESIDE=1`, which #4492 proposes turning on by default. If both land, the defaults this was measured under change with it.
github-bot closed this pull request 2026-11-30 23:30:37 +00:00

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/trustno1-coder--VIctory-NVIDIA!4554
No description provided.