GPU tests: a benchmark of what list calls cost on the title's threads #2820

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

@⁠0xkn0wh3r3 on GitHub · 2026-11-25 21:28 UTC · original
0xkn0wh3r3:gpu/list-call-bench-only → main · +1588 −0 · 3 files · 1 commits · open

Issue #2586 quotes about 20 µs per list call, measured on a fork. The triage asked for a per-call cost measured on main. This adds a synthetic benchmark that gives one, with no game data.

What it does

crates/victory-gpu/src/list_bench.rs is an #[ignore]d test. Several threads record command lists at once, the way a title's render threads do. Each call goes through the device and list method slots the title calls, and each call is timed.

  • Per draw: a constant buffer view is written into the shader-visible heap and bound as a table, then root constants, a root view and an indexed draw.
  • Every 32 draws a texture view is copied into the heap and bound. Every 128 draws a barrier pair is recorded.
  • Each frame ends with a compute pass between barriers, then Close. The main thread submits every list and waits for it.

Draws and dispatches run real host pipelines. Their shaders are hand-assembled GFX10 programs in the console container layout, taken from the conformance title's GPU frame (branch tests/gpu-frame-workload, list_bench/gfx10.rs). They read descriptor tables, so State::bind does what it does for a title's draws. The test fails if any draw does not run on the host.

The defaults are close to the issue's shape: 5 threads, about 8,300 calls each per frame. LIST_BENCH_THREADS, LIST_BENCH_DRAWS and LIST_BENCH_FRAMES change the shape. Run it alone, because other tests switch the device to the newer layouts, which moves list slots:

cargo test --release -p victory-gpu --lib list_calls -- --ignored --nocapture

Numbers on main (RTX 5070 Ti, Windows 11, release)

ns per call, all calls DrawIndexedInstanced CreateConstantBufferView
5 threads 920–1,000 (best runs) 3.8–4.1 µs 0.8–1.0 µs
1 thread 334 1.36 µs 0.17 µs
5 threads, diagnostics about 1,240 5.2 µs 0.76 µs

Draws take about 78% of recording time and descriptor writes about 17%. Everything else costs under 100 ns per call, except Reset (about 80 µs, once per list), Close, OMSetRenderTargets, barriers and dispatches. With five threads each call costs 3× what it costs on one thread, so the difference is contention.

A sampling profile of the five recording threads (an in-process sampler, not included here) puts about 58% of recording time in Mutex::lock_contended:

Lock Where it is taken Share of recording time in its contended path
per-heap HostHeap::made every table entry bound at each draw 25%
descriptor::SHADER_HEAPS every view write and descriptor copy 17%
shadow::BUFFERS shadow::find from draw::readable 15%

The VIEWS registry is next. Allocations, string formatting and SipHash lookups are each about 1% or less in this workload.

A follow-up PR (the lock changes, measured with this benchmark) builds on it.

