GPU: cut write-watch scans between sparse buffer ranges #4571

Closed
yumaste wants to merge 14 commits from upstream-pr/4571 into main
yumaste commented 2026-11-30 22:55:08 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by yumaste on 2026-11-30T22:55:08Z.


## Change

The default kept write-watch query joined ranges separated by up to 8 MiB. On a submission with sparse buffer reads, Windows then walked many pages in between that the submission did not use. Limit those gaps to 512 KiB and reuse the existing ahead_runs planner. VICTORY_ASK_ONCE_GAP_KB=8192 restores the previous limit for an A/B. The flush-local VICTORY_AHEAD_GAP_KB setting continues to govern its own path.

Requested ranges are still queried and noted under the same locks. If a later read asks about a gap that was not queried, it still uses the normal write-watch path. A new Windows test checks the dirty page in that gap with both limits.

Performance

A/B on Windows with a Core Ultra 9 275HX and RTX 5080 Laptop GPU. Used the host submission bench from #3820 on base e1251c31 plus this patch. The same optimized executable ran three times per limit in alternating order, with two warm-up and twelve measured frames per scenario. The bench sends 30 submissions and 8,973 refreshes per simulated frame. Each number is the median of the three run means.

Scenario Preparation, 8 MiB Preparation, 512 KiB Time saved
Nothing written 19.07 ms 8.65 ms 10.43 ms
1% of pages written at the primary address 21.53 ms 13.76 ms 7.77 ms
1% of pages written through an alias 21.12 ms 13.19 ms 7.93 ms

The write-watch phase fell from 11.87 to 3.87 ms in the alias scenario. Every run reported zero stale CPU copies and zero GPU differences after the final refresh. The single-buffer control asked about 0.01 ms per frame in both modes. These results are for synthetic submissions. A gameplay run is still needed for an FPS or frame-pacing estimate.

Validation

  • 70 write-watch tests passed. The new regression also passed with VICTORY_ASK_ONCE_GAP_KB=8192.
  • Staged asset policy and git diff --check passed.
  • The full GPU suite reports 1,132 passed and 66 ignored on this patch. Both this run and the baseline report the same two failures (list::thin::tests::bindings_record_no_work and shader_cache::tests::every_switch_of_the_translator_is_in_the_key).

Refs #2415. The benchmark from #3820 was applied in a separate worktree for measurement. This PR changes only watch.rs.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5575269945 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4571). Originally posted by [yumaste](https://github.com/yumaste) on 2026-11-30T22:55:08Z. --- ## Change The default kept write-watch query joined ranges separated by up to 8 MiB. On a submission with sparse buffer reads, Windows then walked many pages in between that the submission did not use. Limit those gaps to 512 KiB and reuse the existing ahead_runs planner. VICTORY_ASK_ONCE_GAP_KB=8192 restores the previous limit for an A/B. The flush-local VICTORY_AHEAD_GAP_KB setting continues to govern its own path. Requested ranges are still queried and noted under the same locks. If a later read asks about a gap that was not queried, it still uses the normal write-watch path. A new Windows test checks the dirty page in that gap with both limits. ## Performance A/B on Windows with a Core Ultra 9 275HX and RTX 5080 Laptop GPU. Used the host submission bench from #3820 on base e1251c31 plus this patch. The same optimized executable ran three times per limit in alternating order, with two warm-up and twelve measured frames per scenario. The bench sends 30 submissions and 8,973 refreshes per simulated frame. Each number is the median of the three run means. | Scenario | Preparation, 8 MiB | Preparation, 512 KiB | Time saved | | --- | ---: | ---: | ---: | | Nothing written | 19.07 ms | 8.65 ms | 10.43 ms | | 1% of pages written at the primary address | 21.53 ms | 13.76 ms | 7.77 ms | | 1% of pages written through an alias | 21.12 ms | 13.19 ms | 7.93 ms | The write-watch phase fell from 11.87 to 3.87 ms in the alias scenario. Every run reported zero stale CPU copies and zero GPU differences after the final refresh. The single-buffer control asked about 0.01 ms per frame in both modes. These results are for synthetic submissions. A gameplay run is still needed for an FPS or frame-pacing estimate. ## Validation - 70 write-watch tests passed. The new regression also passed with VICTORY_ASK_ONCE_GAP_KB=8192. - Staged asset policy and git diff --check passed. - The full GPU suite reports 1,132 passed and 66 ignored on this patch. Both this run and the baseline report the same two failures (list::thin::tests::bindings_record_no_work and shader_cache::tests::every_switch_of_the_translator_is_in_the_key). Refs #2415. The benchmark from #3820 was applied in a separate worktree for measurement. This PR changes only watch.rs.
trustno1-coder commented 2026-12-01 18:37:39 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-12-01T18:37:39Z.


Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7321240419 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4571#issuecomment-7321240419). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-12-01T18:37:39Z. --- Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

Pull request closed

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