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

Open
0xkn0wh3r3 wants to merge 1 commit from upstream-pr/2820 into main
0xkn0wh3r3 commented 2026-11-25 21:28:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-25T21:28:23Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6614110662 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2820). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-25T21:28:23Z. --- 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.
fuzeofficlal commented 2026-11-25 22:04:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:40:52Z.


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)
<!-- greyfinch-sync:Marvisak/VIctory:comment:7175400336 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2820#issuecomment-7175400336). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T21:40:52Z. --- 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`)
kotekompotek commented 2026-11-25 23:05:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T22:10:43Z.

Review: COMMENTED


Test-only benchmark infrastructure for measuring per-list-call cost on the title's threads — establishes the baseline #2821's lock changes are measured against. No production code paths touched. LGTM as scaffolding; the gfx10 list-encoding coverage keeps it honest.

<!-- greyfinch-sync:Marvisak/VIctory:review:6065686434 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2820#pullrequestreview-6065686434). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T22:10:43Z. **Review:** COMMENTED --- Test-only benchmark infrastructure for measuring per-list-call cost on the title's threads — establishes the baseline #2821's lock changes are measured against. No production code paths touched. LGTM as scaffolding; the gfx10 list-encoding coverage keeps it honest.
Marvisak commented 2026-11-26 03:05:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T02:21:34Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7180728445 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2820#issuecomment-7180728445). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T02:21:34Z. --- <!-- 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)_
0xkn0wh3r3 commented 2026-11-26 07:01:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by 0xkn0wh3r3 on 2026-11-26T06:42:01Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7184693965 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2820#issuecomment-7184693965). Originally posted by [0xkn0wh3r3](https://github.com/0xkn0wh3r3) on 2026-11-26T06:42:01Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2820:upstream-pr/2820'
git switch 'upstream-pr/2820'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2820'
git switch 'upstream-pr/2820'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2820'
git switch 'upstream-pr/2820'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2820'
git switch 'main'
git merge --squash 'upstream-pr/2820'
git switch 'main'
git merge --ff-only 'upstream-pr/2820'
git switch 'main'
git merge 'upstream-pr/2820'
git push origin 'main'
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
Marvisak/VIctory!2818
No description provided.