Perf: retire in batches per thread, and skip decoding declared constant buffers #3565

Closed
github-bot wants to merge 11 commits from github-bot/gh-3565 into main AGit
Owner

@⁠Monard2033 on GitHub · 2026-11-30 01:08 UTC · original
Monard2033:main → main · +822 −829 · 33 files · 11 commits · closed without merging

Fixes: no issue (found while profiling the list translation on my machine)

What it changes

Retirements in batches. The resources of descriptor slots let go by
make_listed's keep -- hundreds of thousands a second -- went to the retired
queue with one lock per object, and that was 15% of the list translation's
processor time. A thread now keeps up to RETIRE_BATCH (256) of them and moves
them into its shard in one go:

  • when the batch fills;
  • at bury(), which publishes the calling thread's batch first, so nothing it
    holds can outlive a drain that should have freed it;
  • at the end of each translated chunk (list/thin.rs), where a listing job's
    work ends.

bury() still drops a retirement only after the last submission that may use
it: objects are freed a little later than they could be, and never earlier.

Declared constant buffers are no longer decoded twice. tables() decoded
every slot of every table three times when the slot was a constant buffer its
plan declares as one: record_at, then make_listed (which answers none for
View::Constant and keeps nothing), then descriptor::view. The declared CBVs
now go straight to the constants path. No state is touched: it is the same path
the code took once make_listed answered none.

