perf(gpu): optimize card_steps planner, batched fill-to lookup, sorted writer search #1279

Open
github-bot wants to merge 1 commit from github-bot/gh-1279 into main AGit
Owner

@⁠qlfu on GitHub · 2026-11-28 16:52 UTC · original
qlfu:pr/card-steps-perf → main · +208 −124 · 1 files · 1 commits · open

Summary

Reduces submitting-thread CPU overhead in crates/victory-gpu/src/host/card_steps.rs (planning steps done on the card):

  1. Fast-path plan() when no Does::Copy exists:
    • Tracks has_copy / has_placed and taken_count during the initial scan so submissions with only Does::Fill skip redundant copy/placement overlap passes.
    • Removes Box<dyn Iterator> heap allocations during level assignment.
  2. Batched FillTo lookups per HostList:
    • Replaces repeated per-fill lock acquisitions/lookups with collect_fill_tos(), gathering each HostList's fill targets in a single pass.
  3. Sorted writers search + fast barrier deduplication + empty-slot skip:
    • Keeps writers sorted and uses partition_point in holder() instead of linear scanning.
    • Deduplicates D3D12 transition barriers with AddressHash.
    • Skips each_under thread-pool dispatch when slot_ops == 0.

Benchmark (GTA VI, 90s steady gameplay, 1440p Series X, DLSS Quality, Ryzen 7 5700X + RTX 4070 Ti 12 GB)

Paired A/B on main (9ce3cf9) with -FrameGen:

Metric (90s median per 5s window unless noted) main (9ce3cf9) pr/card-steps-perf (674d1c5) Delta
Median FPS 15.65 16.30 +4.2%
Mean FPS 16.06 17.10 +6.5%
Max FPS (p90) 21.3 (19.2) 27.3 (20.7) +28.2% (+7.8%)
Frame time (prep / copy back) 63.95 ms (46.95 / 18.4) 61.45 ms (45.55 / 17.7) -3.9%
ASYNC_SUBMIT worked 61.1 ms 58.9 ms -3.6%
Title present-wait 19.7 ms 16.1 ms -18.3%
Gameplay WARN / ERROR count 0 / 0 0 / 0 clean

Verification

  • cargo clippy -p victory-gpu --all-targets --locked and --all-features --locked: 0 warnings/errors in card_steps.rs.
  • cargo test -p victory-gpu --lib --locked -- --test-threads=1 --quiet: 455 passed, 0 failed, 36 ignored.
  • cargo build --release --locked -p victory: exit 0.
**@⁠qlfu** on GitHub · 2026-11-28 16:52 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1279) `qlfu:pr/card-steps-perf` → `main` · +208 −124 · 1 files · 1 commits · open ### Summary Reduces submitting-thread CPU overhead in `crates/victory-gpu/src/host/card_steps.rs` (`planning steps done on the card`): 1. **Fast-path `plan()` when no `Does::Copy` exists**: - Tracks `has_copy` / `has_placed` and `taken_count` during the initial scan so submissions with only `Does::Fill` skip redundant copy/placement overlap passes. - Removes `Box<dyn Iterator>` heap allocations during level assignment. 2. **Batched `FillTo` lookups per `HostList`**: - Replaces repeated per-fill lock acquisitions/lookups with `collect_fill_tos()`, gathering each `HostList`'s fill targets in a single pass. 3. **Sorted `writers` search + fast barrier deduplication + empty-slot skip**: - Keeps `writers` sorted and uses `partition_point` in `holder()` instead of linear scanning. - Deduplicates D3D12 transition barriers with `AddressHash`. - Skips `each_under` thread-pool dispatch when `slot_ops == 0`. ### Benchmark (GTA VI, 90s steady gameplay, 1440p Series X, DLSS Quality, Ryzen 7 5700X + RTX 4070 Ti 12 GB) Paired A/B on `main` (`9ce3cf9`) with `-FrameGen`: | Metric (90s median per 5s window unless noted) | `main` (`9ce3cf9`) | `pr/card-steps-perf` (`674d1c5`) | Delta | |---|---:|---:|---:| | Median FPS | `15.65` | `16.30` | **+4.2%** | | Mean FPS | `16.06` | `17.10` | **+6.5%** | | Max FPS (`p90`) | `21.3` (`19.2`) | `27.3` (`20.7`) | **+28.2%** (**+7.8%**) | | Frame time (`prep` / `copy back`) | `63.95 ms` (`46.95` / `18.4`) | `61.45 ms` (`45.55` / `17.7`) | **-3.9%** | | `ASYNC_SUBMIT` worked | `61.1 ms` | `58.9 ms` | **-3.6%** | | Title `present-wait` | `19.7 ms` | `16.1 ms` | **-18.3%** | | Gameplay `WARN` / `ERROR` count | `0` / `0` | `0` / `0` | clean | ### Verification - `cargo clippy -p victory-gpu --all-targets --locked` and `--all-features --locked`: 0 warnings/errors in `card_steps.rs`. - `cargo test -p victory-gpu --lib --locked -- --test-threads=1 --quiet`: **455 passed, 0 failed, 36 ignored**. - `cargo build --release --locked -p victory`: exit `0`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 16:52:57 +00:00
Author
Owner

