gpu: keep the page guard lock when no mapping query is needed (opt-in) #653

Merged
Blitzball996 merged 1 commit from upstream-pr/653 into main 2026-11-29 08:16:59 +00:00
Blitzball996 commented 2026-11-28 02:46:23 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Blitzball996 on 2026-11-28T02:46:23Z.


Change

guard() checks the bitmap of absent blocks while holding GUARDS. When there are no uncertain blocks, it releases and immediately reacquires the mutex before examining dirty blocks. VICTORY_KEEP_GUARD_LOCK=1 keeps the existing guard across that empty interval. Ranges that need a Windows mapping query still release the mutex for the query and revalidate the result after reacquiring it. The switch is opt-in and supports VICTORY_AB in diagnostics builds.

In a 24-second diagnostics capture, 286 of 2,312 samples of the submitting thread were waiting for watch::guards from writes during a buffer refresh. This is a count of sampled stacks across the guard path. It does not isolate time spent on the second acquisition.

Measurements

RTX 4070 SUPER, i7-14700KF, Series S profile, DLSS Performance (960x540 to 1920x1080), frame generation disabled. The two release runs used the same save and launcher settings on a local branch containing upstream a4d05e7. The table uses median base FPS from five-second reporting windows with zero pipelines being compiled, 55 to 155 seconds after entering the world.

Reporting windows Off On
All qualifying windows 17.7 (19 windows) 17.7 (20 windows)
11,000 to 11,999 draws/frame 11.1 (5 windows) 11.8 (5 windows)

In a separate diagnostics run, VICTORY_AB=6,VICTORY_KEEP_GUARD_LOCK alternated the switch every six seconds. Of seven adjacent off/on pairs within 5% in draw count, six had lower mean frame time with the switch. The median paired difference was -1.5 ms. Independent runs can differ in streaming and scene timing. The full release run showed no overall FPS gain.

Verification

cargo test --offline --locked -p victory-gpu watch::tests:: -- --test-threads=1 passed all 35 tests on the PR branch with the switch set to 0 and again with it set to 1.

Related work in #516 changes fault handling and the collection of soft-view ranges in the same guard path.

The branch targets main at 8fc2254. PR #687 addresses the upstream CI failures independently.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5535931324 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/653). Originally posted by [Blitzball996](https://github.com/Blitzball996) on 2026-11-28T02:46:23Z. --- ## Change `guard()` checks the bitmap of absent blocks while holding `GUARDS`. When there are no uncertain blocks, it releases and immediately reacquires the mutex before examining dirty blocks. `VICTORY_KEEP_GUARD_LOCK=1` keeps the existing guard across that empty interval. Ranges that need a Windows mapping query still release the mutex for the query and revalidate the result after reacquiring it. The switch is opt-in and supports `VICTORY_AB` in diagnostics builds. In a 24-second diagnostics capture, 286 of 2,312 samples of the submitting thread were waiting for `watch::guards` from `writes` during a buffer refresh. This is a count of sampled stacks across the guard path. It does not isolate time spent on the second acquisition. ## Measurements RTX 4070 SUPER, i7-14700KF, Series S profile, DLSS Performance (960x540 to 1920x1080), frame generation disabled. The two release runs used the same save and launcher settings on a local branch containing upstream `a4d05e7`. The table uses median base FPS from five-second reporting windows with zero pipelines being compiled, 55 to 155 seconds after entering the world. | Reporting windows | Off | On | | --- | ---: | ---: | | All qualifying windows | 17.7 (19 windows) | 17.7 (20 windows) | | 11,000 to 11,999 draws/frame | 11.1 (5 windows) | 11.8 (5 windows) | In a separate diagnostics run, `VICTORY_AB=6,VICTORY_KEEP_GUARD_LOCK` alternated the switch every six seconds. Of seven adjacent off/on pairs within 5% in draw count, six had lower mean frame time with the switch. The median paired difference was -1.5 ms. Independent runs can differ in streaming and scene timing. The full release run showed no overall FPS gain. ## Verification `cargo test --offline --locked -p victory-gpu watch::tests:: -- --test-threads=1` passed all 35 tests on the PR branch with the switch set to `0` and again with it set to `1`. Related work in #516 changes fault handling and the collection of soft-view ranges in the same guard path. The branch targets `main` at `8fc2254`. [PR #687](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/687) addresses the upstream CI failures independently.
NotADonky43 commented 2026-11-28 23:44:51 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by NotADonky43 on 2026-11-28T23:44:51Z.


Tested #653 adapted onto our d4b5d517-based cumulative, retaining the newer soft-view lookup under GUARDS after reacquisition. Same optimized executable off/on, 37 watch tests passed per side (including alias and late-fault cases). Windows RTX 5070 Ti, Series X, 1440p DLSS Quality, no FG, identical precompiled shaders/native pipeline library and starting state. Both reached settled heavy rendering and closed at milestone.

One opening pair: across 7 off vs 6 on heavy reports with no pipelines compiling, median reported preparation was 47.6 vs 39.7 ms/frame, but the median of their present-interval p95s was 68.5 vs 67.4 ms, and p99s 77.0 vs 77.4 ms. Not scene-matched (median draws/frame 3401 vs 3230; copied 45.3 vs 50.1 MB/frame). No proven tail or FPS improvement; retaining as a separate opt-in experiment. These timings do not directly measure GUARDS lock duration.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7247636392 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/653#issuecomment-7247636392). Originally posted by [NotADonky43](https://github.com/NotADonky43) on 2026-11-28T23:44:51Z. --- Tested #653 adapted onto our d4b5d517-based cumulative, retaining the newer soft-view lookup under GUARDS after reacquisition. Same optimized executable off/on, 37 watch tests passed per side (including alias and late-fault cases). Windows RTX 5070 Ti, Series X, 1440p DLSS Quality, no FG, identical precompiled shaders/native pipeline library and starting state. Both reached settled heavy rendering and closed at milestone. One opening pair: across 7 off vs 6 on heavy reports with no pipelines compiling, median reported preparation was 47.6 vs 39.7 ms/frame, but the median of their present-interval p95s was 68.5 vs 67.4 ms, and p99s 77.0 vs 77.4 ms. Not scene-matched (median draws/frame 3401 vs 3230; copied 45.3 vs 50.1 MB/frame). No proven tail or FPS improvement; retaining as a separate opt-in experiment. These timings do not directly measure GUARDS lock duration.
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
trustno1-coder/VIctory-NVIDIA!653
No description provided.