How it was tested

  • GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing):
    NVIDIA GeForce RTX 5080 Laptop GPU; Intel Core Ultra 9 275HX (24 threads, 8 P +
    16 E); Windows 11. Series X profile (console=series-x), 1080to1440 (scene
    1920x1080, upscaled by DLSS), DLSS quality, frame generation 2x, ray tracing off
    (this build leaves the title's RT passes out).

  • Before / After: thread-local rdtsc counters on an instrumented local build (the
    counters are not part of this PR), same scene, 90 s in the world, 8 translating
    threads:

    counter before after
    a retirement (l_retire) 0.55 us 0.07 us
    l_retire, share of the translation's CPU 15.4% 1.9%
    make_listed's keep 0.755 us 0.323 us per slot
    declared-CBV decodes, share of the translation's CPU 2% 0
    make_listed calls 172 M / 90 s 164 M / 90 s
    cold view creations (l_lookup cold) 89.7 M / 90 s 64.7 M / 90 s

    Gameplay A/B at matched draw counts (the idle camera drifts, so runs are
    compared at the same draws): at ~7.3k draws the difference is inside the noise
    (+/-2 ms of a ~53 ms frame), which is what a change to the translating threads
    should show there. It shows in heavy scenes: at 10-11k draws the translating
    threads run 89-94% occupied and the title's record calls are 13 + 4 ms of the
    frame's critical chain, and that is where the earlier cuts of the same kind
    moved the frame rate.

  • For shader changes, the wave sizes tested (32 and/or 64 lanes): not a shader
    change.

  • cargo test passed for the crates it touches: yes for victory-gpu (920
    tests; the 2 failures in this environment reproduce on 41adb551 without the
    patch -- one is the translator-switch test, the other is a flake that passes
    3/3 run alone). cargo clippy -p victory-gpu --all-targets: no warnings in the
    touched files.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this
    touches. Related: none open on these paths -- the ones merged for 29.05
    (#2607, #2116, #2509, #2530, #2854, #2814, #2971, #2795, #2834) are already in
    this base.
**@⁠Monard2033** on GitHub · 2026-11-30 01:08 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3565) `Monard2033:main` → `main` · +822 −829 · 33 files · 11 commits · closed without merging Fixes: no issue (found while profiling the list translation on my machine) ## What it changes **Retirements in batches.** The resources of descriptor slots let go by `make_listed`'s `keep` -- hundreds of thousands a second -- went to the retired queue with one lock per object, and that was 15% of the list translation's processor time. A thread now keeps up to `RETIRE_BATCH` (256) of them and moves them into its shard in one go: - when the batch fills; - at `bury()`, which publishes the calling thread's batch first, so nothing it holds can outlive a drain that should have freed it; - at the end of each translated chunk (`list/thin.rs`), where a listing job's work ends. `bury()` still drops a retirement only after the last submission that may use it: objects are freed a little later than they could be, and never earlier. **Declared constant buffers are no longer decoded twice.** `tables()` decoded every slot of every table three times when the slot was a constant buffer its plan declares as one: `record_at`, then `make_listed` (which answers none for `View::Constant` and keeps nothing), then `descriptor::view`. The declared CBVs now go straight to the constants path. No state is touched: it is the same path the code took once `make_listed` answered none. ## How it was tested - GPU and profile (Series X or S, resolution, DLSS, frame generation, ray tracing): NVIDIA GeForce RTX 5080 Laptop GPU; Intel Core Ultra 9 275HX (24 threads, 8 P + 16 E); Windows 11. Series X profile (`console=series-x`), `1080to1440` (scene 1920x1080, upscaled by DLSS), DLSS quality, frame generation 2x, ray tracing off (this build leaves the title's RT passes out). - Before / After: thread-local rdtsc counters on an instrumented local build (the counters are not part of this PR), same scene, 90 s in the world, 8 translating threads: | counter | before | after | |---|---:|---:| | a retirement (`l_retire`) | 0.55 us | **0.07 us** | | `l_retire`, share of the translation's CPU | 15.4% | **1.9%** | | `make_listed`'s `keep` | 0.755 us | **0.323 us** per slot | | declared-CBV decodes, share of the translation's CPU | 2% | 0 | | `make_listed` calls | 172 M / 90 s | **164 M / 90 s** | | cold view creations (`l_lookup` cold) | 89.7 M / 90 s | **64.7 M / 90 s** | Gameplay A/B at matched draw counts (the idle camera drifts, so runs are compared at the same draws): at ~7.3k draws the difference is inside the noise (+/-2 ms of a ~53 ms frame), which is what a change to the translating threads should show there. It shows in heavy scenes: at 10-11k draws the translating threads run 89-94% occupied and the title's record calls are 13 + 4 ms of the frame's critical chain, and that is where the earlier cuts of the same kind moved the frame rate. - For shader changes, the wave sizes tested (32 and/or 64 lanes): not a shader change. - `cargo test` passed for the crates it touches: yes for `victory-gpu` (920 tests; the 2 failures in this environment reproduce on `41adb551` without the patch -- one is the translator-switch test, the other is a flake that passes 3/3 run alone). `cargo clippy -p victory-gpu --all-targets`: no warnings in the touched files. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: none open on these paths -- the ones merged for 29.05 (#2607, #2116, #2509, #2530, #2854, #2814, #2971, #2795, #2834) are already in this base.
From profiling the list translation (2026-11-29: eight translating threads,
90 s in the world).

Retirements -- the resources of descriptor slots let go by make_listed's keep,
hundreds of thousands a second -- went to the retired queue with a lock per
object: 15% of the list translation's processor time. A thread now keeps up to
RETIRE_BATCH (256) of them and moves them into its shard in one go: when the
batch fills, at bury() (which publishes the calling thread's batch first, so
nothing it holds can outlive a drain that should have freed it), and at the end
of each translated chunk (list/thin.rs), where a listing job's work ends. bury()
still drops a retirement only after the last submission that may use it: objects
are freed a little later than they could be, and never earlier.
Measured: 0.55 us -> 0.07 us a retirement; l_retire 15.4% -> 1.9% of the
translation's CPU; make_listed's keep 0.755 -> 0.323 us per slot.

tables(): a constant buffer its plan declares as one was decoded twice on the
miss path -- record_at, then make_listed (which answers none for View::Constant
and keeps nothing), then descriptor::view -- for every slot of every table made.
The declared CBVs now go straight to the constants path. Measured: 2% of the
translating CPU and a quarter of make_listed's calls (13% of that CPU). No state
changes: it is the same path taken once make_listed answered none.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 01:08:53 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-30 05:19 UTC · original · approved these changes

Tested locally merged onto main (41adb551).

  • Merge: Clean merge across draw.rs, host.rs, and list/thin.rs.
  • Tests (RTX 5090):
    • cargo test -p victory-gpu --lib draw:: passed (25 passed; 0 failed; 2 ignored).
    • cargo test -p victory-gpu --lib list::thin:: and host::recycle:: passed.
  • 0 new warnings.

Clean per-thread batched retirement and declared-CBV decode skip optimization. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-30 05:19 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3565#pullrequestreview-6107208554) · **approved these changes** Tested locally merged onto `main` (`41adb551`). - **Merge**: Clean merge across `draw.rs`, `host.rs`, and `list/thin.rs`. - **Tests (RTX 5090)**: - `cargo test -p victory-gpu --lib draw::` passed (`25 passed; 0 failed; 2 ignored`). - `cargo test -p victory-gpu --lib list::thin::` and `host::recycle::` passed. - 0 new warnings. Clean per-thread batched retirement and declared-CBV decode skip optimization. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠dyshay on GitHub · 2026-11-30 05:49 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. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.

**@⁠dyshay** on GitHub · 2026-11-30 05:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3565#issuecomment-7270046329) 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. A run on an RTX 4090 is queued (Series S with ray tracing, DLSS Quality). Frame times will follow here.
github-bot force-pushed github-bot/gh-3565 from 0f96b182ea to 07f43a56ac 2026-11-30 16:39:50 +00:00 Compare
Author
Owner

@⁠trustno1-coder on GitHub · 2026-12-01 18:51 UTC · original

Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.

**@⁠trustno1-coder** on GitHub · 2026-12-01 18:51 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3565#issuecomment-7321672180) Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
github-bot closed this pull request 2026-12-01 18:58:20 +00:00

Pull request closed

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