List translation: a bench of a frame's list calls, a draw's retirements under one lock, per-thread draw counts, dropped draws by reason #2006

Closed
binarycleric wants to merge 6 commits from upstream-pr/2006 into main
binarycleric commented 2026-11-29 07:07:22 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by binarycleric on 2026-11-29T07:07:22Z.


What it changes

Why

Turning the title's list calls into D3D12 calls costs about 6.2 µs a call in
play logs of 2026-11-28: about 280 ms of CPU a frame across the eight
threads that do it. Those are the title's own recording threads, or with
VICTORY_THIN=1 our victory-list-* threads, whose work the submissions
then wait for. There was no way to measure that cost outside a play run, and
no profile of where it goes.

The 5-second line also put every dropped draw under "without a host
pipeline". That was 300 to 1,400 draws a frame, and nobody could tell
missing pipelines from draws that failed to bind.

What

Commits 1, 2, 4: a bench of the list calls (list/bench.rs, #[ignore])

  • What it runs: eight threads record 25 lists of 30 draws each a frame
    (about 23,500 calls) through the same list::state calls as a translating
    thread.
  • Pipelines: the title's own, the first 160 of early-pipelines.txt,
    made from an earlier run's known-pipelines.bin and known-shaders.bin
    (pipeline/known.rs bench_pipelines).
  • Tables: they hold what the shaders read:
    • textures, three in four of them views of title-placed memory;
    • raw buffer views over 512 buffers;
    • constant buffers and samplers.
  • Per draw: root constants, root views, and vertex and index buffers from
    a mesh pool; each thread has its own render targets and depth target.
  • Timing: each frame's lists are submitted afterwards, untimed, so
    textures upload once, as in a run. The bench prints ns and cycles per call
    (QueryThreadCycleTime), CPU ms and wall ms a frame.
  • VICTORY_BENCH_PROFILE=1: samples the threads every quarter
    millisecond (suspend, RtlVirtualUnwind, dbghelp with inline frames; no
    admin rights needed) and prints where they were.
  • VICTORY_BENCH_AB=<switch>,..: turns toggled! switches off and on
    frame by frame in one run and prints the median on/off ratio of 30 frame
    pairs.
    • Why: between separate runs, the numbers moved 30 % and more with the
      machine's other load.
    • In test builds without diagnostics, toggled! checks this variable
      once. Other builds are unchanged.
  • Run:
    VICTORY_BENCH_CACHE=<copy of the cache folder's pipelines\ and shaders\> cargo test --release -p victory-gpu --lib list::bench -- --ignored --nocapture --test-threads=1
    
    Use a copy, because the bench writes to its shaders folder.

Profile (bench, 8 threads, before the changes below)

  • About 45–50 %: fresh (constant buffer) tables: make_listed /
    make_null → HostHeap::keep → retire_resource, plus the driver's
    descriptor calls. retire_resource alone was 14.6 %, nearly all of it
    waiting for the RETIRED lock.
  • 15–20 %: texture work (readable, upload_from with texture::staging's
    STAGING lock, hosted, transition).
  • 11 %: placed_texture.
  • About 3 %: views_read; 3–5 %: shadow::lookup / find_any.

Commit 3: a draw's retirements go to the shared line in one go (VICTORY_RETIRE_BATCH, on)

  • Before: a fresh table retires what each of its dynamic slots showed
    before, about 20,000 resources a frame. Each was pushed onto RETIRED
    under its lock and counted in a shared atomic, by all eight threads.
  • Now: State::tables holds a host::Retiring, during which
    retire_resource keeps each object, with the submission count it was
    retired at, in a thread-local list. At the end the list goes onto
    RETIRED under one lock, with one atomic add.
  • Lifetimes: no object is dropped earlier than before, since its count
    is the same; at worst it waits one more bury.
  • Nesting and fallback: a nested Retiring leaves its objects to the
    outer one. If the thread's local storage is gone, the object goes straight
    to the line.
  • VICTORY_RETIRE_BATCH=0 retires one object at a time, as before.

Commit 5: draw counts per thread (VICTORY_SPREAD_COUNTS, on)

  • Before: every draw added to two or three atomics shared by the whole
    process (DRAWS, DRAWS_EVER, then DRAWN, DROPPED or DISPATCHED).
    Their cache lines moved between cores with every draw.
  • Now (counts.rs): each thread has its own counters, on lines of their
    own, written only by that thread with a plain load and store.
    • total() sums every thread's counters, including threads that have
      ended.
    • take() replaces the old swap with 0.
    • The readers are the frame lines, the warm-up watcher and the panel, at
      most once per present.
  • VICTORY_SPREAD_COUNTS=0 goes back to the shared atomics. Non-Windows
    builds keep the old statics.

Commit 6: dropped draws counted by reason

  • Each drop now also counts under one reason:
    • left out on purpose: the pipeline's left_out, the structure
      builder while it is off, or a pipeline skipped in diagnostics builds;
    • no host pipeline: being made, or refused;
    • could not be bound: the pipeline exists, but prepare() or bind()
      refused (no free table slots, a root SRV without a view, an index buffer
      not found, the wrong kind of pipeline).
  • pipeline::host_missing() tells these apart without waiting for the
    pipeline, and it runs only for a dropped draw.
  • The line now reads "dropped N (A without a host pipeline, M being made; B
    that could not be bound; C left out on purpose)".
  • It changes no behaviour, so it has no switch.

