perf(gpu): coalesce CBV descriptor batches and fuse FillsOnly card_steps #365

Manually merged
github merged 1 commit from gh-pr/365/head into gh-pr/365/base 2026-12-02 19:40:15 +00:00
Owner

@⁠Androtim on GitHub · 2026-12-02 18:20 UTC · original
Androtim:perf/card-steps-fills-only-and-bitset → main · +750 −110 · 3 files · 1 commits · merged 2026-12-02 18:33 UTC

Cuts CPU preparing and card_steps submission latency by coalescing constant-buffer descriptor updates into 64-slot batches and eliminating per-step scan/HashSet overhead (#276).

Changes

  1. 64-slot coalesced CBV staging (crates/victory-gpu/src/descriptor/host.rs, descriptor.rs)
    • Added thread-local 64-slot CPU-only CBV staging (staged_cbv_batch, honoring VICTORY_VIEW_COPY=0) and HostHeap::constant_slots_batch() for non-sampler heaps without raw twins: stages up to 64 unique slot writes (cbv_chunk_len splits on duplicate slot indices), coalesces contiguous runs via coalesce_cbv_ranges(), and issues a single CopyDescriptorsSimple / CopyDescriptors per chunk instead of per-slot calls.
    • Changed descriptor::bucket_constant_ops() bucketing from / 4 to / 64 so worker threads own contiguous descriptor ranges and hit the batch fast path.
  2. Fused FillsOnly card_steps fast path & data structures (crates/victory-gpu/src/host/card_steps.rs)
    • Added Host::scan_and_take() to evaluate blocked_by, copied_read, and FillsOnly candidate collection in a single pass under one HostList::deferred() lock per list, bypassing does_of_for / plan_fast / fill_to() on fill-only submissions and falling back cleanly when Step::Copy, Step::Placed, or Step::Run appears (with fill_tos also captured during does_of_for in the full path).
    • Replaced per-step HashSet<(usize, usize)> in Taken with dense per-list bitsets (TakenBits).
    • Added compact_writers + intern_shadow + holder_compact + first_read on Op to collapse duplicate in-flight ranges, eliminate per-op Arc<Shadow> clones and places.remove lookups, and build refresh spans in a tiny index-addressed Vec.
    • Replaced per-submission HashMap allocations in mapped() with a reusable thread-local MappedPages set.

Verification Gates

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy -> asset policy: 328 files ok
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu card_steps --locked -> 16 passed; 0 failed; 1 ignored
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu descriptor --locked -> 87 passed; 0 failed; 1 ignored
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings -> pass
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warnings -> pass
  • objdump -p on plain --release build -> standard Windows system DLLs only

Paired Plain --release A/B Benchmarks (vs main @ 8ff2a82, Series X parity, DLSS Quality)

  • 1440p 90s matched-scene (ab2-main-8ff2a82-1440p-90s vs ab2-pr-cardsteps-1440p-90s):
    • planning steps done on the card (card_steps): 4.90 ms med / 4.82 ms mean (8.90 ms max) -> 3.00 ms med (-38.8%) / 2.95 ms mean (5.30 ms max) across higher fills (1871.9 -> 1973.8 fills med; 2.62 -> 1.52 ms per 1000 fills)
    • total_sub: 34.15 ms med / 37.85 ms mean -> 31.60 ms med (-2.55 ms) / 31.98 ms mean (-5.87 ms)
    • preparing: 25.25 ms -> 23.70 ms (-1.55 ms); copyback: 9.85 ms -> 9.65 ms
    • FPS: 14.1 fps (70.9 ms) -> 14.2 fps (70.4 ms, max_draws 12246 -> 13573); min FPS: 0.9 -> 5.2 fps
    • mapped(): 1.45 ms/s (538.6 ms total, longest 19.8 ms) -> 0.50 ms/s (383.2 ms, longest 11.1 ms); crashes=0
  • 4K 90s matched-scene (ab2-main-8ff2a82-4k-90s vs ab2-pr-cardsteps-4k-90s):
    • planning steps done on the card (card_steps): 6.70 ms med / 6.45 ms mean -> 4.75 ms med (-1.95 ms) / 5.08 ms mean
    • total_sub: 155.15 ms med / 137.68 ms mean -> 149.40 ms med (-5.75 ms) / 133.21 ms mean
    • preparing: 20.9 ms -> 17.7 ms (-3.2 ms); copyback: 14.4 ms -> 13.95 ms
    • FPS: 6.3 fps (158.5 ms) -> 6.5 fps (154.2 ms, +0.2 fps / -4.3 ms)
    • Peak VRAM: 6345 MB -> 6243 MB (-102 MB); mapped(): 4.18 ms/s -> 1.62 ms/s; crashes=0

--features diagnostics Visual Verification (diag-pr-cardsteps-1440p-90s, 90s 1440p)

  • 6/6 gates PASS: world_windows=20 (max_draws=12486), crashes=0, used_max=5849 MB (over=0 MB, room_false=6.2%), final_waiting=2463, mapped_rate=0.76 ms/s, pngs=24 (lit=19/24, luma=95.09, near_black=0.1%, edge_energy=7.72, magenta=0.0%).
  • Visually inspected frame-2414.png, frame-2422.png, and frame-2428.png: sharp textures, natural lighting, water reflections, and crisp HUD overlays.
**@⁠Androtim** on GitHub · 2026-12-02 18:20 UTC · [original](https://github.com/Androtim/MiniVI/pull/365) `Androtim:perf/card-steps-fills-only-and-bitset` → `main` · +750 −110 · 3 files · 1 commits · merged 2026-12-02 18:33 UTC Cuts CPU `preparing` and `card_steps` submission latency by coalescing constant-buffer descriptor updates into 64-slot batches and eliminating per-step scan/HashSet overhead (`#276`). ### Changes 1. **64-slot coalesced CBV staging (`crates/victory-gpu/src/descriptor/host.rs`, `descriptor.rs`)** - Added thread-local 64-slot CPU-only CBV staging (`staged_cbv_batch`, honoring `VICTORY_VIEW_COPY=0`) and `HostHeap::constant_slots_batch()` for non-sampler heaps without raw twins: stages up to 64 unique slot writes (`cbv_chunk_len` splits on duplicate slot indices), coalesces contiguous runs via `coalesce_cbv_ranges()`, and issues a single `CopyDescriptorsSimple` / `CopyDescriptors` per chunk instead of per-slot calls. - Changed `descriptor::bucket_constant_ops()` bucketing from `/ 4` to `/ 64` so worker threads own contiguous descriptor ranges and hit the batch fast path. 2. **Fused `FillsOnly` `card_steps` fast path & data structures (`crates/victory-gpu/src/host/card_steps.rs`)** - Added `Host::scan_and_take()` to evaluate `blocked_by`, `copied_read`, and `FillsOnly` candidate collection in a single pass under one `HostList::deferred()` lock per list, bypassing `does_of_for` / `plan_fast` / `fill_to()` on fill-only submissions and falling back cleanly when `Step::Copy`, `Step::Placed`, or `Step::Run` appears (with `fill_tos` also captured during `does_of_for` in the full path). - Replaced per-step `HashSet<(usize, usize)>` in `Taken` with dense per-list bitsets (`TakenBits`). - Added `compact_writers` + `intern_shadow` + `holder_compact` + `first_read` on `Op` to collapse duplicate in-flight ranges, eliminate per-op `Arc<Shadow>` clones and `places.remove` lookups, and build refresh spans in a tiny index-addressed `Vec`. - Replaced per-submission `HashMap` allocations in `mapped()` with a reusable thread-local `MappedPages` set. ### Verification Gates - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` -> `asset policy: 328 files ok` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu card_steps --locked` -> `16 passed; 0 failed; 1 ignored` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu descriptor --locked` -> `87 passed; 0 failed; 1 ignored` - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings` -> pass - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warnings` -> pass - `objdump -p` on plain `--release` build -> standard Windows system DLLs only ### Paired Plain `--release` A/B Benchmarks (vs `main` @ `8ff2a82`, `Series X` parity, DLSS Quality) - **1440p 90s matched-scene (`ab2-main-8ff2a82-1440p-90s` vs `ab2-pr-cardsteps-1440p-90s`):** - `planning steps done on the card` (`card_steps`): `4.90 ms` med / `4.82 ms` mean (`8.90 ms` max) -> **`3.00 ms` med (`-38.8%`) / `2.95 ms` mean (`5.30 ms` max)** across higher fills (`1871.9` -> `1973.8` fills med; **`2.62 -> 1.52 ms` per 1000 fills**) - `total_sub`: `34.15 ms` med / `37.85 ms` mean -> **`31.60 ms` med (`-2.55 ms`) / `31.98 ms` mean (`-5.87 ms`)** - `preparing`: `25.25 ms` -> **`23.70 ms` (`-1.55 ms`)**; `copyback`: `9.85 ms` -> **`9.65 ms`** - FPS: `14.1 fps` (`70.9 ms`) -> **`14.2 fps` (`70.4 ms`, `max_draws` `12246` -> `13573`)**; min FPS: **`0.9` -> `5.2 fps`** - `mapped()`: `1.45 ms/s` (`538.6 ms` total, longest `19.8 ms`) -> **`0.50 ms/s` (`383.2 ms`, longest `11.1 ms`)**; `crashes=0` - **4K 90s matched-scene (`ab2-main-8ff2a82-4k-90s` vs `ab2-pr-cardsteps-4k-90s`):** - `planning steps done on the card` (`card_steps`): `6.70 ms` med / `6.45 ms` mean -> **`4.75 ms` med (`-1.95 ms`) / `5.08 ms` mean** - `total_sub`: `155.15 ms` med / `137.68 ms` mean -> **`149.40 ms` med (`-5.75 ms`) / `133.21 ms` mean** - `preparing`: `20.9 ms` -> **`17.7 ms` (`-3.2 ms`)**; `copyback`: `14.4 ms` -> **`13.95 ms`** - FPS: `6.3 fps` (`158.5 ms`) -> **`6.5 fps` (`154.2 ms`, `+0.2 fps / -4.3 ms`)** - Peak VRAM: `6345 MB` -> **`6243 MB` (`-102 MB`)**; `mapped()`: `4.18 ms/s` -> **`1.62 ms/s`**; `crashes=0` ### `--features diagnostics` Visual Verification (`diag-pr-cardsteps-1440p-90s`, 90s 1440p) - **6/6 gates PASS:** `world_windows=20` (`max_draws=12486`), `crashes=0`, `used_max=5849 MB` (`over=0 MB`, `room_false=6.2%`), `final_waiting=2463`, `mapped_rate=0.76 ms/s`, `pngs=24` (`lit=19/24`, `luma=95.09`, `near_black=0.1%`, `edge_energy=7.72`, `magenta=0.0%`). - Visually inspected `frame-2414.png`, `frame-2422.png`, and `frame-2428.png`: sharp textures, natural lighting, water reflections, and crisp HUD overlays.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 19:40:11 +00:00
github manually merged commit 6042ed29d8 into gh-pr/365/base 2026-12-02 19:40:15 +00:00
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/Androtim--MiniVI!365
No description provided.