Repository navigation
feat(gpu): report how long threads are held by host GPU work, by what ran it - #446
Merged
pragyaangaur merged 1 commit intoNov 27, 2026
Merged
Conversation
… ran it A title thread that submits, signals or waits on a queue, calls a fence or presents runs the held work that may run then (crate::hold), the host submissions with their preparation, GPU wait and copy-back included. It goes on with its frame only after that. The 5 s frame report now gives, per frame and per trigger, the milliseconds spent waiting for the queues' lock and running the work, so a world run shows how much of a frame the title spends held there rather than on its own work: the figure that says whether submitting without waiting would pay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A measurement that comes before a design question: how long the title's threads are held inside VIctory's GPU work each frame.
Why
When the title calls
ExecuteCommandLists, the call runs whatever held work may run then (crate::hold, throughqueue::pump). That work isHost::execute: the preparation, the host submission, the wait for the GPU and the copy-back. The call returns to the title only after all of it. The same happens when the title signals or waits on a queue, sets a fence from the CPU, or presents. A thread that only polls (GetCompletedValue,SetEventOnCompletion) usestry_lockand is not held when another thread is pumping.On the console,
ExecuteCommandListsreturns at once and the GPU works alongside. Here the title's thread waits through the GPU work itself, about 140–260 ms of a 450–1,060 ms world frame on M5 Pros in #131 and #409, plus VIctory's preparation. If the title would otherwise spend that time on its own work, submitting without waiting could save up to the GPU time. Preparing on another thread could save more. But the change would be deep.crate::holdtests queue waits against values the copy-back writes, and much ofshadow.rsrelies on "a submission waits for the one before it". So it is only worth designing if the title really is held there and not waiting anyway. Nothing measures that today.SUBMISSION_UScounts preparation and GPU time, but not who was held by them.What changes
queue.rskeeps two counters for eachWhy, in microseconds:held_for, through the smalllock_timed);The callers that block are the title's submissions, its queues' Signals and Waits,
pump_heldfor CPU fence signals and presents, and our 2 ms timer thread. They take the lock throughheld_for(why).pumptimes its body, nowpump_work, unchanged.The 5 s frame report in
host.rsadds one line, in every build, since it costs a clock read or two per pump:The zeros show the format, not a measurement. "our timer" is VIctory's own thread, so time there holds no title thread.
How to read it
Tested
On an M5 Pro, macOS 26.6.2, GPTK 4.0 beta 3, Wine built by
setup.sh:tools/macos/test-wine.sh -p victory-gpu --lib: 363 passed, 0 failed. The one new test isqueue::tests::a_timed_lock_counts_its_wait.cargo test -p victory-gpu --lib queue::tests(native): 6 passed.cargo clippy --target x86_64-pc-windows-gnullvm --workspace --all-targets: no warnings. The native clippy count is unchanged frommain.I have not seen the new line in a game run, since I have no game files. It needs someone's world run, ideally next to the existing
ms/frameline from the same report.AI-assisted, prepared with Claude Code.
🤖 Generated with Claude Code