perf(card_steps): overlap D3D12 command recording onto background thread #404

Closed
github-bot wants to merge 0 commits from github-bot/gh-404 into main AGit
Owner

@⁠leixner on GitHub · 2026-12-01 22:34 UTC · original
leixner:perf/async-card-steps-record → main · +153 −28 · 2 files · 72 commits · closed without merging

Summary

Cuts submitting-thread card_steps overhead by ~30% per 1k fills (-37% p50, -33% p90, -35% p99) by offloading card_steps D3D12 command recording (CopyBufferRegion, ResourceBarrier, and Close) onto a dedicated background helper thread (victory-card-rec) while the submitting thread runs write-watch, refreshes, and list steps (~25–35 ms of overlap).

Problem

In Host::submit, card_steps::take_steps runs at the start of the submission and synchronously records ~2,000–2,700 CopyBufferRegion calls, resource barriers, and list.Close() into own.list.list on the submitting thread — even though own.list.list is not submitted to the GPU until ~25–35 ms later (all intermediate stages only read own.list.deferred()).

Changes (crates/victory-gpu/src/host/card_steps.rs, crates/victory-gpu/src/host.rs)

  • Added CardRecordJob and record_async (using a single persistent victory-card-rec helper thread, mirroring watch::ask_first) that runs record(...) across all levels and list.Close() in the background (non-diagnostics builds; diagnostics builds keep the synchronous own.list.close() path for timestamp/op queries).
  • Added Taken::wait_recorded(&self) (also called in Taken::landed and Drop for Taken so own.list is never submitted, recycled, or dropped while recording is in flight).
  • Call own.wait_recorded() in Host::submit right before Handoff / ExecuteCommandLists (~25–35 ms after dispatch, when recording has already completed).

Verification

  • cargo test -p victory-gpu --lib card_steps — 14 passed, 0 failed (zero warnings).
  • cargo test -p victory-gpu --lib host::refresh_tests — 5 passed, 0 failed.
  • cargo xtask policy — 293 files ok.
  • Gameplay A/B on Ryzen 7 5700X + RTX 3070 8 GB (Xbox Series X @ 3440×1440 UWQHD, VICTORY_WIDE_THREADS=8, 179 gameplay windows, 0 errors):
Metric (p50 / mean / p90 / p99) Baseline This PR Delta
card_steps ms 5.20 / 4.44 / 6.90 / 7.90 ms 3.30 / 2.97 / 4.60 / 5.10 ms -37% p50 / -33% p90 / -35% p99
Normalized card_steps (ms / 1k fills) 0.641 ms 0.452 ms -29.5%
Submitting thread ms 41.50 / 41.57 / 54.50 / 74.30 ms 37.00 / 37.16 / 51.70 / 63.80 ms -4.50 ms (-11%) p50 / -10.5 ms (-14%) p99
**@⁠leixner** on GitHub · 2026-12-01 22:34 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/404) `leixner:perf/async-card-steps-record` → `main` · +153 −28 · 2 files · 72 commits · closed without merging ## Summary Cuts submitting-thread `card_steps` overhead by **~30% per 1k fills** (**-37% p50**, **-33% p90**, **-35% p99**) by offloading `card_steps` D3D12 command recording (`CopyBufferRegion`, `ResourceBarrier`, and `Close`) onto a dedicated background helper thread (`victory-card-rec`) while the submitting thread runs write-watch, refreshes, and list steps (~25–35 ms of overlap). ### Problem In `Host::submit`, `card_steps::take_steps` runs at the start of the submission and synchronously records ~2,000–2,700 `CopyBufferRegion` calls, resource barriers, and `list.Close()` into `own.list.list` on the submitting thread — even though `own.list.list` is not submitted to the GPU until ~25–35 ms later (all intermediate stages only read `own.list.deferred()`). ### Changes (`crates/victory-gpu/src/host/card_steps.rs`, `crates/victory-gpu/src/host.rs`) - Added `CardRecordJob` and `record_async` (using a single persistent `victory-card-rec` helper thread, mirroring `watch::ask_first`) that runs `record(...)` across all levels and `list.Close()` in the background (non-diagnostics builds; diagnostics builds keep the synchronous `own.list.close()` path for timestamp/op queries). - Added `Taken::wait_recorded(&self)` (also called in `Taken::landed` and `Drop for Taken` so `own.list` is never submitted, recycled, or dropped while recording is in flight). - Call `own.wait_recorded()` in `Host::submit` right before `Handoff` / `ExecuteCommandLists` (~25–35 ms after dispatch, when recording has already completed). ## Verification - `cargo test -p victory-gpu --lib card_steps` — **14 passed, 0 failed** (zero warnings). - `cargo test -p victory-gpu --lib host::refresh_tests` — **5 passed, 0 failed**. - `cargo xtask policy` — **293 files ok**. - Gameplay A/B on Ryzen 7 5700X + RTX 3070 8 GB (Xbox Series X @ 3440×1440 UWQHD, `VICTORY_WIDE_THREADS=8`, 179 gameplay windows, 0 errors): | Metric (`p50 / mean / p90 / p99`) | Baseline | This PR | Delta | | --- | --- | --- | --- | | `card_steps` ms | 5.20 / 4.44 / 6.90 / 7.90 ms | **3.30 / 2.97 / 4.60 / 5.10 ms** | **-37% p50 / -33% p90 / -35% p99** | | Normalized `card_steps` (ms / 1k fills) | 0.641 ms | **0.452 ms** | **-29.5%** | | Submitting thread ms | 41.50 / 41.57 / 54.50 / 74.30 ms | **37.00 / 37.16 / 51.70 / 63.80 ms** | **-4.50 ms (-11%) p50 / -10.5 ms (-14%) p99** |
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 22:38:08 +00:00
github-bot closed this pull request 2026-12-02 07:54:20 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.