What it does not cover

  • Per-call cost here is about 1 µs, not 20 µs. The title's heaps, buffer counts, tracked memory and command notes are far larger than anything here.
  • The shaders read descriptor tables only. Root constants and root views are set but not read, so their binding work at draw time is not measured.
  • Command notes (VICTORY_D3D12_DRED, #913) are not turned on.
**@⁠0xkn0wh3r3** on GitHub · 2026-11-25 21:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2820) `0xkn0wh3r3:gpu/list-call-bench-only` → `main` · +1588 −0 · 3 files · 1 commits · open Issue #2586 quotes about 20 µs per list call, measured on a fork. The triage asked for a per-call cost measured on main. This adds a synthetic benchmark that gives one, with no game data. ## What it does `crates/victory-gpu/src/list_bench.rs` is an `#[ignore]`d test. Several threads record command lists at once, the way a title's render threads do. Each call goes through the device and list method slots the title calls, and each call is timed. - Per draw: a constant buffer view is written into the shader-visible heap and bound as a table, then root constants, a root view and an indexed draw. - Every 32 draws a texture view is copied into the heap and bound. Every 128 draws a barrier pair is recorded. - Each frame ends with a compute pass between barriers, then `Close`. The main thread submits every list and waits for it. Draws and dispatches run real host pipelines. Their shaders are hand-assembled GFX10 programs in the console container layout, taken from the conformance title's GPU frame (branch `tests/gpu-frame-workload`, `list_bench/gfx10.rs`). They read descriptor tables, so `State::bind` does what it does for a title's draws. The test fails if any draw does not run on the host. The defaults are close to the issue's shape: 5 threads, about 8,300 calls each per frame. `LIST_BENCH_THREADS`, `LIST_BENCH_DRAWS` and `LIST_BENCH_FRAMES` change the shape. Run it alone, because other tests switch the device to the newer layouts, which moves list slots: ``` cargo test --release -p victory-gpu --lib list_calls -- --ignored --nocapture ``` ## Numbers on main (RTX 5070 Ti, Windows 11, release) | | ns per call, all calls | DrawIndexedInstanced | CreateConstantBufferView | |---|---|---|---| | 5 threads | 920–1,000 (best runs) | 3.8–4.1 µs | 0.8–1.0 µs | | 1 thread | 334 | 1.36 µs | 0.17 µs | | 5 threads, `diagnostics` | about 1,240 | 5.2 µs | 0.76 µs | Draws take about 78% of recording time and descriptor writes about 17%. Everything else costs under 100 ns per call, except `Reset` (about 80 µs, once per list), `Close`, `OMSetRenderTargets`, barriers and dispatches. With five threads each call costs 3× what it costs on one thread, so the difference is contention. A sampling profile of the five recording threads (an in-process sampler, not included here) puts **about 58% of recording time in `Mutex::lock_contended`**: | Lock | Where it is taken | Share of recording time in its contended path | |---|---|---| | per-heap `HostHeap::made` | every table entry bound at each draw | 25% | | `descriptor::SHADER_HEAPS` | every view write and descriptor copy | 17% | | `shadow::BUFFERS` | `shadow::find` from `draw::readable` | 15% | The `VIEWS` registry is next. Allocations, string formatting and SipHash lookups are each about 1% or less in this workload. A follow-up PR (the lock changes, measured with this benchmark) builds on it. ## What it does not cover - Per-call cost here is about 1 µs, not 20 µs. The title's heaps, buffer counts, tracked memory and command notes are far larger than anything here. - The shaders read descriptor tables only. Root constants and root views are set but not read, so their binding work at draw time is not measured. - Command notes (`VICTORY_D3D12_DRED`, #913) are not turned on.
Issue #2586 measured about 20 us a list call on a fork, with nothing on
main to compare against. This records command lists the way a title's
render threads do, from several threads at once, through the device and
list method slots the title calls, and times each call: per draw a
constant buffer view written into the shader-visible heap and bound as a
table, root constants, a root view and an indexed draw; texture views
copied into the heap, barriers, a compute pass, then the list is closed
and the main thread submits every list. Draws and dispatches run real
host pipelines made from hand-assembled GFX10 shaders that read
descriptor tables (the conformance title's, branch
tests/gpu-frame-workload), so binding does what it does for a title; the
test fails if a draw does not run on the host.

Defaults are near the issue's shape: 5 threads x ~8,300 calls a frame.
It reports ns a call per method and each thread's time in calls.

RTX 5070 Ti, release: 1,119 ns a call on average, 9.3 ms a thread a
frame; DrawIndexedInstanced 4.5 us (78 %), CreateConstantBufferView
1.0 us (17 %); diagnostics builds 1,390 ns a call.

cargo test --release -p victory-gpu --lib list_calls -- --ignored --nocapture
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:15:03 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 21:40 UTC · original