Measurements

All from the bench, with frames alternating off and on in one run. Each
figure is the median of 30 pair ratios (on/off), and below 1 is better.
Other sessions loaded the machine throughout.

Change Cycles per call Thread time per call
Retire batching (3 runs) 1.000, 0.951, 0.896 0.997, 0.926, 0.885
Per-thread counts (2 runs) 0.967, 0.972 0.971, 1.023
Both together (2 runs) 0.862, 0.932 0.875, 0.930
  • With both on, a call went from 5.7–5.8 µs to 5.1–5.4 µs.
  • Retire batching gained most on the quietest run (31 ms frames): from
    7.2 µs to 6.2 µs a call.
  • The bench ran at about 7.5 µs a call before the changes, against 6.2 µs in
    play.

Not tried in play. None of this has run in the game yet: every number
above is from the bench. Both behaviour changes can be turned off
(VICTORY_RETIRE_BATCH=0, VICTORY_SPREAD_COUNTS=0).

Tried and left out, because the bench measured no gain:

  • a per-list cache of texture lookups: cycles 1.05–1.09, then 1.01–1.02
    after a rework;
  • a faster hash for byte keys: cycles 0.96–1.00, thread time 0.96–1.04.

Leads not taken here

These are all in the fresh-table path:

  • the COM reference each dynamic slot takes on the resource it shows;
  • the global STAGING lock, taken per texture on a list's first use (about
    6 %);
  • State::fresh_tables starting empty in every list (2–7 %).

How it was tested

  • GPU and profile: RTX 5070 Ti 16 GB, Ryzen 9 7900X; Series X profile, 1440p native, DLSS off, frame generation off; ray-tracing passes left out (no structure builder) (play numbers), plus the list-call bench (above)
  • Before: in play before these commits, about 44,850 list calls a frame in about 280 ms on all threads (6.2 µs each)
  • After: in play with them, 32,700–34,300 calls a frame in 173–174 ms on all threads (about 5.2 µs each) at 26–28 fps; dropped draws now say why ("0 without a host pipeline, 0 being made; 0 that could not be bound; 462 left out on purpose"). Different builds and scenes, so the bench numbers above are the measurement of this PR
  • cargo test passed for the crates it touches: yes. Rebased onto main e1f2eb60: cargo test --release -p victory-gpu --lib, 592 passed, 0 failed, 45 ignored

