Where a frame goes on an RTX 4090: submitting thread and helpers, measured (static scene) #3905
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?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T11:04:42Z.
Follows #2415. This is a measured account of one frame on an RTX 4090 in a static scene (camera still, one character idle), so that the next pieces of work can be ranked by what they would save on the frame, not by what they cost in total CPU.
Set-up
diagbuild ofmain2at e4f7d4eb, run unattended for 300 s.VICTORY_PROFILE=150,270,1,<file>): the 28 busiest threads every millisecond for 120 s (62,841 rounds, so 1.9 ms per round in practice), symbolised against the build's PDB. Frame lines from the log averaged over the same window.Summary
victory-submit. It works 35.2 of every 36.3 ms (queue::behind); the profile finds it running 85 % of the time, and of its waits only 0.19 ms per frame are "nothing to do". The rest are waits inside the work.Measured breakdown (log, averaged over the window)
Re-checked on this run against the figures quoted in #2415; this scene is markedly lighter:
Other lines that matter here: the submitting thread spends 32.1 ms per frame in its submissions (17.0 ms user, 8.1 ms kernel); 18.3 submissions per frame; the write watch checks 8.8 GB per frame of which 8.7 GB (99.4 %) is unchanged; the guards' lock is taken 685 times per frame and waited for 10.7 ms (all threads); the relay copies back for 10.9 ms per frame, beside the submitting thread.
Per-thread profile
CPU ms per frame (thread CPU time / frames), and the share of samples running or waiting (top frame in a wait system call):
victory-submitshadow::wide_each_scoped(its helpers), residency fencevictory-list-0..7(8)list::thin::start(no work)victory-relayhost::wait_host_fence)victory-wide-0..7(8)shadow::workers(no work)victory-records-N/victory-under-N(5 + 5)victory-late-waitvictory-heap-syncdescriptor::begin_sync_heapsThe whole process uses about 434 ms of CPU per frame (about 12 logical processors busy), of which about 150 ms is translated title code.
The submitting thread, by function (ms per frame)
Attributed to the innermost of our functions, so driver, kernel and
memcpytime is charged to its caller:Host::submitbody and direct callsExecuteCommandListsper frame)shadow::wide_each_scopedHost::card_record+send::Own::recordHost::card_takeland::Pool::each(merging fetched pieces,memcpy) 1.7; 0.8 waiting for a new upload buffer to become residentwatch::kernel_written,ask_rest,nothing_new*,writes,waited)NtGetWriteWatchin the kernelVec::retaininlined inHost::submitsend::trim,trim_spare_chunks,give_read_back, residency)DestroyAllocation2/FreeGpuVirtualAddresswatch::guards, write trackers, journal)The refresh fan-out costs more than it saves. In
wide_each_scopedthe submitting thread does 3.0 ms of the refresh jobs itself, then waits 2.1 ms for the helpers, which do only 2.6 ms of work between the eight of them; waking them costs about 0.6 ms (NtAlertThreadByThreadIdEx), andavailable_parallelismis asked again on every fan-out (0.16 ms). About 4.7 ms of work takes 6.6 ms of the critical path.Off the critical path, but expensive on smaller CPUs
The eight list translators use 148 ms of CPU per frame. The largest parts:
draw::State::bind15.5,shadow::lookup9.0,HostHeap::keep_ref7.8 (about 6.4 of it in the compare-and-swap of its per-slotMutex, which points to cache misses on the million-slot array, or false sharing between translators writing neighbouring dynamic slots, four 16-byte slots to a cache line; not proven yet),buffer_srv+make_twinned8.7 (about 12,000 raw twins per frame), and read-back buffers created every frame (CreateAllocation2.4, plus 4.4 ms of waiting) and destroyed again onvictory-late-wait(2.6).Already measured
Neutral on the card:
LAND_BATCHASK_RESERVATIONCARD_BUFFERS_MIN_MB=4Positive:
PORT_GUARD: RTX 4090 −2.0 ± 0.9 ms per frame, −5.1 ± 1.3 ms preparing; on a 6-core RTX 3080 Ti machine, lock waits −70 %, −1.5 ms per frame.TEXTURE_HASH_EVERY=64: −1.0 ± 0.6 ms per frame, −2.8 ± 1.2 ms preparing.Planned work, with expected gains on this scene
The gains are for the submitting thread (= the frame here) and are estimates from the profile, to be confirmed by A/B runs on the card. The order puts the largest proven or near-certain savings first.
land::Pool::each, 1.7 ms) off the submitting thread, and keep upload buffers resident instead of waiting for new ones. Expected −3 to −5 ms of the 7.1 ms.available_parallelism. Expected −2 to −4 ms.PORT_GUARDPR. Already measured at −2.0 ± 0.9 ms per frame on the 4090; it takes on the guards' lock (10.7 ms of waiting per frame across threads, about 1.4 ms on the submitting thread here).Vec::retainsweep inHost::submit; read-back and upload buffers created and destroyed every frame (pool them); fewer, larger submissions (18.3 per frame, 41 % ofHost::submitin the driver). Off the frame but worth it on 6-core machines: the per-slotMutexinHostHeap::keep_ref.Together, items 1–4 could bring the submitting thread from ~35 ms towards the card's ~21 ms on this scene; each will be measured on its own, with
VICTORY_ABA/B runs, before any claim.Method and caveats
NtWaitForSingleObject,NtWaitForAlertByThreadIdfor futex locks, condvars and parking,NtDelayExecution, the kernel graphics fence wait). Spinning counts as running.ntdllcarry the nearest export's name; the driver is reported as a module.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by github-actions[bot] on 2026-11-30T11:04:52Z.
Please attach both logs from the run that went wrong. Without them we can only guess. Paste
%LOCALAPPDATA%into the address bar of File Explorer to get there.%LOCALAPPDATA%\victory\logs\: the newestvictory-nvidia-play-<date>-<time>-<number>.log(fromvictory.exe) orvictory-nvidia-<date>-<time>.log(from the script launcher). The window shows its path at the start, on the lineLog: ....%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newestvictory-<date>-<time>-<number>.crash.login%LOCALAPPDATA%\VIctory\data\7952987A\temp\.Also say which GPU, Windows version (10 or 11)
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by akimfomin on 2026-11-30T11:18:48Z.
@dyshay A matching pressure point from our 4070 Ti SUPER (i5-13600KF), Series X native 1440p, full stock RT, DLSS/FG off, on the moving house route: #3833 removed roughly 25,000 unused raw twins per frame, but the independently measured medians were 13.38 vs 13.42 FPS (test settings and results). The overlapping GPU profile accounted for 66.5 ms/frame of marked work, so I’m keeping CPU refresh and GPU RT results separate. For your refresh fan-out work, is there a PR or preferred threshold to test yet? I can run its isolated A/B on this 13600KF. Counts of refresh batch sizes and parent-thread wait per window would also help select a threshold without relying on total worker time.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T11:39:50Z.
@akimfomin thanks. The fan-out change is up on dyshay/VIctory-NVIDIA
fanout:VICTORY_FANOUT_TUNED=1(off by default, A/B-able). The thread count is read once instead of per fan-out, helpers are woken only in proportion to the measured work of the batch (small batches run inline), and the submitting thread takes chunks instead of a fixed share, so it doesn't sit waiting for helpers to finish. A diagnostics line counts fan-outs, inline batches, helpers woken and the submitting thread's wait. The branch is on top of our fork's main (trustno1 main + our fixes, including PORT_GUARD), so an A/B withVICTORY_AB=15,VICTORY_FANOUT_TUNEDisolates it. Our own A/B on the static scene is queued; I'll post it here. Batch-size counts per window are a good idea, and I'll add them if the first A/B is inconclusive.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by dyshay on 2026-11-30T18:16:20Z.
Our A/B of
VICTORY_FANOUT_TUNED(branchfanout), RTX 4090 + i9-13900KF, Series S + hardware RT, static motel save, 15 s phases, 27 neighbouring pairs, draws regressed out:So the submitting thread does a little less, but the frame doesn't move. That fits @burber's point that the refresh is a fork-join on the frame's critical path, and that the submitting thread is blocked for a third of the frame: shuffling chunks between it and the helpers doesn't shorten the join. We're not taking it. Next on our side is finding what the submitting thread waits on, before moving more work. @akimfomin no need to spend a run on the branch.