perf: cut the layer's CPU and card-side overhead (14 changes, switch-gated) #1449

Closed
gaxolotl wants to merge 39 commits from upstream-pr/1449 into main
gaxolotl commented 2026-11-28 20:11:57 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by gaxolotl on 2026-11-28T20:11:57Z.


What this is

A performance pass over the layer, driven by measurements on one machine
(i5-14600KF, 32 GB, RTX 4070 Ti 12 GB, Windows 11 26300, driver 621.24, Series X
profile, 2560x1440, DLSS Quality). Every change is behind its own VICTORY_*
switch and defaults to the new path, with =0 restoring the old one.

The target was 30 fps rendered with VICTORY_FRAMEGEN=0. It is not reached
and cannot be reached by this layer's bookkeeping
— the last section has the
measurement that settles it. Everything below is still a real reduction in work
the layer was doing; it just is not the work that limits the frame.

Changes

Card command stream

  • Join adjacent card copies — upstream foxhound 0.2.0-pre.5 (7c53527).
    10,541 fills/frame became 3,499 copies. VICTORY_CARD_STEPS_JOIN.
  • Align copy runs on 256 bytes when the title's constant ring is off 256.
    3,499 → 823 copies/frame. VICTORY_CARD_STEPS_ALIGN.
  • Plan the steps faster: one ReadProcessMemory a place instead of one per
    page (240 ns for 1 byte vs 276 ns per place), the fill lookup under the one
    list lock taken per plan, and hash runs built in order instead of sorted
    (64k–85k spans a frame). VICTORY_CARD_PLAN_FAST, VICTORY_CARD_HASH_ORDER.

Descriptor heaps

  • Mirror only the slots the host has — 41% of the 1,245,184-slot heap could
    never be mirrored. 22 MB → 9.7 MB read per frame. VICTORY_SYNC_CAP.
  • Carry the record words out of the compare pass instead of re-reading them.
    VICTORY_SYNC_WORDS.
  • Make runs of null slots with one CopyDescriptors — ~16,800 calls →
    ~368 runs/frame. VICTORY_SYNC_NULL_RUNS.
  • Cache the descriptor made for a record within a round — the title copies
    one view into many slots; each was a Create*View. VICTORY_SYNC_MAKE_CACHE.
  • Answer a round from a clean heap without asking the watch when every
    guarded block is read-only and clean. VICTORY_SYNC_ASK_CLEAN.

Write watch / refreshes

  • Journal page table as fixed-size pieces instead of an unbounded
    BTreeMap (136 ns → 4 ns a page look at 100k pages), one read lock per flush,
    ordered ahead-range lookup. Refreshes 11.3 → 8.7 ms/frame.
    VICTORY_JOURNAL_TREE, VICTORY_REFRESH_BULK.
  • Send only the dwords that changed, for copies no shader writes.
    VICTORY_SEND_CHANGED (off by default).
  • Gather send ranges across ≤256-byte gaps, one card_sides() per copy
    instead of three. VICTORY_SEND_BATCH.

Textures

  • Refuse a slot with no host texture before its 48 KiB look when the pool has
    no room; tell the queue 256 at a time. VICTORY_TEXSPK_SKIP_WHEN_FULL.
  • Take the due list from an index ordered by due frame — 108 µs → 3.6 µs at
    40k slots — and bound a take to twice what the pass last served (154 takes
    walked 594,000 entries to serve 48,414). VICTORY_DUE_ORDERED,
    VICTORY_TEXSPK_DUE_TAKE.
  • One record read a slot instead of 4–5. VICTORY_TEXSPK_ONE_RECORD.
  • The pass went 1,215 → 541 ms per 5 s (~12 → ~5 ms/frame) with these.

Card compare/hash passes

  • Run-list driven passes and one dispatch per compare list via a
    descriptor table
    (SRV t0[64] / UAV u0[64]): 549 → 56 commands in replay,
    picture byte-identical. VICTORY_CARD_PASS_BATCH.
  • 256-thread piece hash with a tree (16 dependent steps instead of 64),
    bit-identical to the CPU mirror in torn.rs, proved by a WARP test.
    VICTORY_CARD_HASH_WIDE.

