GPU: the frame line times the title's calls, and how long they waited #3222
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3224"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-26T13:39:57Z.
Summary
Every counter on the frame line times submission-side work — preparing, copying back, guarding, heaps, descriptors. Nothing times the recording side: the title's calls into its command lists, which #2590 puts at "about 42,000 list calls a frame … roughly 20 µs each (RTX 4050 Laptop): the largest CPU cost of a frame".
list::with_stateis where every list handler's body runs, so it now reports:Calls— the calls that found a host list to record into. A call with no host list (no host GPU) runs nothing and is not counted,CallUs— how long their handlers took, all of it,CallLockWaitUs— the one part split out: the time before a handler ran, waiting for the list's own two locks (the segment's host list, then the draw state).Printed at the end of the existing line, as
list calls N: X ms in their handlers, Y ms waiting for the list's locks.What this answers, and what it does not. It says how much of a frame's recording time is in the title's list calls at all, and how much of that is contention on the list's own two locks. It does not separate instructions from waiting inside a handler: a call blocked on
SHADER_HEAPS(NEW-74'ssync_heapshold, FIND-30's 48 ms a frame of title threads waiting) blocks inside its handler, so that wait lands inCallUswhole andCallLockWaitUsdoes not move. Reading these three as "instructions vs waiting for the list" would be wrong, and telling those apart inside a handler is a further measurement, not this one.Diagnostics builds only, like every other counter in this file: with the feature off, nothing is measured and nothing is added to the call.
Verification
Intel Arc B580, Windows 11:
cargo test -p victory-gpu --lib --features diagnostics --locked -- --test-threads=1→ 246 passed, 2 failed, 1 ignored. The two are the known Intel heap-cap pair (descriptor::host::tests::dynamic_slots_are_held_until_released,memory::tests::lists_share_a_table_and_copies_keep_their_views— #1744/#1829) that pristinemain63bcca4also fails on this card.list::call_counters::a_call_with_a_live_host_list_is_counted— a created list with a live host list:Calls+1, its handler's 2 ms inCallUs,CallLockWaitUsleft where it was, since a slow handler is not a wait for the list; anda_call_without_a_host_list_is_not_counted— a call with no host list runs nothing and is not counted.the call is counted, left 0, right 1). With the count moved above the host-list check both fail (not counted, left 1, right 0). With the wait measured over the handler too the first fails (a slow handler is not a wait for the list's locks: 2089 us).cargo clippy -p victory-gpu --all-targets -- -D warningsclean with and without thediagnosticsfeature.cargo xtask policy→ 191 files ok.rustfmt --checkon the two files is unchanged from the PR's base version of each:list.rs26 "Diff in" hunks before and after,copystat.rs5 before and after.No game data used; synthetic tests only. Measurement only — no behaviour change on any path.
claiming: GPU: the frame line times the title's calls into its command lists (how many, how long, and how long they waited for the list's locks) — the recording side of a frame, which no counter measures today
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T13:50:11Z.
Review: APPROVED
Verified on RTX 5090 against
origin/main(63bcca4):cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20/20 passed.cargo clippy -p victory-gpu --all-targets -- -D warnings&--features diagnostics: clean.cargo xtask policy: 191 files ok.Cleanly times title command-list calls and their wait durations in the frame summary line.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T22:34:13Z.
Windows 11,
63bcca4+ this PR:cargo test -p victory-gpu --lib: 231 passed / 0 failed / 1 ignored — same counts as unpatched63bcca4here.cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.No test added; the frame-line accounting it extends is only meaningful in a submission, so this is compile/regression coverage. Synthetic only. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T23:02:18Z.
The timer in
db140abstops before acquiring the draw-state mutex. Time spent on that mutex is absent from both reported durations. Follow-upf0c6f25uses the start of the handler as the end of the wait interval and samples handler time before updating the counters.I made three calls on a real synthetic D3D12 list, with a second thread holding the state mutex for 25, 90, and 160 ms respectively. On exact
db140ab, all three calls were counted, but their combined reported wait was 4–7 μs across three WARP processes. With the patch it was 276.3–277.0 ms, matching the caller's measured delay. The no-op handlers themselves took 1–5 μs total in both builds. The diagnostics GPU suite passed 246 tests with one ignored. Strict GPU Clippy in both configurations and asset policy passed.@borosf, this is ready to cherry-pick. If you fold it into your change, please keep the Git author or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:35:57Z.
Review: CHANGES_REQUESTED
Reviewed and tested
db140abf87159fc379dba3a49f1d1a2d5273aafeon both RTX 5090 and WARP (--features diagnostics,VICTORY_D3D12_DEBUG=1;cargo xtask policyand default/diagnosticsclippyare clean).There is a timing bug in
crates/victory-gpu/src/list.rs:140-160:waitingis sampled beforestate.lock(), andhandleris sampled afterstate.lock(). As a result, all time spent blocked onList::state's mutex is excluded from bothC::CallWaitUsandC::CallUs(onlyhost_list(this)is measured inCallWaitUs).Confirmed live by holding
list.stateon another thread for ~35 ms while callingwith_state(list, |_, _| {}):wall_ms = 35.17,calls = 1,call_us = 0,wait_us = 1wall_ms = 35.52,calls = 1,call_us = 0,wait_us = 1Sampling
handlerimmediately afterstate.lock()and computingwaitingfromhandler.saturating_duration_since(started)both fixes the missing lock-wait accounting and removes an extraInstant::now()call on the hot path:Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T06:38:40Z.
Folded in at
0707239(on top ofdb140ab), with you asCo-authored-by:in the commit — thank you, this is a real hole in the measurement the whole frame line rests on.What went in, exactly as you diagnosed it:
with_stateno longer samples the wait beforestate.lock(): the wait ishandler.duration_since(started), so it ends where the handler starts and also covers the list's own locks on the way in (thehostslock inhost_list).C::Calls/C::CallUs/C::CallWaitUsare updated, so the counting is not billed to the call.Verification on Windows 11 x64 / Arc B580:
cargo test -p victory-gpu --lib --features diagnostics --locked244 passed / 0 failed / 1 ignored (the two #1744 heap-cap tests skipped, as on main here);cargo clippy -p victory-gpu --all-targets -- -D warningsclean with and without--features diagnostics;rustfmt --edition 2024 --checkhunk parity with origin/main on both files (26 = 26, 5 = 5).I did not add a regression test: it needs a real title list and a host list behind it, and the observable is a counter in
copystat, so the honest guard is your reproduction (25/90/160 ms held → 276 ms reported). If you want it in the tree, your fixture would be the one to take. Synthetic only, no game data.Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T10:50:39Z.
Folded in at
07072396, and thank you for doing the measurement that made it obvious — 4-7 µs reported against 276-277 ms of real delay is exactly the kind of number that settles which side of the mutex a timer belongs on.The change matches your
f0c6f25:Calls/CallUs/CallWaitUsdoc comments no longer claim the timer "can only be read as time waiting on a submission", since it now measures that directlyCo-authored-by: andrewpozdnakov7-jpgis on the commit. CI is green on the head, the branch is mergeable, andcargo test -p victory-gpu --lib, strict clippy in both configurations andcargo xtask policypass locally on Windows 11 x64 (Arc B580).Synthetic tests only, no game data used.
Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T11:22:40Z.
Re-review request: the one item in @fuzeofficlal's review is already satisfied at the current head (
07072396), which is why I have not changed anything since.crates/victory-gpu/src/list.rs:146-157now keeps the incoming bytes as the saved baseline only for pages the copy-back actually owns, and every other page falls through to the pre-write baseline exactly as before. Local verification on Windows 11 x64 (Intel Arc B580):cargo test -p victory-gpu --lib watch:: --locked16 passed / 1 ignored,cargo clippy -p victory-gpu --all-targets -- -D warningsclean,cargo xtask policy191 files ok.Nothing else in the PR changed since that review; if the head looks right to you, a dismissal of the stale request would let this go in.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T11:28:20Z.
@fuzeofficlal, I checked the current head
07072396against the timer fix I tested. Your review ofdb140abflagged the wait onList::state. The current code takeshandlerafterstate.lock()and reportshandler.duration_since(started), so that wait is now included inCallWaitUs.CallUsis sampled before incrementing the counters.The entire difference from tested
f0c6f25is three comment lines inlist.rs. Onf0c6f25the synthetic WARP run reported 276.3–277.0 ms for the three held locks, up from 4–7 μs ondb140ab. Original WARP result · CI on the current headCould you re-review the timing change on
07072396?AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T14:11:36Z.
@borosf I checked the new diagnostic assertions on
d409803. The live-list test reads the shared frame counters. I ran a second realwith_statecall on another thread and another synthetic list while the first handler was active. The original assertion observed two calls and failed2 == 1.Test follow-up
94924bdtests the same overlap and observes increments from its own thread. It bounds the lock time by the measured interval before handler entry, so a scheduling delay before entry cannot cause a spurious failure. Both diagnostic tests passed in 25 separate WARP processes with--test-threads=2. Strict GPU Clippy passed in both feature configurations, along with the asset check.Please keep the Git author if cherry-picking or rebasing the test patch. If folding it in, add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>. AI-assisted. Synthetic lists only.Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T14:28:15Z.
@andrewpozdnakov7-jpg took it as a cherry-pick of
94924bd, so your authorship, message and date are untouched at5fa8cb3, with the(cherry picked from commit 94924bd...)line kept for provenance. Nothing of yours was reworded and noCo-authored-bywas needed.What I checked on this head:
count()back on the shared atomics makes the live-list test failonly this call is countedwithleft: 2, right: 1— from the test's own peer call, deterministically, no timing needed. With the thread-local it passes. So the isolation is load-bearing, not just a tightening of the assertions.victory-gpulib suite, this head vsd409803: 246 passed / 2 failed / 1 ignored withdiagnostics, 229 / 2 / 1 without — the same two failures on both trees (descriptor::host::tests::dynamic_slots_are_held_until_released,memory::tests::lists_share_a_table_and_copies_keep_their_views; they want a live device on this Arc B580). Your patch adds none.--all-targets -- -D warnings, both feature configurations: clean.Bounding the wait by the interval measured before handler entry is the part that makes it robust to scheduling; reading only this thread's increments is the part that lets the test exist at all while other modules record into the same counters.
AI use: Mistral Vibe (agent) — cherry-pick, mutation check and suite runs on Windows 11 x64, Intel Arc B580.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.