gpu(watch): spin-backoff before yielding in fault-ask open wait #2814

Merged
Nosheboo merged 1 commit from upstream-pr/2814 into main 2026-11-29 22:54:42 +00:00
Nosheboo commented 2026-11-29 17:37:14 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Nosheboo on 2026-11-29T17:37:14Z.


Motivation

On upstream 55d06914, baseline profiling shows the submitter spending 3.4–3.7 ms/frame in write watch. In wait_open_done, the open-wait loop immediately called std::thread::yield_now() on contention and unconditionally evaluated Instant::now() even when fault_asks() diagnostics were off.

Changes

  • crates/victory-gpu/src/watch.rs:
    • Extracts OpenWait, wait_open_done, and testable wait_open_done_with.
    • Performs a bounded 8 x 64 std::hint::spin_loop() fast-spin phase (OPEN_FAST_SPINS = 8) before falling back to std::thread::yield_now() up to OPEN_LONGEST_US = 2_000.
    • Moves Instant::now() reads inside the fault_asks() diagnostics branch so the non-diagnostic hot path avoids extra clock syscalls.
    • Adds wait_open_done_covers_immediate_fast_spin_yield_cleared_and_timeout covering all six wait outcomes.

Verification

  • cargo test -p victory-gpu --lib --locked watch:: -- --test-threads=1 -> 63 passed; 0 failed; 0 ignored
  • cargo clippy -p victory-gpu --no-deps --lib --tests --locked -- -W clippy::undocumented_unsafe_blocks reported 0 warnings in watch.rs
  • git diff --cached --check clean; cargo xtask policy --staged passed (1 files ok)

Council review

Rounds: 3

Delegate Round 1 Round 2 Round 3
Concurrency & Safety Auditor (gpt-6-luna, xhigh) 9/10 9/10 9/10
Performance & Modernization Architect (gpt-6-luna, xhigh) 8/10 8/10 9/10
Upstream PR Hygiene & Test Critic (gpt-6-luna, xhigh) 9/10 8/10 8/10

Created in T3 Code (reviewed by Council: 3× gpt-6-luna on xhigh).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5553310818 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2814). Originally posted by [Nosheboo](https://github.com/Nosheboo) on 2026-11-29T17:37:14Z. --- ## Motivation On upstream `55d06914`, baseline profiling shows the submitter spending `3.4–3.7 ms/frame` in `write watch`. In `wait_open_done`, the open-wait loop immediately called `std::thread::yield_now()` on contention and unconditionally evaluated `Instant::now()` even when `fault_asks()` diagnostics were off. ## Changes - `crates/victory-gpu/src/watch.rs`: - Extracts `OpenWait`, `wait_open_done`, and testable `wait_open_done_with`. - Performs a bounded 8 x 64 `std::hint::spin_loop()` fast-spin phase (`OPEN_FAST_SPINS = 8`) before falling back to `std::thread::yield_now()` up to `OPEN_LONGEST_US = 2_000`. - Moves `Instant::now()` reads inside the `fault_asks()` diagnostics branch so the non-diagnostic hot path avoids extra clock syscalls. - Adds `wait_open_done_covers_immediate_fast_spin_yield_cleared_and_timeout` covering all six wait outcomes. ## Verification - `cargo test -p victory-gpu --lib --locked watch:: -- --test-threads=1` -> `63 passed; 0 failed; 0 ignored` - `cargo clippy -p victory-gpu --no-deps --lib --tests --locked -- -W clippy::undocumented_unsafe_blocks` reported 0 warnings in `watch.rs` - `git diff --cached --check` clean; `cargo xtask policy --staged` passed (`1 files ok`) ## Council review Rounds: 3 | Delegate | Round 1 | Round 2 | Round 3 | | --- | --- | --- | --- | | Concurrency & Safety Auditor (`gpt-6-luna`, `xhigh`) | 9/10 | 9/10 | 9/10 | | Performance & Modernization Architect (`gpt-6-luna`, `xhigh`) | 8/10 | 8/10 | 9/10 | | Upstream PR Hygiene & Test Critic (`gpt-6-luna`, `xhigh`) | 9/10 | 8/10 | 8/10 | Created in T3 Code (reviewed by Council: 3× gpt-6-luna on xhigh).
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!2814
No description provided.