Proposal: record list calls on the title's threads, translate them on worker threads (about 20 µs a call today) #2586

Open
opened 2026-11-26 05:09:47 +00:00 by github-bot · 4 comments
Owner

@⁠shawshanker18 on GitHub · 2026-11-25 16:18 UTC · original

Idea

The title's render threads call the D3D12.X list methods, and the layer translates each call right there, on the title's thread. On the console these calls are a few dozen instructions each (they write packets into a command buffer). Here they are much more: address lookups in shared maps, descriptor mirroring, state tracking, then the host call.

Proposal: record now, translate later, off the title's threads:

  1. Each list method appends a compact record (opcode plus the argument words, copied by value) to a per-list log. About 100 ns, no locks, no host calls.
  2. At Close (or at submission), worker threads translate the logs into host lists. Several lists translate in parallel; one list's log could also split at barriers.
  3. What must happen at call time stays at call time (anything that returns a value to the title, or reads title memory that may change before submission). The rest is deferred.

Why (measured, fxceless fork, RTX 4050 Laptop, Ryzen 7 7735HS, lit world)

  • 5 title threads each spend 150-180 ms a frame inside list calls, about 8,500 calls each: roughly 20 µs a call. On the console the same work is a few milliseconds a frame in total.
  • A sampling profile of those threads (an in-process sampler, diag build) shows mutex contention (descriptor::mirror into lock_contended), allocation, and, in diag builds with VICTORY_D3D12_DRED, string formatting for command notes (see #913).
  • During a frame about half of the 16 hardware threads are idle.

Even with no reduction in total work, moving it off the title's critical path and spreading it over idle cores should cut the title's frame time. Combined with reusing translated lists across frames (separate proposal), total work could drop too.

Open questions

  • Which list methods have observable side effects that must stay synchronous.
  • Descriptor-heap bytes the title writes between recording and submission: deferred translation must see the heap as the GPU would at execution, which is the console's behaviour.

No game data in this proposal.

**@⁠shawshanker18** on GitHub · 2026-11-25 16:18 UTC · [original](https://github.com/Marvisak/VIctory/issues/2586) ## Idea The title's render threads call the D3D12.X list methods, and the layer translates each call right there, on the title's thread. On the console these calls are a few dozen instructions each (they write packets into a command buffer). Here they are much more: address lookups in shared maps, descriptor mirroring, state tracking, then the host call. Proposal: **record now, translate later, off the title's threads**: 1. Each list method appends a compact record (opcode plus the argument words, copied by value) to a per-list log. About 100 ns, no locks, no host calls. 2. At `Close` (or at submission), worker threads translate the logs into host lists. Several lists translate in parallel; one list's log could also split at barriers. 3. What must happen at call time stays at call time (anything that returns a value to the title, or reads title memory that may change before submission). The rest is deferred. ## Why (measured, fxceless fork, RTX 4050 Laptop, Ryzen 7 7735HS, lit world) - 5 title threads each spend **150-180 ms a frame inside list calls**, about 8,500 calls each: roughly **20 µs a call**. On the console the same work is a few milliseconds a frame in total. - A sampling profile of those threads (an in-process sampler, diag build) shows mutex contention (`descriptor::mirror` into `lock_contended`), allocation, and, in diag builds with `VICTORY_D3D12_DRED`, string formatting for command notes (see #913). - During a frame about half of the 16 hardware threads are idle. Even with no reduction in total work, moving it off the title's critical path and spreading it over idle cores should cut the title's frame time. Combined with reusing translated lists across frames (separate proposal), total work could drop too. ## Open questions - Which list methods have observable side effects that must stay synchronous. - Descriptor-heap bytes the title writes between recording and submission: deferred translation must see the heap as the GPU would at execution, which is the console's behaviour. No game data in this proposal.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:47 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 18:46 UTC · original

Automated triage for the maintainers.

This is a performance proposal for the GPU layer: record command-list calls on the title's threads and translate them later on worker threads. It fits the project's scope, and it is labelled and kept as a request.

The timings quoted come from a fork, not from main. A per-call cost measured on main, along with the list of calls that must stay synchronous, would settle the open questions.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 18:46 UTC · [original](https://github.com/Marvisak/VIctory/issues/2586#issuecomment-7171377198) <!-- victory-issue-triage v1 verdict=tracked seen=2026-11-25T16:18:15Z at=2026-11-25T19:09:00Z --> Automated triage for the maintainers. This is a performance proposal for the GPU layer: record command-list calls on the title's threads and translate them later on worker threads. It fits the project's scope, and it is labelled and kept as a request. The timings quoted come from a fork, not from main. A per-call cost measured on main, along with the list of calls that must stay synchronous, would settle the open questions. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠KainanP on GitHub · 2026-11-26 14:49 UTC · original

Per-call cost on main (63bcca4), as the triage asked: every D3D12.X list method the title calls most, through the list's method table, on a host device.

Method. An #[ignore]d test, pipeline::list_bench, one commit on top of main: KainanP/VIctory@perf/list-call-bench (cargo test -p victory-gpu --release list_bench -- --ignored --nocapture). The setup is close to the title's:

  • title buffers in write-watched memory, a shader-visible title view heap of 4,096 slots, and eight 64×64 textures;
  • graphics pipelines whose translations read two root constant buffers, four root constants and a six-texture table, and a compute pipeline that reads a texture + raw UAV table and a root constant buffer. The host code reads nothing, so State::bind does all of its CPU work for those bindings.

Each row is the best of 5 × 20,000 calls, with lists closed and reset every 2,000 calls. The binary ran 7 times interleaved with other builds, and the table gives the median. Hardware: RTX 4060 Laptop GPU (driver 32.0.16.1047), Core i7-14650HX, Windows 11, release profile, idle machine. No game data.

method (older-layout slot) ns/call what dominates
SetGraphicsRootConstantBufferView (0x150) 24 with_state: two uncontended mutexes (segment list, draw state), then a Vec store. No host call.
SetGraphicsRootDescriptorTable (0x120) 24 same
SetGraphicsRoot32BitConstant(s) (0x130/0x140), SetComputeRoot32BitConstants (0x138) 22–23 same, plus a small Vec resize
IASetIndexBuffer / IASetVertexBuffers (0x178/0x180) 21–22 same
SetPipelineState (0xc8) 27 same. The host pipeline is bound at the next draw.
SetDescriptorHeaps (0x100) 21 same, plus one heap lookup
RSSetViewports / RSSetScissorRects (0xa8/0xb0) 50 / 56 the host call, plus a to_vec() allocation per call that keeps them for the next segment (Fixed)
ResourceBarrier, one texture transition (0xd0) 312 host lookup, a Vec per call, and the host ResourceBarrier (not split further)
ResourceBarrier, one buffer (0xd0) 198 buffer_bytes, a Vec, a host UAV barrier
DrawIndexedInstanced, nothing changed since the last draw (0x68) 2,713 the six table entries, ~320 ns each, ≈1.9 µs: resource::alias_source 120 (builds the texture's full console layout under TEXTURES_AT), list::ensure_state 70 (resource lock, two GetDesc, per-list state map), host copy lookups + title_written GetDesc + upload check ~85, HostHeap::mirror 43 (made + VIEWS locks). Three root constant buffers ≈ 3 × 45 (shadow::find under BUFFERS, a SipHash set insert). About 0.4 µs left over: user-data Vecs and the host calls (not split).
draw sequence: root CBV + 4 constants + index buffer + draw, per draw 2,780 the draw. The three setters add ~70 ns.
Dispatch (0x70), two-entry table + root CBV 855 the same per-entry work
ExecuteIndirect, one indexed draw (0x1d8) 4,660 a draw's bind, plus the argument refresh and the clamp dispatch recorded per call
ExecuteIndirect, one dispatch 2,899 the same
draw sequence on 5 threads at once, per draw per thread 10,526 (vs 2,780 on 1 thread) contention on the shared locks above: HostHeap::made, VIEWS, TEXTURES_AT, BUFFERS, and the per-resource host mutexes of textures all threads read

So on main a state-setting call is ~20–60 ns. The cost is in the draws, dispatches and indirect executions, through what each table entry does, and it grows about 3.8× when five threads record at once. Per call, averaged over the draw sequence: ~0.7 µs on one thread and ~2.6 µs per thread on five. The 20 µs a call in the proposal was measured on a fork, with the world's heaps (many more textures per draw, sync_heaps holding SHADER_HEAPS while title threads write views) and, in diag builds, command notes. None of that is modelled here.

Open PRs on the same path, same benchmark, each merged on main (median of 7 interleaved runs):

ns per draw main #1978 #3238 #2102 #2821 #3061 / #3005 / #2848 / #3215 #3258 (new) #1978+#2102+#2821+#3005+#3061 the same + #3258
DrawIndexedInstanced 2713 2046 1966 2663 2480 2571–2704 2047 1774 1132
draw sequence, 1 thread 2780 2118 2388 2640 2731 2738–2839 2186 1844 1236
draw sequence, 5 threads 10526 6664 6615 9897 8170 9316–10859 9831 4539 4537
Dispatch 855 733 708 835 828 819–851 748 627 522
ExecuteIndirect, indexed 4660 3893 3661 4611 4389 4518–4746 4120 3550 2835
  • #1978 and #3238 both stop alias_source from building the layout per texture view (120 → 14 ns). Merge one of them, not both.
  • #3238 also turns the list's refreshed-range set into a Vec with a linear contains. In the draw sequence each draw refreshes a new constant-ring position, so the scan grows with the list, and #3238's draw sequence (2388) costs more than its bare draw (1966). On main and on every other build the sequence adds ~70 ns over the bare draw. A frame's lists refresh thousands of ranges, so #1978's version of the alias_source change is the safer one.
  • #2821 halves HostHeap::mirror (43 → 18 ns) and is the one that pays off under five threads.
  • #3258 (opened now) takes the texture's host copy once per read and keeps its flags instead of calling GetDesc (ensure_state 70 → 35 ns). On one thread it adds ~600 ns per draw to any of the above. On five threads it should merge with or after #2821: on top of #1978 alone, five threads get slower, because with less work between them the threads queue on the remaining shared locks more.
  • #3061, #3005, #2848 and #3215 change nothing measurable here. Their paths (capped heaps, the first-use exchange, copy-back and heap sync, submission) aren't exercised.

Calls that must stay synchronous (for the record-now/translate-later design; #3184 implements it behind VICTORY_DEFER_LISTS): the ones that return something the title reads (QueryInterface, Release, GetType 0x40, the upload allocation 0x4a0, the driver hint 0x318). Reset/ResetX/last Release must first drain the log, since they free what the logged calls read. Everything else returns nothing or a constant (ResourceBarrier returns 0) and can be logged, as long as what its pointers name is copied at the call (viewports, scissors, barriers, root constant arrays, vertex/index views, target handles, clear values, copy locations, rectangles). Today descriptor-table contents are read when a draw is translated, which is at the call, and title buffers are read at submission. Deferring translation moves the descriptor read later, closer to when the console's GPU reads them.

AI use: Claude Code (Claude Opus 5.5) wrote the benchmark, ran the measurements and drafted this comment.

**@⁠KainanP** on GitHub · 2026-11-26 14:49 UTC · [original](https://github.com/Marvisak/VIctory/issues/2586#issuecomment-7195391455) Per-call cost on **main** (63bcca4), as the triage asked: every D3D12.X list method the title calls most, through the list's method table, on a host device. **Method.** An `#[ignore]`d test, `pipeline::list_bench`, one commit on top of main: [KainanP/VIctory@perf/list-call-bench](https://github.com/KainanP/VIctory/tree/perf/list-call-bench) (`cargo test -p victory-gpu --release list_bench -- --ignored --nocapture`). The setup is close to the title's: - title buffers in write-watched memory, a shader-visible title view heap of 4,096 slots, and eight 64×64 textures; - graphics pipelines whose translations read two root constant buffers, four root constants and a six-texture table, and a compute pipeline that reads a texture + raw UAV table and a root constant buffer. The host code reads nothing, so `State::bind` does all of its CPU work for those bindings. Each row is the best of 5 × 20,000 calls, with lists closed and reset every 2,000 calls. The binary ran 7 times interleaved with other builds, and the table gives the median. Hardware: RTX 4060 Laptop GPU (driver 32.0.16.1047), Core i7-14650HX, Windows 11, release profile, idle machine. No game data. | method (older-layout slot) | ns/call | what dominates | |---|---:|---| | `SetGraphicsRootConstantBufferView` (0x150) | 24 | `with_state`: two uncontended mutexes (segment list, draw state), then a `Vec` store. No host call. | | `SetGraphicsRootDescriptorTable` (0x120) | 24 | same | | `SetGraphicsRoot32BitConstant(s)` (0x130/0x140), `SetComputeRoot32BitConstants` (0x138) | 22–23 | same, plus a small `Vec` resize | | `IASetIndexBuffer` / `IASetVertexBuffers` (0x178/0x180) | 21–22 | same | | `SetPipelineState` (0xc8) | 27 | same. The host pipeline is bound at the next draw. | | `SetDescriptorHeaps` (0x100) | 21 | same, plus one heap lookup | | `RSSetViewports` / `RSSetScissorRects` (0xa8/0xb0) | 50 / 56 | the host call, plus a `to_vec()` allocation per call that keeps them for the next segment (`Fixed`) | | `ResourceBarrier`, one texture transition (0xd0) | 312 | host lookup, a `Vec` per call, and the host `ResourceBarrier` (not split further) | | `ResourceBarrier`, one buffer (0xd0) | 198 | `buffer_bytes`, a `Vec`, a host UAV barrier | | **`DrawIndexedInstanced`**, nothing changed since the last draw (0x68) | **2,713** | the six table entries, ~320 ns each, ≈1.9 µs: `resource::alias_source` 120 (builds the texture's full console layout under `TEXTURES_AT`), `list::ensure_state` 70 (resource lock, two `GetDesc`, per-list state map), host copy lookups + `title_written` `GetDesc` + upload check ~85, `HostHeap::mirror` 43 (`made` + `VIEWS` locks). Three root constant buffers ≈ 3 × 45 (`shadow::find` under `BUFFERS`, a SipHash set insert). About 0.4 µs left over: user-data `Vec`s and the host calls (not split). | | draw sequence: root CBV + 4 constants + index buffer + draw, per draw | 2,780 | the draw. The three setters add ~70 ns. | | `Dispatch` (0x70), two-entry table + root CBV | 855 | the same per-entry work | | `ExecuteIndirect`, one indexed draw (0x1d8) | 4,660 | a draw's bind, plus the argument refresh and the clamp dispatch recorded per call | | `ExecuteIndirect`, one dispatch | 2,899 | the same | | **draw sequence on 5 threads at once**, per draw per thread | **10,526** (vs 2,780 on 1 thread) | contention on the shared locks above: `HostHeap::made`, `VIEWS`, `TEXTURES_AT`, `BUFFERS`, and the per-resource `host` mutexes of textures all threads read | So on main a state-setting call is ~20–60 ns. The cost is in the draws, dispatches and indirect executions, through what each table entry does, and it grows about 3.8× when five threads record at once. Per call, averaged over the draw sequence: ~0.7 µs on one thread and ~2.6 µs per thread on five. The 20 µs a call in the proposal was measured on a fork, with the world's heaps (many more textures per draw, `sync_heaps` holding `SHADER_HEAPS` while title threads write views) and, in diag builds, command notes. None of that is modelled here. **Open PRs on the same path**, same benchmark, each merged on main (median of 7 interleaved runs): | ns per draw | main | #1978 | #3238 | #2102 | #2821 | #3061 / #3005 / #2848 / #3215 | #3258 (new) | #1978+#2102+#2821+#3005+#3061 | the same + #3258 | |---|---:|---:|---:|---:|---:|---:|---:|---:|---:| | `DrawIndexedInstanced` | 2713 | 2046 | 1966 | 2663 | 2480 | 2571–2704 | 2047 | 1774 | **1132** | | draw sequence, 1 thread | 2780 | 2118 | 2388 | 2640 | 2731 | 2738–2839 | 2186 | 1844 | **1236** | | draw sequence, 5 threads | 10526 | 6664 | 6615 | 9897 | 8170 | 9316–10859 | 9831 | 4539 | **4537** | | `Dispatch` | 855 | 733 | 708 | 835 | 828 | 819–851 | 748 | 627 | **522** | | `ExecuteIndirect`, indexed | 4660 | 3893 | 3661 | 4611 | 4389 | 4518–4746 | 4120 | 3550 | **2835** | - #1978 and #3238 both stop `alias_source` from building the layout per texture view (120 → 14 ns). Merge one of them, not both. - #3238 also turns the list's refreshed-range set into a `Vec` with a linear `contains`. In the draw sequence each draw refreshes a new constant-ring position, so the scan grows with the list, and #3238's draw sequence (2388) costs more than its bare draw (1966). On main and on every other build the sequence adds ~70 ns over the bare draw. A frame's lists refresh thousands of ranges, so #1978's version of the `alias_source` change is the safer one. - #2821 halves `HostHeap::mirror` (43 → 18 ns) and is the one that pays off under five threads. - #3258 (opened now) takes the texture's host copy once per read and keeps its flags instead of calling `GetDesc` (`ensure_state` 70 → 35 ns). On one thread it adds ~600 ns per draw to any of the above. On five threads it should merge with or after #2821: on top of #1978 alone, five threads get slower, because with less work between them the threads queue on the remaining shared locks more. - #3061, #3005, #2848 and #3215 change nothing measurable here. Their paths (capped heaps, the first-use exchange, copy-back and heap sync, submission) aren't exercised. **Calls that must stay synchronous** (for the record-now/translate-later design; #3184 implements it behind `VICTORY_DEFER_LISTS`): the ones that return something the title reads (`QueryInterface`, `Release`, `GetType` 0x40, the upload allocation 0x4a0, the driver hint 0x318). `Reset`/`ResetX`/last `Release` must first drain the log, since they free what the logged calls read. Everything else returns nothing or a constant (`ResourceBarrier` returns 0) and can be logged, as long as what its pointers name is copied at the call (viewports, scissors, barriers, root constant arrays, vertex/index views, target handles, clear values, copy locations, rectangles). Today descriptor-table contents are read when a draw is translated, which is at the call, and title buffers are read at submission. Deferring translation moves the descriptor read later, closer to when the console's GPU reads them. _AI use: Claude Code (Claude Opus 5.5) wrote the benchmark, ran the measurements and drafted this comment._
Author
Owner

@⁠KainanP on GitHub · 2026-11-26 15:27 UTC · original

Update on the 5-thread scaling from my last comment (7195391455).

I profiled the draw sequence on five threads with per-call-site lock counters, on main + #1978 + #2821 + #3258. The most contended lock was TEXTURES_AT in alias_source: it's taken six times per draw, and another thread held it on 36% of those takes. After it came descriptor::VIEWS (taken in view_at), each texture's host mutex, and shadow::BUFFERS. HostHeap::made isn't on this path because the slots are already made. Two PRs remove the first two from the read path:

  • #3274: a texture with no GPU writer at its memory keeps that answer, checked against a per-bucket change count, so its reads skip the lock.
  • #3275: each recording thread keeps the views it looked up, checked against lock-free per-entry generations.

Draw sequence (list_bench, VICTORY_LIST_BENCH_SCALING=1), ns per draw per thread, medians of 7 interleaved runs, RTX 4060 Laptop + i7-14650HX:

tree 1 thread 5 threads 5 / 1
main 3144 12119 3.85×
main + #1978 + #2821 + #3258 1559 5100 3.27×
the same + #3274 1430 2895 2.02×
the same + #3274 + #3275 1426 2824 1.98×

#3274 alone on main: 3144 → 2325 on one thread and 12119 → 7836 on five. What's left on five threads is mostly the shared Arc count of each texture's host copy and shadow::BUFFERS. None of this has been measured in a game yet. An A/B of #3274 (with #2821) in a title that records on several threads would be the useful next number.

**@⁠KainanP** on GitHub · 2026-11-26 15:27 UTC · [original](https://github.com/Marvisak/VIctory/issues/2586#issuecomment-7196282096) Update on the 5-thread scaling from my last comment (7195391455). I profiled the draw sequence on five threads with per-call-site lock counters, on main + #1978 + #2821 + #3258. The most contended lock was `TEXTURES_AT` in `alias_source`: it's taken six times per draw, and another thread held it on 36% of those takes. After it came `descriptor::VIEWS` (taken in `view_at`), each texture's `host` mutex, and `shadow::BUFFERS`. `HostHeap::made` isn't on this path because the slots are already made. Two PRs remove the first two from the read path: - #3274: a texture with no GPU writer at its memory keeps that answer, checked against a per-bucket change count, so its reads skip the lock. - #3275: each recording thread keeps the views it looked up, checked against lock-free per-entry generations. Draw sequence (`list_bench`, `VICTORY_LIST_BENCH_SCALING=1`), ns per draw per thread, medians of 7 interleaved runs, RTX 4060 Laptop + i7-14650HX: | tree | 1 thread | 5 threads | 5 / 1 | |---|---:|---:|---:| | main | 3144 | 12119 | 3.85× | | main + #1978 + #2821 + #3258 | 1559 | 5100 | 3.27× | | the same + #3274 | 1430 | 2895 | 2.02× | | the same + #3274 + #3275 | 1426 | 2824 | 1.98× | #3274 alone on main: 3144 → 2325 on one thread and 12119 → 7836 on five. What's left on five threads is mostly the shared `Arc` count of each texture's host copy and `shadow::BUFFERS`. None of this has been measured in a game yet. An A/B of #3274 (with #2821) in a title that records on several threads would be the useful next number.
Author
Owner

@⁠KainanP on GitHub · 2026-11-26 16:26 UTC · original

Follow-up to the per-call table (7195391455) and the scaling note (7196282096). Same bench and machine: RTX 4060 Laptop, i7-14650HX, release, builds interleaved, median of 7 runs. Four unrelated Python jobs were using the CPU throughout.

1. ExecuteIndirect (4.7 µs on main). I benchmarked the two open PRs that batch the per-call argument clamp. The bench branch now has VICTORY_LIST_BENCH_INDIRECT=1, which runs indirect draws and dispatches on 1 and 5 threads, with the list's close and the submission prelude timed. Full tables are on #2472 (7197569095) and #3197 (7197569697). Indexed draw, ns per call:

main + #2472 + #3197 (VICTORY_CLAMP_WINDOW=1)
1 thread 4,870 3,212 3,186
1 thread, on main + #1978 + #2821 + #3258 + #3274 + #3275 3,260 1,449 1,449
5 threads, same stack 4,345 2,742 2,687

On the CPU, both PRs remove the same ~1.8 µs per indirect draw. This bench is the best case for both: the list only has non-writing indirect draws. What separates them is how much of a real frame each covers, and their GPU time, and I measured neither. Neither PR touches indirect dispatches (3.0 µs vs 0.86 µs for a plain Dispatch). I found no open PR for those. Both pass their tests on RTX 4060, Intel UHD and WARP, with the same failures as on main.

2. RSSetViewports / RSSetScissorRects / ResourceBarrier per-call Vecs. No open PR removed these, so I opened #3297. It reuses the kept Vec, and barriers go into a stack array. ns per call: viewports 50 → 23, scissors 56 → 28, barrier on a texture 312 → 262, barrier on a buffer 191 → 145. #3297 overlaps #3176 and #3129 on the same lines, and its description says how to combine them.

3. BUFFERS reads left after #3274/#3275. As an experiment, I put a thread-local cache in front of shadow::find on main + #1978 + #2821 + #3258 + #3274 + #3275. The cache holds the last few buffers found, validated by a generation counter bumped on every register/unregister/copy made. Draw sequence, ns per draw:

1 thread 5 threads (per thread)
stack 1,351 [1,271–1,708] 2,485 [2,427–2,597]
+ find cache 1,242 [1,197–1,286] 1,894 [1,829–1,954]

That is −24% on five threads, with the Arc<Shadow> clone still paid on every hit. The experiment isn't a fix as written. It cached a buffer's whole range without checking for buffers nested inside it, and it held Arcs in thread-locals. #1356 (wbkepler) already does this properly: a per-list cache validated by a buffer-table generation, with a CachedRange that is only as wide as no other buffer intrudes. But #1356 needs a rebase (BUFFERS is a Mutex on main, an RwLock with #2821, and #2096 restructures it). Splitting that cache out of #1356 and rebasing it looks like the next clear win for the title's threads, so I haven't opened a competing PR. I didn't measure the per-texture Arc count on the host copy separately.

AI use: Claude Code (Claude Opus 5.5) ran the measurements and drafted this comment.

**@⁠KainanP** on GitHub · 2026-11-26 16:26 UTC · [original](https://github.com/Marvisak/VIctory/issues/2586#issuecomment-7197644545) Follow-up to the per-call table (7195391455) and the scaling note (7196282096). Same bench and machine: RTX 4060 Laptop, i7-14650HX, release, builds interleaved, median of 7 runs. Four unrelated Python jobs were using the CPU throughout. **1. `ExecuteIndirect` (4.7 µs on main).** I benchmarked the two open PRs that batch the per-call argument clamp. The bench branch now has `VICTORY_LIST_BENCH_INDIRECT=1`, which runs indirect draws and dispatches on 1 and 5 threads, with the list's close and the submission prelude timed. Full tables are on #2472 (7197569095) and #3197 (7197569697). Indexed draw, ns per call: | | main | + #2472 | + #3197 (`VICTORY_CLAMP_WINDOW=1`) | |---|---:|---:|---:| | 1 thread | 4,870 | 3,212 | 3,186 | | 1 thread, on main + #1978 + #2821 + #3258 + #3274 + #3275 | 3,260 | 1,449 | 1,449 | | 5 threads, same stack | 4,345 | 2,742 | 2,687 | On the CPU, both PRs remove the same ~1.8 µs per indirect draw. This bench is the best case for both: the list only has non-writing indirect draws. What separates them is how much of a real frame each covers, and their GPU time, and I measured neither. Neither PR touches indirect dispatches (3.0 µs vs 0.86 µs for a plain `Dispatch`). I found no open PR for those. Both pass their tests on RTX 4060, Intel UHD and WARP, with the same failures as on main. **2. `RSSetViewports` / `RSSetScissorRects` / `ResourceBarrier` per-call `Vec`s.** No open PR removed these, so I opened #3297. It reuses the kept `Vec`, and barriers go into a stack array. ns per call: viewports 50 → 23, scissors 56 → 28, barrier on a texture 312 → 262, barrier on a buffer 191 → 145. #3297 overlaps #3176 and #3129 on the same lines, and its description says how to combine them. **3. `BUFFERS` reads left after #3274/#3275.** As an experiment, I put a thread-local cache in front of `shadow::find` on main + #1978 + #2821 + #3258 + #3274 + #3275. The cache holds the last few buffers found, validated by a generation counter bumped on every register/unregister/copy made. Draw sequence, ns per draw: | | 1 thread | 5 threads (per thread) | |---|---:|---:| | stack | 1,351 [1,271–1,708] | 2,485 [2,427–2,597] | | + `find` cache | 1,242 [1,197–1,286] | **1,894** [1,829–1,954] | That is −24% on five threads, with the `Arc<Shadow>` clone still paid on every hit. The experiment isn't a fix as written. It cached a buffer's whole range without checking for buffers nested inside it, and it held `Arc`s in thread-locals. #1356 (wbkepler) already does this properly: a per-list cache validated by a buffer-table generation, with a `CachedRange` that is only as wide as no other buffer intrudes. But #1356 needs a rebase (`BUFFERS` is a `Mutex` on main, an `RwLock` with #2821, and #2096 restructures it). Splitting that cache out of #1356 and rebasing it looks like the next clear win for the title's threads, so I haven't opened a competing PR. I didn't measure the per-texture `Arc` count on the host copy separately. _AI use: Claude Code (Claude Opus 5.5) ran the measurements and drafted this comment._
This discussion has been locked. Commenting is limited to contributors.
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#2586
No description provided.