@⁠Aniseto on GitHub · 2026-11-28 19:39 UTC · original

Ran the full victory-gpu library suite at 674d1c5 on an NVIDIA Blackwell desktop part with an updated driver.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: Rust 1.98.1 (48a229cea 2026-09-01, pinned by rust-toolchain.toml), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-gpu --lib --locked -- --test-threads=1 --quiet: 455 passed, 0 failed, 36 ignored.

What this adds
The count matches the author's run. This covers the faster card-step planner, batched FillTo lookup and sorted writer search. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti on driver 32.0.16.2140. It is a correctness run, not a CPU-time measurement.

Not tested
A retail title, CPU-time or FPS A/B, a paired smoke run, the whole workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.

**@⁠Aniseto** on GitHub · 2026-11-28 19:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1279#issuecomment-7244703586) Ran the full victory-gpu library suite at `674d1c5` on an NVIDIA Blackwell desktop part with an updated driver. **System** - GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40) - CPU: Intel Core i5-12400F, 64 GB RAM - OS: Windows 11 Pro build 26200 x64 - Toolchain: Rust 1.98.1 (48a229cea 2026-09-01, pinned by `rust-toolchain.toml`), MSVC 14.44.35207, DXC 1.9.2609.5 - Build: debug **Results** - `VICTORY_D3D12_ADAPTER=NVIDIA cargo test -p victory-gpu --lib --locked -- --test-threads=1 --quiet`: 455 passed, 0 failed, 36 ignored. **What this adds** The count matches the author's run. This covers the faster card-step planner, batched FillTo lookup and sorted writer search. The PR has no comments yet, so this is the first datapoint in the thread and the first from an RTX 5070 Ti on driver 32.0.16.2140. It is a correctness run, not a CPU-time measurement. **Not tested** A retail title, CPU-time or FPS A/B, a paired smoke run, the whole workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - ran the commands above on this machine and wrote this report; no game data was used.
github-bot force-pushed github-bot/gh-1279 from 674d1c5a0f to da94a8e9ef 2026-11-28 20:57:16 +00:00 Compare
Author
Owner

@⁠meonline42 on GitHub · 2026-11-29 09:18 UTC · original

Measurements from a Zen 3 + Ampere machine, in case they're useful (stacked builds, so most PRs aren't isolated, see below).

Machine: Ryzen 9 5900X (thermally limited: ~3.7 GHz average, Tctl 80-87 °C), RTX 3090 at 350 W, 64 GB DDR4-3200, Windows 11. Series X profile, 1080p rendered to 1440p, DLSS Performance, FSR 3 frame generation 2x.
Base: main at e1f2eb6, plus a local keyboard-input patch (victory-hle only, nothing in the GPU path).
Method: each build was started unattended from the same save, standing still, and measured for 150 s once the world was drawn. The scene isn't identical between runs (traffic and time of day differ), so I also bucketed the 5-second victory_gpu::host lines by draws per frame.

Build (stacked, each on top of the one above) fps median ms/frame, 6,000-6,999 draws ms/frame, 12,000-12,999 draws
main e1f2eb6 16 57.9 (n=3) -
+ #1403 #1279 #2049 #1937 17 56.8 (n=22) 77.6 (n=4)
+ #1988 with VICTORY_PRESENT_QUEUE=1 18 55.9 (n=24) 75.5 (n=10)
#1403 #1279 #2049 #1937 + #128 (fat LTO), no present queue 18 55.0 (n=26) 74.0 (n=8)
  • Each step moves in the right direction, but the gains (1-2 ms per step, about 5% in total) are close to run-to-run noise on this setup.
  • No crashes or visible problems in any run, but standing still doesn't exercise much.
  • #1937: the launcher here already set VICTORY_SPANS_QUICK=1, so its default flip made no difference in this run.
  • #128: a full release build took 4 min 23 s on the 5900X.
  • On this machine, most of the frame is still preparing: copies of 24-28 ms for 60-70 MB per frame, and the card busy only a few ms. Copy-back dropped from ~13 ms to ~6.5 ms between 923e38c and e1f2eb6.

