Skip to content

VICTORY_BARRIER_STATS: count barriers by kind and estimate redundant UAV waits (off by default) - #1789

Open
Jesper-Andersson wants to merge 2 commits into
trustno1-coder:mainfrom
Jesper-Andersson:pr/barrier-stats
Open

Jesper-Andersson wants to merge 2 commits into
trustno1-coder:mainfrom
Jesper-Andersson:pr/barrier-stats

Conversation

@Jesper-Andersson

@Jesper-Andersson Jesper-Andersson commented Nov 29, 2026 •

Copy link
Copy Markdown

Tested in game: the numbers below come from one in-game run (180 s window, 2026-11-28) on our fork. This exact PR branch has not been run in game. The wrapping of the newer upstream calls is checked by build and tests only.

Relates to: no issue; this PR is my claim for the idea.

What it changes

This is a diagnostic. It is off by default and costs one cached flag read when off. With VICTORY_BARRIER_STATS=1, it logs one line per frame-rate report:

  • Barrier kinds. Every ResourceBarrier the layer records goes through barstat::rb (crates/victory-gpu/src/barstat.rs), which counts it as a global UAV, per-resource UAV, transition or aliasing barrier. Enhanced Barrier calls are counted too (global / buffer / texture).
  • Redundant title waits (estimate). The title's UAV-type waits (barriers, barrier groups and pipeline syncs) and its dispatches are followed per list. A wait counts as redundant when the next dispatch touches nothing (reads or writes) that the dispatches since the last needed wait touched. Unknown bindings, draws, copies, and the list start all count as needed, as does a wait at the list's end.
  • Run histogram. A histogram of dispatches between title waits, both as recorded and with the redundant waits dropped.

Adapted to current main. Our branch was first written on an older base. Current main has added ResourceBarrier calls since then, and this PR wraps those too (in host.rs, host/place.rs, list.rs, gpudetile.rs, descriptor/host.rs, host/upq.rs, ambient.rs and compose.rs), so the counts are not low. The only calls left unwrapped are in the offline replay tool (replay/), examples and tests, none of which run in the game. The narrow-barrier counters that main has since removed are not touched.

Why: measured numbers (our fork, not this exact branch)

RTX 2070 SUPER, Series S + DLSS Performance, free-roam scene. This is one 180 s run on our t1-next base (upstream 923e38c plus our ports), per frame.

ResourceBarrier calls and barriers are different units: one call can carry several barriers. The first row counts calls. The next three rows count barriers, so they add up to more than the calls.

per frame
ResourceBarrier calls ~2,481
global UAV barriers 1,166
transitions 2,349
enhanced global barriers 64
title UAV-type waits 904
of them estimated redundant ~32 (3.5 %)
of them needed 152
of them unknown (bindings 297, a draw/copy/list start between 223, at list end 130) ~650
of them back-to-back repeats of a needed wait ~71

The last four rows add up to the 904 waits (32 + 152 + 650 + 71, with rounding).

The estimate is conservative, and the unknowns dominate. Every unknown is counted as needed. Only 3.5 % of the waits are provably redundant by this test, and about 72 % can't be classed either way. So this does not show that removing waits would pay off. It shows where the counting has to get better (binding coverage first) before anyone can tell. It is also consistent with #1449's finding that barriers alone are not the cost in a replay, and it gives a way to measure what #799 (narrow barriers) actually removes in a live run.

How it was tested

Checked for overlap

This was written with AI assistance (Claude Code).

…tes redundant UAV waits

Off by default (one cached flag read). Every ResourceBarrier the layer records
goes through barstat::rb and is counted as global UAV, per-resource UAV,
transition or aliasing; enhanced Barrier calls are counted too. The title's UAV
waits (barrier, barrier group, pipeline sync) and dispatches are followed per
list: a wait is redundant if the next dispatch touches nothing the dispatches
since the last needed wait touched (reads and writes both count; unknown
bindings, draws, copies and the list start count as needed). Also a histogram of
dispatches between title waits, as recorded and with redundant waits dropped.
One log line per frame-rate report.

This change was made with AI assistance (Claude Code).
…orrow

Where the list was already a reference, wrapping its ResourceBarrier call as
barstat::rb(&list, ..) borrowed it twice; clippy (needless_borrow) flagged 60
such calls. They now pass the reference as is. No change in behaviour.

This change was made with AI assistance (Claude Code).
@github-actions github-actions Bot added pr-diagnostics Pull request: adds logging, counters or tools pr-performance Pull request: makes it faster or use less memory labels Nov 29, 2026
@github-actions github-actions Bot changed the title [pr-diagnostics][performance] VICTORY_BARRIER_STATS: count barriers by kind and estimate redundant UAV waits (off by default) VICTORY_BARRIER_STATS: count barriers by kind and estimate redundant UAV waits (off by default) Nov 29, 2026
@Jesper-Andersson
Jesper-Andersson marked this pull request as ready for review November 29, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-diagnostics Pull request: adds logging, counters or tools pr-performance Pull request: makes it faster or use less memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant