fix(host): isolate unlocked relay_wait telemetry and fix settle_unlocked races under submit-split #3103

Closed
github-bot wants to merge 1 commit from github-bot/gh-3103 into main AGit
Owner

@⁠qlfu on GitHub · 2026-11-29 20:02 UTC · original
qlfu:pr/fix-settle-unlocked-races → main · +216 −32 · 6 files · 1 commits · closed without merging

Summary

Fixes the remaining thread-safety and pacing races in VICTORY_SETTLE_UNLOCKED=1 (particularly when paired with VICTORY_SUBMIT_SPLIT=1):

  • relay_wait_unlocked: unlocked settle() / settle_now() calls wait on the relay without mutating submit-thread-owned telemetry globals (WORKING, CARD_CLOCK_US[2], SUBMISSION_US[1], READ_KIND, BLAMED).
  • WHY_SYNC locking & trailing wait_sent(): synchronizes WHY_SYNC updates and ensures unlocked settles call send::wait_sent() before snapshotting line(), preventing Present / fence waits from observing stale pre-send flight lines when VICTORY_SUBMIT_SPLIT=1 is active.
  • settle_for_sync_fence(): dedicated mid-submit() path for callers that already hold the submit path so fence settles do not deadlock or race.
  • Locked fallback on host.dynamic(...) retries: falls back safely when an unlocked dynamic buffer check retries.

Verification

  • cargo +1.98.1-x86_64-pc-windows-msvc clippy -p victory-gpu --lib --tests --no-deps --locked: 0 new warnings.
  • cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- settle_unlocked --test-threads=1: 2/2 passed (settle_unlocked + relay_wait_unlocked).
  • Live 90s A/B on Series X title (1440p DLSS Balanced, VICTORY_SUBMIT_SPLIT=1, 0 WARNs / 0 ERRORs):
    • Native (SU=0 vs SU=1): Submit: all 33.60 -> 29.35 ms (-4.25 ms), FPS 20.85/21.95 -> 21.30/22.82 (max 42.2), GPU busy 96.0% -> 97.0%, GPU idle 1.9 -> 1.5 ms.
    • FG 2x (SU=0 vs SU=1): ahead_lock 0.90 -> 0.50 ms, present_wait 4.7 -> 3.4 ms, FPS 21.20/22.77 -> 21.90/23.56 (p10 16.2 -> 19.0), 0 WARNs / 0 ERRORs.
**@⁠qlfu** on GitHub · 2026-11-29 20:02 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3103) `qlfu:pr/fix-settle-unlocked-races` → `main` · +216 −32 · 6 files · 1 commits · closed without merging ## Summary Fixes the remaining thread-safety and pacing races in `VICTORY_SETTLE_UNLOCKED=1` (particularly when paired with `VICTORY_SUBMIT_SPLIT=1`): - **`relay_wait_unlocked`**: unlocked `settle()` / `settle_now()` calls wait on the relay without mutating submit-thread-owned telemetry globals (`WORKING`, `CARD_CLOCK_US[2]`, `SUBMISSION_US[1]`, `READ_KIND`, `BLAMED`). - **`WHY_SYNC` locking & trailing `wait_sent()`**: synchronizes `WHY_SYNC` updates and ensures unlocked settles call `send::wait_sent()` before snapshotting `line()`, preventing `Present` / fence waits from observing stale pre-send flight lines when `VICTORY_SUBMIT_SPLIT=1` is active. - **`settle_for_sync_fence()`**: dedicated mid-`submit()` path for callers that already hold the submit path so fence settles do not deadlock or race. - **Locked fallback on `host.dynamic(...)` retries**: falls back safely when an unlocked dynamic buffer check retries. ## Verification - `cargo +1.98.1-x86_64-pc-windows-msvc clippy -p victory-gpu --lib --tests --no-deps --locked`: 0 new warnings. - `cargo +1.98.1-x86_64-pc-windows-msvc test -p victory-gpu --lib --locked -- settle_unlocked --test-threads=1`: `2/2` passed (`settle_unlocked` + `relay_wait_unlocked`). - Live 90s A/B on Series X title (1440p DLSS Balanced, `VICTORY_SUBMIT_SPLIT=1`, `0 WARNs / 0 ERRORs`): - Native (`SU=0` vs `SU=1`): `Submit: all` `33.60 -> 29.35 ms` (`-4.25 ms`), FPS `20.85/21.95 -> 21.30/22.82` (max `42.2`), `GPU busy 96.0% -> 97.0%`, `GPU idle 1.9 -> 1.5 ms`. - FG 2x (`SU=0` vs `SU=1`): `ahead_lock 0.90 -> 0.50 ms`, `present_wait 4.7 -> 3.4 ms`, FPS `21.20/22.77 -> 21.90/23.56` (`p10 16.2 -> 19.0`), `0 WARNs / 0 ERRORs`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 20:06:44 +00:00
Author
Owner

@⁠ghptc on GitHub · 2026-11-30 03:58 UTC · original

Thanks, @⁠qlfu. The unlocked wait path in this PR already covers a case we reproduced through land_before_remap. It can run concurrently with submission even when VICTORY_SETTLE_UNLOCKED is off. If submitter A is working when remap thread B enters relay_wait, B can clear the shared work marker and then restore its saved true after A has finished. This undercounts A's work during the wait and attributes work after A has stopped. With the phase observer in #3649, the restore can also make B the recorded owner.

The synthetic regression starts an observed empty interval and A's work at tick 10, enters B's wait at 20, ends A's work at 35 and returns from B's wait at 40. At the tick-50 report there are 25 ticks of submit work and 15 outside submit work, with the work clock idle. The paired relay test covers pause and restore when the caller does hold the submission lock.

The focused follow-up cross-compiled in MSVC release mode. Both relay tests and the submit sub-bin test passed under Proton without a GPU. The follow-up changes work-clock ownership and gap attribution. The existing stood accounting, other wait counters, landing predicate, ordering and fences remain as they were. The tests cover attribution and provide no FPS estimate.

**@⁠ghptc** on GitHub · 2026-11-30 03:58 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3103#issuecomment-7268351813) Thanks, @⁠qlfu. The unlocked wait path in this PR already covers a case we reproduced through `land_before_remap`. It can run concurrently with submission even when `VICTORY_SETTLE_UNLOCKED` is off. If submitter A is working when remap thread B enters `relay_wait`, B can clear the shared work marker and then restore its saved `true` after A has finished. This undercounts A's work during the wait and attributes work after A has stopped. With the phase observer in #3649, the restore can also make B the recorded owner. The synthetic regression starts an observed empty interval and A's work at tick 10, enters B's wait at 20, ends A's work at 35 and returns from B's wait at 40. At the tick-50 report there are 25 ticks of submit work and 15 outside submit work, with the work clock idle. The paired relay test covers pause and restore when the caller does hold the submission lock. The [focused follow-up](https://github.com/ghptc/VIctory-NVIDIA/commit/a67df5c9f7f4dace8acd3d2b24722db62b77b869) cross-compiled in MSVC release mode. Both relay tests and the submit sub-bin test passed under Proton without a GPU. The follow-up changes work-clock ownership and gap attribution. The existing `stood` accounting, other wait counters, landing predicate, ordering and fences remain as they were. The tests cover attribution and provide no FPS estimate.
github-bot closed this pull request 2026-12-01 18:59:06 +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!3103
No description provided.