Posted by Claude Code on behalf of the machine's owner.

**@⁠meonline42** on GitHub · 2026-11-29 09:18 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1279#issuecomment-7253671241) Measurements from a Zen 3 + Ampere machine, in case they're useful (stacked builds, so most PRs aren't isolated, see below). **Machine:** Ryzen 9 5900X (thermally limited: ~3.7 GHz average, Tctl 80-87 °C), RTX 3090 at 350 W, 64 GB DDR4-3200, Windows 11. Series X profile, 1080p rendered to 1440p, DLSS Performance, FSR 3 frame generation 2x. **Base:** `main` at `e1f2eb6`, plus a local keyboard-input patch (victory-hle only, nothing in the GPU path). **Method:** each build was started unattended from the same save, standing still, and measured for 150 s once the world was drawn. The scene isn't identical between runs (traffic and time of day differ), so I also bucketed the 5-second `victory_gpu::host` lines by draws per frame. | Build (stacked, each on top of the one above) | fps median | ms/frame, 6,000-6,999 draws | ms/frame, 12,000-12,999 draws | |---|---|---|---| | `main` e1f2eb6 | 16 | 57.9 (n=3) | - | | + #1403 #1279 #2049 #1937 | 17 | 56.8 (n=22) | 77.6 (n=4) | | + #1988 with `VICTORY_PRESENT_QUEUE=1` | 18 | 55.9 (n=24) | 75.5 (n=10) | | #1403 #1279 #2049 #1937 + #128 (fat LTO), no present queue | 18 | 55.0 (n=26) | 74.0 (n=8) | - Each step moves in the right direction, but the gains (1-2 ms per step, about 5% in total) are close to run-to-run noise on this setup. - No crashes or visible problems in any run, but standing still doesn't exercise much. - #1937: the launcher here already set `VICTORY_SPANS_QUICK=1`, so its default flip made no difference in this run. - #128: a full release build took 4 min 23 s on the 5900X. - On this machine, most of the frame is still `preparing`: copies of 24-28 ms for 60-70 MB per frame, and the card busy only a few ms. Copy-back dropped from ~13 ms to ~6.5 ms between `923e38c` and `e1f2eb6`. Posted by Claude Code on behalf of the machine's owner.
github-bot force-pushed github-bot/gh-1279 from da94a8e9ef to 6fcaa51f66 2026-11-29 14:56:28 +00:00 Compare
Author
Owner

@⁠dyshay on GitHub · 2026-11-29 15:40 UTC · original

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series X 1440p, and Series S with ray tracing, DLSS Quality). Frame times will follow here.

**@⁠dyshay** on GitHub · 2026-11-29 15:40 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1279#issuecomment-7258273541) Merged into our fork's integration branch for testing ([dyshay/VIctory-NVIDIA](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs), branch `janus-prs`). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with `--profile diag --features diagnostics`, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series X 1440p, and Series S with ray tracing, DLSS Quality). Frame times will follow here.
Author
Owner

@⁠DoubleD17 on GitHub · 2026-11-30 07:58 UTC · original · edited 2026-11-30 09:57 UTC

We ran a test of this PR on current main (41adb551 with this PR merged), on a CPU-bound machine.

We compare only the seconds where the idle camera shows the same lighter views (about 7,500 draws a frame). Its heavier view (about 15,000 draws, half the frame rate) takes 10 to 60 s of each 150 s run, and it moved whole-run means by several ms.

CPU prep (ms/frame) main at that point fps main at that point
round 1 60.0 60.8 15.3 14.3
round 2 64.0 60.0 13.5 15.3
mean difference +1.6 ms −2.4 %

No difference we can measure. The five main runs of the session agreed within 1.3 ms on these seconds. But we also ran main again, built in another folder, eight times: it ranged from 57.5 to 65.5 ms. Its first four runs were 2.4 ms slower than main on average, and the last four 4.2 ms faster. All nine PRs we tested in this session came out 0.4 to 3.9 ms slower than main, and fps moved with it. So we read the difference as a newly built executable, not as this PR.

Picture: 0 defects in 160 frames.

Setup:

  • Ryzen 7 5800X (8 cores, 16 threads), RTX 5070 12 GB (DXGI budget 11,175 MB), 64 GB RAM, Windows 11;
  • Series X, 1440p with DLAA (DLSS at native resolution; corrected, this line said DLSS Performance at first), frame generation and ray tracing off;
  • the PR merged locally onto main 41adb551 (only its own commits on top), against 41adb551 itself;
  • a warm-up run per build, then 150 s runs in two rounds (the second in reverse order), with five main runs spread through the session;
  • every run starts from the same save, restored before each run;
  • CPU prep is the median of the submitting thread's 5 s lines, fps the median of the host's 5 s lines, on the light-view seconds after the first 20 s; each run is compared with main's runs interpolated in time.

Picture check: a burst of 10 captures a second at the end of each run (80 frames), looked at frame by frame.

AI Assisted

**@⁠DoubleD17** on GitHub · 2026-11-30 07:58 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1279#issuecomment-7272336152) · edited 2026-11-30 09:57 UTC We ran a test of this PR on current main (41adb551 with this PR merged), on a CPU-bound machine. We compare only the seconds where the idle camera shows the same lighter views (about 7,500 draws a frame). Its heavier view (about 15,000 draws, half the frame rate) takes 10 to 60 s of each 150 s run, and it moved whole-run means by several ms. | | CPU prep (ms/frame) | main at that point | fps | main at that point | |---|---|---|---|---| | round 1 | 60.0 | 60.8 | 15.3 | 14.3 | | round 2 | 64.0 | 60.0 | 13.5 | 15.3 | | **mean difference** | **+1.6 ms** | | **−2.4 %** | | No difference we can measure. The five main runs of the session agreed within 1.3 ms on these seconds. But we also ran main again, built in another folder, eight times: it ranged from 57.5 to 65.5 ms. Its first four runs were 2.4 ms slower than main on average, and the last four 4.2 ms faster. All nine PRs we tested in this session came out 0.4 to 3.9 ms slower than main, and fps moved with it. So we read the difference as a newly built executable, not as this PR. **Picture:** 0 defects in 160 frames. **Setup:** - Ryzen 7 5800X (8 cores, 16 threads), RTX 5070 12 GB (DXGI budget 11,175 MB), 64 GB RAM, Windows 11; - Series X, 1440p with DLAA (DLSS at native resolution; corrected, this line said DLSS Performance at first), frame generation and ray tracing off; - the PR merged locally onto main 41adb551 (only its own commits on top), against 41adb551 itself; - a warm-up run per build, then 150 s runs in two rounds (the second in reverse order), with five main runs spread through the session; - every run starts from the same save, restored before each run; - CPU prep is the median of the submitting thread's 5 s lines, fps the median of the host's 5 s lines, on the light-view seconds after the first 20 s; each run is compared with main's runs interpolated in time. Picture check: a burst of 10 captures a second at the end of each run (80 frames), looked at frame by frame. AI Assisted
Author
Owner

@⁠Cooperos on GitHub · 2026-11-30 09:39 UTC · original

I tested this changes on the same CPU (Ryzen 7 5700X), 8 GB RTX 3070 Ti,
driver 610.88, Series S profile, 1440p scene 1280x720, DLSS quality, frame
generation off, same save and overlapping routes:

v2026.11.29.05 this PR
median fps 16.3 15.6
slowest 5% 9.9 10.1
under 10 fps 65 s of 1,202 s 69 s of 1,447 s
title waited at presents 15.7 ms 10.5 ms (−33%)
crashes / memory-pressure warnings 0 0
**@⁠Cooperos** on GitHub · 2026-11-30 09:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1279#issuecomment-7274505131) I tested this changes on the same CPU (Ryzen 7 5700X), 8 GB RTX 3070 Ti, driver 610.88, Series S profile, 1440p scene 1280x720, DLSS quality, frame generation off, same save and overlapping routes: | | v2026.11.29.05 | this PR | |---|---|---| | median fps | 16.3 | 15.6 | | slowest 5% | 9.9 | 10.1 | | under 10 fps | 65 s of 1,202 s | 69 s of 1,447 s | | title waited at presents | 15.7 ms | **10.5 ms (−33%)** | | crashes / memory-pressure warnings | 0 | 0 |
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host/card_steps.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1279/head:github-bot/gh-1279'
git switch 'github-bot/gh-1279'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1279'
git switch 'github-bot/gh-1279'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1279'
git switch 'github-bot/gh-1279'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1279'
git switch 'main'
git merge --squash 'github-bot/gh-1279'
git switch 'main'
git merge --ff-only 'github-bot/gh-1279'
git switch 'main'
git merge 'github-bot/gh-1279'
git push origin 'main'
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/trustno1-coder--VIctory-NVIDIA!1279
No description provided.