VICTORY_DISPATCH_SPREAD costs ~20 ms of card time a frame on an RTX 3060; with =0, 2 of 4 loads hang (DEVICE_HUNG) #1338
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork#1338
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@grosterr on GitHub · 2026-11-26 17:06 UTC · original
RTX 3060 12 GB (driver as of 2026-11), Ryzen 7 5700X, 32 GB RAM, Windows 11, Series X profile, prison prologue, the same save every run. Release build of our branch: the #770 stack with main
06702fe+ceb9e1fmerged in, plusVICTORY_LEVELS_ON_DEMAND EARLY_TEXTURES_MS=40 TEXTURE_NO_WAIT WIDE_TEXTURES ASYNC_SUBMIT QUEUE2 INDIRECT_WINDOW COPY_PLAIN JOIN_PARTS BACK_OWN_VIEW INDIRECT_GATHER CARD_HASH_WIDE LOOKUP_CACHE. World frames only (> 4,000 draws,0 being made), medians of the last 4 minutes of each run, warm pipeline library.06702fe06702fe+ceb9e1fVICTORY_DISPATCH_SPREAD=0The card's time goes up by 18-22 ms with the spread at fewer draws, and the cold run of the same build showed the same (99 ms). Preparing and copy-back do not move.
But
=0is not an option here: 2 of the 4 runs withVICTORY_DISPATCH_SPREAD=0lost the device while loading, 1 min 42 s and 2.5 min in. Both hadDXGI_ERROR_DEVICE_HUNG(0x887A0006), the submitting thread preparing a submission (~0.5 s, nothing of ours on the card), and no breadcrumbs. 0 of 4 runs with the spread on were lost. We read it as: a dispatch clamped to 65,535 groups leaves data the next passes rely on (indirect arguments among them) half made.Where the cost may come from. In the same warm run the frame line says 550-1,030 indirect dispatches a frame go through the spread signature (
CONSTANT×2 +DISPATCH, stride 20). The clamp's own line says the largest group count asked for is ~84,000 (max 115,200), with 260-290 thousand groups asked a frame in all. So only a few dispatches seem to need the spread, while hundreds take the signature that sets root constants. On NVIDIA anExecuteIndirectwhose signature changes root arguments is known to cost more than a plain dispatch signature. Our guess is that this, not the extra groups, is most of the 20 ms. We have not proven it yet. We are working on a variant that keeps the plain signature for records within 65,535 and will post the A/B here.Has anyone measured
=alton another NVIDIA card? A count, in the clamp, of records whose x really passes 65,535 would settle which of the two it is.@grosterr on GitHub · 2026-11-26 17:33 UTC · original
Follow-up: most of it is the signature, and it can be had back without clamping.
Counters. We added two counters to the clamp: records that really ask for more than 65,535 groups in x, and the rest. Of the ~890-990 indirect dispatches a frame that go through the spread signature, only 0.4-1.2 a frame pass 65,535 (15-38 thousand extra groups). The other ~900-1,450 records are within the limit.
A cheaper path,
VICTORY_SPREAD_LEAN=1|alt(off by default, no translator change):[x, y, z]records, where those over 65,535 are zeroed, and the spread[row, asked x, x, y, z]records, where those within it are zeroed.ExecuteIndirectwith the plainDISPATCHsignature, thenSetPredication(EQUAL_ZERO)on that word, thenExecuteIndirectwith the spread signature, then predication off.=0do not apply.A micro-benchmark on the 3060 (1,000 single-record
ExecuteIndirects of empty dispatches): the spread signature takes 1.88 ms of card time against 0.06 ms for the plain one; behind a predicate that is 0 it takes 0.53 ms.In game (RTX 3060, same setup as above, standing still at one spot,
=alt20 s / 20 s, 9 pairs, warm library):The card's time came out lower in all 9 pairs: −22, −19, −9, −19, −16, −7, −1, −13, −8 ms (median −12.8). Preparing pays about +4 ms for recording two calls and the predication instead of one. So in a real frame the signature that sets root constants costs far more than in the empty benchmark, about 13 ms a frame on this card, probably because the driver serialises around it. The rest of the spread's 18-22 ms is either the extra groups or the prologue.
We can open a pull request with this if it is of use (
crates/victory-gpu:indirect.rs,draw.rs,host.rs; WARP tests for the routing and for equal group ids at 100,000 groups).@grosterr on GitHub · 2026-11-26 17:43 UTC · original
Opened as #1352 (rebased on
e4245f3, off by default).