gpu: avoid unrelated range-lock wakeups and linear overlap scans #3292

Merged
spk-c merged 1 commit from upstream-pr/3292 into main 2026-11-30 14:12:01 +00:00
spk-c commented 2026-11-29 21:22:48 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by spk-c on 2026-11-29T21:22:48Z.


What it changes

The watch range lock stores writer ranges sorted and merged, but checks them linearly while holding the state mutex. Reader drops also wake all waiters even when the departing reader is outside the writer's ranges.

Use binary search over the joined intervals and notify waiters only when the departing reader overlaps the pending writer. Writer release still notifies all. Lock ownership and ordering are unchanged.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): Not yet tested in-game; planned on RTX 4090, Series X, with matching graphics settings for both runs.
  • Before: linear overlap checks and unrelated reader-drop notifications (source inspection).
  • After: binary overlap checks and targeted notifications (source inspection). FPS and frametimes not measured.
  • For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A.
  • cargo test passed for the crates it touches: no, not yet run. Added a predicate-equivalence regression test; existing concurrency tests retained.
  • Windows CI: run 46311066023 stopped at Clippy because victory-loader::unwind_copy is unused, outside the changed file. No successful test run is claimed.
  • Planned: cargo test -p victory-gpu rangelock --locked and identical streaming-route A/B, comparing CPU preparation time, p95/p99 and displayed FPS.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #3061 changes the timing-sensitive test in the same file, not the overlap predicate; #2650 changes range-lock initialisation in watch.rs; #2439 isolates a related XMem test. No duplicate found in the searched results.

AI assistance

Prepared with AI assistance; gameplay validation and human review remain pending.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5555260563 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3292). Originally posted by [spk-c](https://github.com/spk-c) on 2026-11-29T21:22:48Z. --- ## What it changes The watch range lock stores writer ranges sorted and merged, but checks them linearly while holding the state mutex. Reader drops also wake all waiters even when the departing reader is outside the writer's ranges. Use binary search over the joined intervals and notify waiters only when the departing reader overlaps the pending writer. Writer release still notifies all. Lock ownership and ordering are unchanged. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): Not yet tested in-game; planned on RTX 4090, Series X, with matching graphics settings for both runs. - Before: linear overlap checks and unrelated reader-drop notifications (source inspection). - After: binary overlap checks and targeted notifications (source inspection). FPS and frametimes not measured. - For shader changes, the wave sizes tested (32 and/or 64 lanes): N/A. - `cargo test` passed for the crates it touches: no, not yet run. Added a predicate-equivalence regression test; existing concurrency tests retained. - Windows CI: [run 46311066023](https://github.com/spk-c/VIctory-NVIDIA/actions/runs/46311066023) stopped at Clippy because `victory-loader::unwind_copy` is unused, outside the changed file. No successful test run is claimed. - Planned: `cargo test -p victory-gpu rangelock --locked` and identical streaming-route A/B, comparing CPU preparation time, p95/p99 and displayed FPS. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #3061 changes the timing-sensitive test in the same file, not the overlap predicate; #2650 changes range-lock initialisation in watch.rs; #2439 isolates a related XMem test. No duplicate found in the searched results. ## AI assistance Prepared with AI assistance; gameplay validation and human review remain pending.
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!3292
No description provided.