Diagnostics: where the presenting thread and the workers spent a frame (VICTORY_FRAME_WHY2, off by default) #1275

Open
github-bot wants to merge 2 commits from github-bot/gh-1275 into main AGit
Owner

@⁠CuteBooty on GitHub · 2026-11-26 09:08 UTC · original
CuteBooty:frame-timelines → main · +378 −1 · 7 files · 2 commits · open

VICTORY_FRAME_WHY2=1 writes two lines beginning why2 every five seconds, one for the mean frame of the window and one for its longest frame. Off by default; it changes no behaviour.

Each line is a set of exclusive timelines that add up to the frame: the presenting thread (recording, waits by cause, the present's drain, the display copy, the remainder), the title's other callers (in thread-ms, because several record at once), the submit worker (preparing, waiting, idle) and the relay (waiting for the card's fence, landing, idle). Waits that are still open at a present are sampled there, so time is booked to the frame in which it passed.

How it fits with what is here. The frame log gives aggregate timings; 0672327d measures the gaps of the card's direct queue on the card's clock; the corner box shows the machine's load. These lines add the CPU side as timelines, so one can see which waits overlap and where a saved wait reappears.

What one run showed on my tree (fuller version of the same counters; Ryzen 5 3600, RTX 3070 8 GB, Series S, town, about 212 ms a frame; one run):

  • the presenting thread spends 187 of 212 ms inside the present and records nothing itself;
  • the title's other threads spend 637 thread-ms a frame recording (about three callers at any moment);
  • the submit worker prepares for 126 ms (240 at worst) and is idle for 71; the relay waits 85 ms for the card and is idle for 88.

So on that machine the "present wait" is the presenting thread waiting for the rest of the frame, not a cost of its own.

What changed. New frame_why.rs (span, sample, frame). Hooks in queue.rs (present, execute_now, worker), list.rs (with_state), frame.rs (wait) and in host.rs around preparation, fence waits and relay landing. Two tests: waits that cross a present, and overlapping callers.

Left out against the version in my tree, because this tip's code differs there: the query, culling and descriptor counters, native waits, the drain overlap, flight latency and per-phase maxima.

Cost. When on, reading clocks and taking the counters' lock can affect very short calls. When off, one flag load per hook.

State. Ported by hand onto this tip. cargo clippy --workspace --all-targets -- -D warnings is clean, cargo test --workspace passes (617), the asset policy passes. Not yet run in the game on this tip.

🤖 Generated with Claude Code

**@⁠CuteBooty** on GitHub · 2026-11-26 09:08 UTC · [original](https://github.com/fxceless/victory-fork/pull/1275) `CuteBooty:frame-timelines` → `main` · +378 −1 · 7 files · 2 commits · open `VICTORY_FRAME_WHY2=1` writes two lines beginning `why2` every five seconds, one for the mean frame of the window and one for its longest frame. Off by default; it changes no behaviour. Each line is a set of **exclusive timelines that add up to the frame**: the presenting thread (recording, waits by cause, the present's drain, the display copy, the remainder), the title's other callers (in thread-ms, because several record at once), the submit worker (preparing, waiting, idle) and the relay (waiting for the card's fence, landing, idle). Waits that are still open at a present are sampled there, so time is booked to the frame in which it passed. **How it fits with what is here.** The frame log gives aggregate timings; `0672327d` measures the gaps of the card's direct queue on the card's clock; the corner box shows the machine's load. These lines add the CPU side as timelines, so one can see which waits overlap and where a saved wait reappears. **What one run showed** on my tree (fuller version of the same counters; Ryzen 5 3600, RTX 3070 8 GB, Series S, town, about 212 ms a frame; one run): - the presenting thread spends 187 of 212 ms inside the present and records nothing itself; - the title's other threads spend 637 thread-ms a frame recording (about three callers at any moment); - the submit worker prepares for 126 ms (240 at worst) and is idle for 71; the relay waits 85 ms for the card and is idle for 88. So on that machine the "present wait" is the presenting thread waiting for the rest of the frame, not a cost of its own. **What changed.** New `frame_why.rs` (`span`, `sample`, `frame`). Hooks in `queue.rs` (`present`, `execute_now`, `worker`), `list.rs` (`with_state`), `frame.rs` (`wait`) and in `host.rs` around preparation, fence waits and relay landing. Two tests: waits that cross a present, and overlapping callers. **Left out** against the version in my tree, because this tip's code differs there: the query, culling and descriptor counters, native waits, the drain overlap, flight latency and per-phase maxima. **Cost.** When on, reading clocks and taking the counters' lock can affect very short calls. When off, one flag load per hook. **State.** Ported by hand onto this tip. `cargo clippy --workspace --all-targets -- -D warnings` is clean, `cargo test --workspace` passes (617), the asset policy passes. **Not yet run in the game on this tip.** 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Two why2 lines every five seconds: the mean frame and the longest, as exclusive
timelines of the presenter, the other callers, the submit worker and the relay.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:19:38 +00:00
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 09:25 UTC · original

Thanks, this was useful right away. Merged on top of f6a09d3 with no conflict, run on an RTX 3080 10 GB (Series X, boat mission, standing, README set + CARD_SYNC_BATCH=1 CARD_HASH_WIDE=1):

  • mean frame ~98-103 ms: submit worker prepare 76-79 ms, idle ~18; presenter present 62 + other 34; relay fence wait 51, land 26, idle 22; other callers record ~258 thread-ms.
  • longest frames (214-286 ms): the submit worker is idle ~151 ms in them, so those spikes come from elsewhere (title / streaming), not from preparing.

Together with the existing a submission's preparing by part line (list steps 29.4, write-watch 11.8, refresh flush 11.7, card_before 6.3 ms a frame), it tells us where to look on a machine where the card is no longer the wall. No behaviour change seen with the switch on, no device loss.

**@⁠Garu667** on GitHub · 2026-11-26 09:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/1275#issuecomment-7187959940) Thanks, this was useful right away. Merged on top of `f6a09d3` with no conflict, run on an RTX 3080 10 GB (Series X, boat mission, standing, README set + `CARD_SYNC_BATCH=1 CARD_HASH_WIDE=1`): - mean frame ~98-103 ms: **submit worker prepare 76-79 ms**, idle ~18; presenter present 62 + other 34; relay fence wait 51, land 26, idle 22; other callers record ~258 thread-ms. - longest frames (214-286 ms): the submit worker is **idle ~151 ms** in them, so those spikes come from elsewhere (title / streaming), not from preparing. Together with the existing `a submission's preparing by part` line (list steps 29.4, write-watch 11.8, refresh flush 11.7, card_before 6.3 ms a frame), it tells us where to look on a machine where the card is no longer the wall. No behaviour change seen with the switch on, no device loss.
Author
Owner

@⁠CuteBooty on GitHub · 2026-11-26 10:17 UTC · original

Thank you for trying it so quickly, and for the numbers. A submit worker that is idle for about 150 ms inside the longest frames is the case these lines were written to show.

One small addition exists on my side, if it is wanted here later: a lane for the texture-pass worker of PR 1007 (why2 heap worker), which appears only while that worker runs.

**@⁠CuteBooty** on GitHub · 2026-11-26 10:17 UTC · [original](https://github.com/fxceless/victory-fork/pull/1275#issuecomment-7189172561) Thank you for trying it so quickly, and for the numbers. A submit worker that is idle for about 150 ms inside the longest frames is the case these lines were written to show. One small addition exists on my side, if it is wanted here later: a lane for the texture-pass worker of PR 1007 (`why2 heap worker`), which appears only while that worker runs.
Author
Owner

@⁠Garu667 on GitHub · 2026-11-26 10:35 UTC · original

That heap-worker lane would be useful here: on the RTX 3080, VICTORY_HEAP_WORKER=1 gave no fps gain, darkened the picture and cost 8-9 fps in cutscenes (f6a09d3 comment), so seeing where that worker's time goes next to the submit worker would help explain it. Happy to run it if you push it.

**@⁠Garu667** on GitHub · 2026-11-26 10:35 UTC · [original](https://github.com/fxceless/victory-fork/pull/1275#issuecomment-7189557157) That heap-worker lane would be useful here: on the RTX 3080, `VICTORY_HEAP_WORKER=1` gave no fps gain, darkened the picture and cost 8-9 fps in cutscenes (f6a09d3 comment), so seeing where that worker's time goes next to the submit worker would help explain it. Happy to run it if you push it.
With VICTORY_FRAME_WHY2=1 and VICTORY_HEAP_WORKER=1, each why2 mean and
longest line is followed by a "why2 heap worker" line: the worker's pass
(prepare), waiting for one (idle), and the rest (other). Without the worker,
or with VICTORY_FRAME_WHY2 unset, nothing changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠CuteBooty on GitHub · 2026-11-26 13:50 UTC · original

@⁠Garu667 the lane you asked for is pushed (7cf4e095). With VICTORY_FRAME_WHY2=1 and VICTORY_HEAP_WORKER=1, each why2 mean and why2 longest line is now followed by one more:

why2 heap worker mean (frames=N, ms): prepare X, idle Y, other Z

prepare is the worker's texture pass (including its wait for the pass lock), idle is waiting for a heap to be handed over, other is the rest of the frame. The line appears only while the worker thread exists; nothing else changes. Counters only, two files, lint and the workspace tests pass. I have not yet run this version in the game on the fork's own code, only its sibling in my tree.

On the darker picture with the worker on: I cannot say it is the same thing, but there is one path I read where a slot may never get its host view with the worker running (a placed view of memory the host writes itself); the note is on #1007. A sampled null would read as zero, which could look like darkening. It is a reading of the code, not something I have seen.

**@⁠CuteBooty** on GitHub · 2026-11-26 13:50 UTC · [original](https://github.com/fxceless/victory-fork/pull/1275#issuecomment-7193907119) @⁠Garu667 the lane you asked for is pushed (`7cf4e095`). With `VICTORY_FRAME_WHY2=1` and `VICTORY_HEAP_WORKER=1`, each `why2 mean` and `why2 longest` line is now followed by one more: ``` why2 heap worker mean (frames=N, ms): prepare X, idle Y, other Z ``` `prepare` is the worker's texture pass (including its wait for the pass lock), `idle` is waiting for a heap to be handed over, `other` is the rest of the frame. The line appears only while the worker thread exists; nothing else changes. Counters only, two files, lint and the workspace tests pass. I have not yet run this version in the game on the fork's own code, only its sibling in my tree. On the darker picture with the worker on: I cannot say it is the same thing, but there is one path I read where a slot may never get its host view with the worker running (a placed view of memory the host writes itself); the note is on #1007. A sampled null would read as zero, which could look like darkening. It is a reading of the code, not something I have seen.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1275/head:github-bot/gh-1275'
git switch 'github-bot/gh-1275'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1275'
git switch 'github-bot/gh-1275'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1275'
git switch 'github-bot/gh-1275'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1275'
git switch 'main'
git merge --squash 'github-bot/gh-1275'
git switch 'main'
git merge --ff-only 'github-bot/gh-1275'
git switch 'main'
git merge 'github-bot/gh-1275'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.