Build

  • Fat LTO, one codegen unit for release; the diagnostics profile skips LTO so
    victory replay builds in about a minute.

Verification

  • cargo test --release -p victory-gpu --lib: 488 passed, 0 failed.
  • WARP tests pin the null-run descriptors, the run-list and table hashes, and the
    wide hash against the CPU mirror, byte for byte.
  • victory replay of a recorded frame: picture blake3 unchanged by every batching
    change; commands 549 → 56.

Why 30 fps is not reached — and cannot be, from here

Three controlled experiments say the frame is not bound by anything this layer
does.

  1. Pixels are not the cost. DLSS Performance (1280x720 internal instead of
    1706x960) plus the ambient/reflection estimate off — two large quality
    cuts — gives 19.6 fps, 51.1 ms, card 83% busy. Halving the pixels changed
    nothing.
  2. Barriers are not the cost. The replay has 3,017 barriers and every title
    barrier is promoted to a global UAV barrier. Running the frame with them
    removed is slower (44.1 ms vs 42.3 ms baseline); merging them is slower
    still (53.8 ms).
  3. The layer's GPU work is small. victory replay --timing detailed on a
    recorded frame: indirect mesh draws 25.0 ms in 7,817 commands, dispatches
    15.4 ms in 1,735, indirect dispatches 7.9 ms, draws 6.3 ms — against our
    hash/compare passes at ~7 ms (all 549), texture copies 3.4 ms, buffer copies
    2.8 ms, clamps 1.7 ms.

So the card spends ~42 ms of a ~50 ms frame launching and running ~7,800 mesh
draws at ~5 µs each, and it draws only ~125 W doing it — high occupancy, low
power, i.e. per-draw front-end work, not shading. Removing all of the layer's
GPU work would leave a ~42 ms frame (24 fps), and it would still be the title's
geometry.

The remaining lever is the translated geometry itself — how a mesh draw is
translated and launched — which is a project, not a patch series.

Measurement notes

Unattended runs drift into different content (draws 1.2k–12.9k), so raw fps is
not comparable between runs; the figures above come from the layer's own
per-frame counters or from controlled victory replay --compare A/Bs in one
process.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5544149021 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1449). Originally posted by [gaxolotl](https://github.com/gaxolotl) on 2026-11-28T20:11:57Z. --- ## What this is A performance pass over the layer, driven by measurements on one machine (i5-14600KF, 32 GB, RTX 4070 Ti 12 GB, Windows 11 26300, driver 621.24, Series X profile, 2560x1440, DLSS Quality). Every change is behind its own `VICTORY_*` switch and defaults to the new path, with `=0` restoring the old one. The target was 30 fps rendered with `VICTORY_FRAMEGEN=0`. **It is not reached and cannot be reached by this layer's bookkeeping** — the last section has the measurement that settles it. Everything below is still a real reduction in work the layer was doing; it just is not the work that limits the frame. ## Changes ### Card command stream - **Join adjacent card copies** — upstream foxhound `0.2.0-pre.5` (`7c53527`). 10,541 fills/frame became 3,499 copies. `VICTORY_CARD_STEPS_JOIN`. - **Align copy runs on 256 bytes when the title's constant ring is off 256.** 3,499 → 823 copies/frame. `VICTORY_CARD_STEPS_ALIGN`. - **Plan the steps faster**: one `ReadProcessMemory` a place instead of one per page (240 ns for 1 byte vs 276 ns per place), the fill lookup under the one list lock taken per plan, and hash runs built in order instead of sorted (64k–85k spans a frame). `VICTORY_CARD_PLAN_FAST`, `VICTORY_CARD_HASH_ORDER`. ### Descriptor heaps - **Mirror only the slots the host has** — 41% of the 1,245,184-slot heap could never be mirrored. 22 MB → 9.7 MB read per frame. `VICTORY_SYNC_CAP`. - **Carry the record words out of the compare pass** instead of re-reading them. `VICTORY_SYNC_WORDS`. - **Make runs of null slots with one `CopyDescriptors`** — ~16,800 calls → ~368 runs/frame. `VICTORY_SYNC_NULL_RUNS`. - **Cache the descriptor made for a record within a round** — the title copies one view into many slots; each was a `Create*View`. `VICTORY_SYNC_MAKE_CACHE`. - **Answer a round from a clean heap without asking the watch** when every guarded block is read-only and clean. `VICTORY_SYNC_ASK_CLEAN`. ### Write watch / refreshes - **Journal page table as fixed-size pieces** instead of an unbounded `BTreeMap` (136 ns → 4 ns a page look at 100k pages), one read lock per flush, ordered ahead-range lookup. Refreshes 11.3 → 8.7 ms/frame. `VICTORY_JOURNAL_TREE`, `VICTORY_REFRESH_BULK`. - **Send only the dwords that changed**, for copies no shader writes. `VICTORY_SEND_CHANGED` (off by default). - **Gather send ranges across ≤256-byte gaps**, one `card_sides()` per copy instead of three. `VICTORY_SEND_BATCH`. ### Textures - **Refuse a slot with no host texture before its 48 KiB look** when the pool has no room; tell the queue 256 at a time. `VICTORY_TEXSPK_SKIP_WHEN_FULL`. - **Take the due list from an index ordered by due frame** — 108 µs → 3.6 µs at 40k slots — and bound a take to twice what the pass last served (154 takes walked 594,000 entries to serve 48,414). `VICTORY_DUE_ORDERED`, `VICTORY_TEXSPK_DUE_TAKE`. - **One record read a slot** instead of 4–5. `VICTORY_TEXSPK_ONE_RECORD`. - The pass went **1,215 → 541 ms per 5 s** (~12 → ~5 ms/frame) with these. ### Card compare/hash passes - **Run-list driven passes** and **one dispatch per compare list via a descriptor table** (`SRV t0[64]` / `UAV u0[64]`): 549 → 56 commands in replay, picture byte-identical. `VICTORY_CARD_PASS_BATCH`. - **256-thread piece hash with a tree** (16 dependent steps instead of 64), bit-identical to the CPU mirror in `torn.rs`, proved by a WARP test. `VICTORY_CARD_HASH_WIDE`. ### Build - **Fat LTO, one codegen unit** for release; the diagnostics profile skips LTO so `victory replay` builds in about a minute. ## Verification - `cargo test --release -p victory-gpu --lib`: **488 passed, 0 failed**. - WARP tests pin the null-run descriptors, the run-list and table hashes, and the wide hash against the CPU mirror, byte for byte. - `victory replay` of a recorded frame: picture blake3 unchanged by every batching change; commands 549 → 56. ## Why 30 fps is not reached — and cannot be, from here Three controlled experiments say the frame is not bound by anything this layer does. 1. **Pixels are not the cost.** DLSS Performance (1280x720 internal instead of 1706x960) *plus* the ambient/reflection estimate off — two large quality cuts — gives **19.6 fps, 51.1 ms, card 83% busy**. Halving the pixels changed nothing. 2. **Barriers are not the cost.** The replay has 3,017 barriers and every title barrier is promoted to a global UAV barrier. Running the frame with them removed is *slower* (44.1 ms vs 42.3 ms baseline); merging them is slower still (53.8 ms). 3. **The layer's GPU work is small.** `victory replay --timing detailed` on a recorded frame: indirect mesh draws 25.0 ms in 7,817 commands, dispatches 15.4 ms in 1,735, indirect dispatches 7.9 ms, draws 6.3 ms — against our hash/compare passes at ~7 ms (all 549), texture copies 3.4 ms, buffer copies 2.8 ms, clamps 1.7 ms. So the card spends ~42 ms of a ~50 ms frame launching and running ~7,800 mesh draws at ~5 µs each, and it draws only ~125 W doing it — high occupancy, low power, i.e. per-draw front-end work, not shading. Removing *all* of the layer's GPU work would leave a ~42 ms frame (24 fps), and it would still be the title's geometry. The remaining lever is the translated geometry itself — how a mesh draw is translated and launched — which is a project, not a patch series. ## Measurement notes Unattended runs drift into different content (draws 1.2k–12.9k), so raw fps is not comparable between runs; the figures above come from the layer's own per-frame counters or from controlled `victory replay --compare` A/Bs in one process.

Pull request closed

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!1449
No description provided.