Verified f7579ca0 on Windows 11 (RTX 5090):

  • cargo xtask policy: 186 files ok; cargo clippy --locked -p victory-gpu --all-targets -- -D warnings (default & --features diagnostics): 0 warnings; clean git merge-tree against origin/main 13f91ca.
  • Baseline --release list_calls benchmark (5 threads × 8,310 calls/frame × 10 frames = 80,000 draws + 2,500 dispatches, 0 dropped, 2 runs):
    • Run 1: 1871 ns/call, 15.54 ms/thr/frame (15.78 ms recording, 12.81 ms CPU, 15.97 ms/frame wall; DrawIndexedInstanced 7521 ns, CreateCBV 1795 ns, CopyDescriptorsSimple 3165 ns, Dispatch 1867 ns)
    • Run 2: 1495 ns/call, 12.42 ms/thr/frame (12.65 ms recording, 8.44 ms CPU, 12.79 ms/frame wall; DrawIndexedInstanced 6065 ns, CreateCBV 1344 ns, CopyDescriptorsSimple 2407 ns, Dispatch 1580 ns)
**@⁠fuzeofficlal** on GitHub · 2026-11-25 21:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2820#issuecomment-7175400336) Verified `f7579ca0` on Windows 11 (RTX 5090): - `cargo xtask policy`: 186 files ok; `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` (default & `--features diagnostics`): 0 warnings; clean `git merge-tree` against `origin/main` `13f91ca`. - Baseline `--release` `list_calls` benchmark (`5` threads × `8,310` calls/frame × `10` frames = `80,000` draws + `2,500` dispatches, `0` dropped, 2 runs): - Run 1: `1871 ns/call`, `15.54 ms/thr/frame` (`15.78 ms` recording, `12.81 ms` CPU, `15.97 ms/frame` wall; `DrawIndexedInstanced` `7521 ns`, `CreateCBV` `1795 ns`, `CopyDescriptorsSimple` `3165 ns`, `Dispatch` `1867 ns`) - Run 2: `1495 ns/call`, `12.42 ms/thr/frame` (`12.65 ms` recording, `8.44 ms` CPU, `12.79 ms/frame` wall; `DrawIndexedInstanced` `6065 ns`, `CreateCBV` `1344 ns`, `CopyDescriptorsSimple` `2407 ns`, `Dispatch` `1580 ns`)
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 02:21 UTC · original · edited 2026-11-26 07:22 UTC

Automated triage for the maintainers.

Thanks. I confirmed that #2821 no longer carries list_bench.rs or list_bench/gfx10.rs, so this is now the only PR that would add them. Otherwise nothing has changed (same head). Whether about 1,600 lines of benchmark code, including hand-assembled GFX10 shaders, belong in the tree needs the maintainer's decision. The numbers stay in the description either way.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 02:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2820#issuecomment-7180728445) · edited 2026-11-26 07:22 UTC <!-- victory-triage v1 head=cdc91bc540aa236b8e6113c4b3445c25d89e7b96 verdict=needs-work at=2026-11-26T07:22:53Z --> Automated triage for the maintainers. Thanks. I confirmed that #2821 no longer carries `list_bench.rs` or `list_bench/gfx10.rs`, so this is now the only PR that would add them. Otherwise nothing has changed (same head). Whether about 1,600 lines of benchmark code, including hand-assembled GFX10 shaders, belong in the tree **needs the maintainer's decision**. The numbers stay in the description either way. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠0xkn0wh3r3 on GitHub · 2026-11-26 06:42 UTC · original

Understood: whether the benchmark belongs in the tree is your call. #2821 no longer carries these files, so this PR is the only place they'd land. If you'd rather not keep ~1,600 lines of benchmark code, I'll close it; the numbers stay in the description for reference.

**@⁠0xkn0wh3r3** on GitHub · 2026-11-26 06:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2820#issuecomment-7184693965) Understood: whether the benchmark belongs in the tree is your call. #2821 no longer carries these files, so this PR is the only place they'd land. If you'd rather not keep ~1,600 lines of benchmark code, I'll close it; the numbers stay in the description for reference.
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 origin '+refs/pull/2820/head:github-bot/gh-2820'
git switch 'github-bot/gh-2820'

Merge

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