Tests

  • host::retiring_tests:
    • inside a Retiring, objects are kept alive by the thread, with counts
      no later than when retired;
    • a nested Retiring leaves them to the outer one;
    • at the end they are in the line, still alive;
    • outside a Retiring, they go to the line at once.
  • counts::tests: eight threads' adds all count; take gives what came
    since the last take.
  • draw::dropped_tests: each drop counts in the total and under its reason.
  • list::bench is #[ignore]d: it needs an earlier run's cache folder.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1735 (counts repeated lists and draws in the thin path; different counters). Nothing else found for the draw retirements or the drop reasons.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5548502506 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2006). Originally posted by [binarycleric](https://github.com/binarycleric) on 2026-11-29T07:07:22Z. --- ## What it changes ### Why Turning the title's list calls into D3D12 calls costs about 6.2 µs a call in play logs of 2026-11-28: about 280 ms of CPU a frame across the eight threads that do it. Those are the title's own recording threads, or with `VICTORY_THIN=1` our `victory-list-*` threads, whose work the submissions then wait for. There was no way to measure that cost outside a play run, and no profile of where it goes. The 5-second line also put every dropped draw under "without a host pipeline". That was 300 to 1,400 draws a frame, and nobody could tell missing pipelines from draws that failed to bind. ### What **Commits 1, 2, 4: a bench of the list calls** (`list/bench.rs`, `#[ignore]`) - **What it runs:** eight threads record 25 lists of 30 draws each a frame (about 23,500 calls) through the same `list::state` calls as a translating thread. - **Pipelines:** the title's own, the first 160 of `early-pipelines.txt`, made from an earlier run's `known-pipelines.bin` and `known-shaders.bin` (`pipeline/known.rs` `bench_pipelines`). - **Tables:** they hold what the shaders read: - textures, three in four of them views of title-placed memory; - raw buffer views over 512 buffers; - constant buffers and samplers. - **Per draw:** root constants, root views, and vertex and index buffers from a mesh pool; each thread has its own render targets and depth target. - **Timing:** each frame's lists are submitted afterwards, untimed, so textures upload once, as in a run. The bench prints ns and cycles per call (`QueryThreadCycleTime`), CPU ms and wall ms a frame. - **`VICTORY_BENCH_PROFILE=1`:** samples the threads every quarter millisecond (suspend, `RtlVirtualUnwind`, dbghelp with inline frames; no admin rights needed) and prints where they were. - **`VICTORY_BENCH_AB=<switch>,..`:** turns `toggled!` switches off and on frame by frame in one run and prints the median on/off ratio of 30 frame pairs. - Why: between separate runs, the numbers moved 30 % and more with the machine's other load. - In test builds without `diagnostics`, `toggled!` checks this variable once. Other builds are unchanged. - **Run:** ``` VICTORY_BENCH_CACHE=<copy of the cache folder's pipelines\ and shaders\> cargo test --release -p victory-gpu --lib list::bench -- --ignored --nocapture --test-threads=1 ``` Use a copy, because the bench writes to its `shaders` folder. ### Profile (bench, 8 threads, before the changes below) - About 45–50 %: fresh (constant buffer) tables: `make_listed` / `make_null` → `HostHeap::keep` → `retire_resource`, plus the driver's descriptor calls. `retire_resource` alone was 14.6 %, nearly all of it waiting for the `RETIRED` lock. - 15–20 %: texture work (`readable`, `upload_from` with `texture::staging`'s `STAGING` lock, `hosted`, `transition`). - 11 %: `placed_texture`. - About 3 %: `views_read`; 3–5 %: `shadow::lookup` / `find_any`. **Commit 3: a draw's retirements go to the shared line in one go** (`VICTORY_RETIRE_BATCH`, on) - **Before:** a fresh table retires what each of its dynamic slots showed before, about 20,000 resources a frame. Each was pushed onto `RETIRED` under its lock and counted in a shared atomic, by all eight threads. - **Now:** `State::tables` holds a `host::Retiring`, during which `retire_resource` keeps each object, with the submission count it was retired at, in a thread-local list. At the end the list goes onto `RETIRED` under one lock, with one atomic add. - **Lifetimes:** no object is dropped earlier than before, since its count is the same; at worst it waits one more bury. - **Nesting and fallback:** a nested `Retiring` leaves its objects to the outer one. If the thread's local storage is gone, the object goes straight to the line. - `VICTORY_RETIRE_BATCH=0` retires one object at a time, as before. **Commit 5: draw counts per thread** (`VICTORY_SPREAD_COUNTS`, on) - **Before:** every draw added to two or three atomics shared by the whole process (`DRAWS`, `DRAWS_EVER`, then `DRAWN`, `DROPPED` or `DISPATCHED`). Their cache lines moved between cores with every draw. - **Now** (`counts.rs`): each thread has its own counters, on lines of their own, written only by that thread with a plain load and store. - `total()` sums every thread's counters, including threads that have ended. - `take()` replaces the old swap with 0. - The readers are the frame lines, the warm-up watcher and the panel, at most once per present. - `VICTORY_SPREAD_COUNTS=0` goes back to the shared atomics. Non-Windows builds keep the old statics. ### Commit 6: dropped draws counted by reason - Each drop now also counts under one reason: - **left out on purpose:** the pipeline's `left_out`, the structure builder while it is off, or a pipeline skipped in diagnostics builds; - **no host pipeline:** being made, or refused; - **could not be bound:** the pipeline exists, but `prepare()` or `bind()` refused (no free table slots, a root SRV without a view, an index buffer not found, the wrong kind of pipeline). - `pipeline::host_missing()` tells these apart without waiting for the pipeline, and it runs only for a dropped draw. - The line now reads "dropped N (A without a host pipeline, M being made; B that could not be bound; C left out on purpose)". - It changes no behaviour, so it has no switch. ### Measurements All from the bench, with frames alternating off and on in one run. Each figure is the median of 30 pair ratios (on/off), and below 1 is better. Other sessions loaded the machine throughout. | Change | Cycles per call | Thread time per call | |---|---|---| | Retire batching (3 runs) | 1.000, 0.951, 0.896 | 0.997, 0.926, 0.885 | | Per-thread counts (2 runs) | 0.967, 0.972 | 0.971, 1.023 | | Both together (2 runs) | **0.862, 0.932** | **0.875, 0.930** | - With both on, a call went from 5.7–5.8 µs to 5.1–5.4 µs. - Retire batching gained most on the quietest run (31 ms frames): from 7.2 µs to 6.2 µs a call. - The bench ran at about 7.5 µs a call before the changes, against 6.2 µs in play. **Not tried in play.** None of this has run in the game yet: every number above is from the bench. Both behaviour changes can be turned off (`VICTORY_RETIRE_BATCH=0`, `VICTORY_SPREAD_COUNTS=0`). Tried and left out, because the bench measured no gain: - a per-list cache of texture lookups: cycles 1.05–1.09, then 1.01–1.02 after a rework; - a faster hash for byte keys: cycles 0.96–1.00, thread time 0.96–1.04. ### Leads not taken here These are all in the fresh-table path: - the COM reference each dynamic slot takes on the resource it shows; - the global `STAGING` lock, taken per texture on a list's first use (about 6 %); - `State::fresh_tables` starting empty in every list (2–7 %). ## How it was tested - GPU and profile: RTX 5070 Ti 16 GB, Ryzen 9 7900X; Series X profile, 1440p native, DLSS off, frame generation off; ray-tracing passes left out (no structure builder) (play numbers), plus the list-call bench (above) - Before: in play before these commits, about 44,850 list calls a frame in about 280 ms on all threads (6.2 µs each) - After: in play with them, 32,700–34,300 calls a frame in 173–174 ms on all threads (about 5.2 µs each) at 26–28 fps; dropped draws now say why ("0 without a host pipeline, 0 being made; 0 that could not be bound; 462 left out on purpose"). Different builds and scenes, so the bench numbers above are the measurement of this PR - `cargo test` passed for the crates it touches: yes. Rebased onto main e1f2eb60: `cargo test --release -p victory-gpu --lib`, 592 passed, 0 failed, 45 ignored ### Tests - `host::retiring_tests`: - inside a `Retiring`, objects are kept alive by the thread, with counts no later than when retired; - a nested `Retiring` leaves them to the outer one; - at the end they are in the line, still alive; - outside a `Retiring`, they go to the line at once. - `counts::tests`: eight threads' adds all count; `take` gives what came since the last take. - `draw::dropped_tests`: each drop counts in the total and under its reason. - `list::bench` is `#[ignore]`d: it needs an earlier run's cache folder. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1735 (counts repeated lists and draws in the thin path; different counters). Nothing else found for the draw retirements or the drop reasons.

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