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

Open
CuteBooty wants to merge 2 commits from upstream-pr/1275 into main
CuteBooty commented 2026-11-26 09:08:25 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by CuteBooty on 2026-11-26T09:08:25Z.


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

<!-- greyfinch-sync:fxceless/victory-fork:issue:6623243212 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1275). Originally posted by [CuteBooty](https://github.com/CuteBooty) on 2026-11-26T09:08:25Z. --- `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)
Garu667 commented 2026-11-26 10:06:46 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Garu667 on 2026-11-26T09:25:12Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7187959940 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1275#issuecomment-7187959940). Originally posted by [Garu667](https://github.com/Garu667) on 2026-11-26T09:25:12Z. --- 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.
CuteBooty commented 2026-11-26 11:05:31 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by CuteBooty on 2026-11-26T10:17:40Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7189172561 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1275#issuecomment-7189172561). Originally posted by [CuteBooty](https://github.com/CuteBooty) on 2026-11-26T10:17:40Z. --- 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.
Garu667 commented 2026-11-26 11:05:32 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Garu667 on 2026-11-26T10:35:00Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7189557157 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1275#issuecomment-7189557157). Originally posted by [Garu667](https://github.com/Garu667) on 2026-11-26T10:35:00Z. --- 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.
CuteBooty commented 2026-11-26 14:03:31 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by CuteBooty on 2026-11-26T13:50:20Z.


@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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7193907119 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1275#issuecomment-7193907119). Originally posted by [CuteBooty](https://github.com/CuteBooty) on 2026-11-26T13:50:20Z. --- @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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1275:upstream-pr/1275'
git switch 'upstream-pr/1275'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1275'
git switch 'upstream-pr/1275'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1275'
git switch 'upstream-pr/1275'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1275'
git switch 'main'
git merge --squash 'upstream-pr/1275'
git switch 'main'
git merge --ff-only 'upstream-pr/1275'
git switch 'main'
git merge 'upstream-pr/1275'
git push origin 'main'
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
fxceless/victory-fork!1272
No description provided.