[pr-performance] Opt-in DARNER_LATE_FENCE=1 to avoid CPU stalls on in-flight cross-queue fence waits #93

Open
hingeowl wants to merge 1 commit from hingeowl/Darner:vercetti/late-fence into main
First-time contributor

Summary

Adds opt-in DARNER_LATE_FENCE=1 (off by default) to avoid CPU stalls on in-flight cross-queue fence waits when running on a single FIFO host queue.

When a waiting queue encounters Ask::Wait(fence, value) or Job::Wait(fence, value) whose signal is already queued in-flight on the host relay (Late::Signal), host::late_fence_met() allows the waiting queue to proceed behind the in-flight signal instead of stalling the sender thread for the GPU to drain. Guarded off automatically when two_queues::on() is active.

Provenance

  • Ported from https://github.com/lobomfz/VIctory-xmem commit 9d72949c520646e44a1cdb1f451fd1b6f2de07f9 (GPL-3.0-or-later), adapted to Darner's FenceRef and guarded against two_queues::on().
  • Rebased cleanly onto main (b3a615f).

Validation

  • Unit tests: cargo test --locked -p darner-gpu --lib queue::behind passed.
  • 2-round 60 s interleaved spinning-camera A/B (RTX 4090 / Ryzen 9 7950X3D, Series X, 1440p, RT off, DARNER_RELAY=2, canonical play.rs settings, DARNER_LATE_FENCE=0 vs 1, same binary):
Metric DARNER_LATE_FENCE=0 (R1 / R2) DARNER_LATE_FENCE=1 (R1 / R2) Summary Delta
Draws/frame 7,982 / 7,917 7,556 / 7,841 1.77% drift
FPS (median) 20.5 / 21.9 (21.9) 20.9 / 22.2 (22.2) +0.3 FPS
FrameMedMs 49.0 / 46.2 ms (49.0) 47.1 / 46.4 ms (47.1) -1.9 ms
FrameP95Ms 63.1 / 57.7 ms (63.1) 60.1 / 58.9 ms (60.1) -3.0 ms
SubmitMs 34.1 / 31.5 ms (34.1) 32.2 / 32.4 ms (32.4) -1.7 ms
ListsMs 18.4 ms 17.3 ms -1.1 ms
GPU Busy / VRAM 65% / 21,799 MB 64% / 21,891 MB Parity
  • Verdict: IMPROVED (-1.9 ms median frame time, -3.0 ms P95, -1.7 ms submit, visually verified spotless with nonBlack=99.99%, magenta=0%).
  • (Reference baseline on unmodified main b3a615f: 19.4 FPS, 49.6 ms med, 65.0 ms P95, 35.1 ms submit, 7,946 draws.)
## Summary Adds opt-in `DARNER_LATE_FENCE=1` (off by default) to avoid CPU stalls on in-flight cross-queue fence waits when running on a single FIFO host queue. When a waiting queue encounters `Ask::Wait(fence, value)` or `Job::Wait(fence, value)` whose signal is already queued in-flight on the host relay (`Late::Signal`), `host::late_fence_met()` allows the waiting queue to proceed behind the in-flight signal instead of stalling the sender thread for the GPU to drain. Guarded off automatically when `two_queues::on()` is active. ## Provenance - Ported from `https://github.com/lobomfz/VIctory-xmem` commit `9d72949c520646e44a1cdb1f451fd1b6f2de07f9` (GPL-3.0-or-later), adapted to Darner's `FenceRef` and guarded against `two_queues::on()`. - Rebased cleanly onto `main` (`b3a615f`). ## Validation - **Unit tests:** `cargo test --locked -p darner-gpu --lib queue::behind` passed. - **2-round 60 s interleaved spinning-camera A/B** (RTX 4090 / Ryzen 9 7950X3D, Series X, 1440p, RT off, `DARNER_RELAY=2`, canonical `play.rs` settings, `DARNER_LATE_FENCE=0` vs `1`, same binary): | Metric | `DARNER_LATE_FENCE=0` (R1 / R2) | `DARNER_LATE_FENCE=1` (R1 / R2) | Summary Delta | |---|---:|---:|---:| | **Draws/frame** | `7,982` / `7,917` | `7,556` / `7,841` | `1.77%` drift | | **FPS (median)** | `20.5` / `21.9` (`21.9`) | `20.9` / `22.2` (`22.2`) | **`+0.3 FPS`** | | **FrameMedMs** | `49.0` / `46.2 ms` (`49.0`) | `47.1` / `46.4 ms` (`47.1`) | **`-1.9 ms`** | | **FrameP95Ms** | `63.1` / `57.7 ms` (`63.1`) | `60.1` / `58.9 ms` (`60.1`) | **`-3.0 ms`** | | **SubmitMs** | `34.1` / `31.5 ms` (`34.1`) | `32.2` / `32.4 ms` (`32.4`) | **`-1.7 ms`** | | **ListsMs** | `18.4 ms` | `17.3 ms` | **`-1.1 ms`** | | **GPU Busy / VRAM** | `65%` / `21,799 MB` | `64%` / `21,891 MB` | Parity | - **Verdict:** **IMPROVED** (`-1.9 ms` median frame time, `-3.0 ms` P95, `-1.7 ms` submit, visually verified spotless with `nonBlack=99.99%`, `magenta=0%`). - *(Reference baseline on unmodified `main` `b3a615f`: `19.4 FPS`, `49.6 ms` med, `65.0 ms` P95, `35.1 ms` submit, `7,946` draws.)*
Ported from VIctory-xmem 9d72949c, adapted to Darner's FenceRef and guarded against two_queues::on().

Upstream-Repository: https://github.com/lobomfz/VIctory-xmem
Upstream-Commit: 9d72949c520646e44a1cdb1f451fd1b6f2de07f9
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'vercetti/late-fence:hingeowl-vercetti/late-fence'
git switch 'hingeowl-vercetti/late-fence'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'hingeowl-vercetti/late-fence'
git switch 'hingeowl-vercetti/late-fence'
git rebase 'main'
git switch 'main'
git merge --ff-only 'hingeowl-vercetti/late-fence'
git switch 'hingeowl-vercetti/late-fence'
git rebase 'main'
git switch 'main'
git merge --no-ff 'hingeowl-vercetti/late-fence'
git switch 'main'
git merge --squash 'hingeowl-vercetti/late-fence'
git switch 'main'
git merge --ff-only 'hingeowl-vercetti/late-fence'
git switch 'main'
git merge 'hingeowl-vercetti/late-fence'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
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
TrustNo1/Darner!93
No description provided.