On a submit-bound PC the title spins on its frame fence: measurements, a reversed throttle, and switches that do nothing here #2940
Labels
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida#2940
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?
@Yizzii on GitHub · 2026-12-01 20:06 UTC · original
PC: RTX 5070 Ti 16 GB, Ryzen 7 9800X3D (8C/16T), 32 GB, Windows 11. Builds:
7fbcd45,ed867d7anddcda41f(each section says which), diag profile, the launcher's settings, frame generation off. All runs stand at one save restored before every run, with background apps closed by the test script (a music player left open in the later runs). Frame times are split by draws a frame: light < 6,500, heavy > 8,000. A/B runs use LEONIDA_AB with 4 s phases for 15 minutes; plain runs are 6 minutes.On
dcda41fthis PC does 23.0-23.2 ms light and 29.6-30.4 ms heavy (two runs). The runtime's "card's clock" line (medians over both runs) puts the card at about 70 % busy and idle 7.0-7.9 ms a frame, 6.9-7.2 ms of that "while the submitting thread was working (the card idle behind us)". So here the submitting thread is the limit, not the card. Several of the findings.md results these switches rest on were taken where the card was the wall (d280: about 95 % busy), and some come out differently here.1. The title allows two frames under way, and its main thread spins on that fence (reversed from the executable)
Windows Performance Recorder (CPU profile, 20 s,
ed867d7): the busiest title thread was on a processor 55 % of the time, and 81 % of those samples were in one wait: 61 % in the Sleep it calls and 20 % in its own monitorx/mwaitx loop. That is at least ~10 ms of every ~24 ms frame, before counting its time asleep. The timeline shows most of it as the title running ("outside our spans"); only the longer sleeps appear as waits.The wait, by RVA in the 1.0.2.1 image:
So at the end of frame N the title waits until frame N-1 has been submitted, run and landed. In the same run the submitting thread worked 20.4 of 24.2 ms a frame light and 24.9 of 30.7 heavy.
I tried letting the title have three frames under way: the ring moved to four slots in the padding at the end of .data (+0xabce400), waiting at three instead of two. Both runs broke within a minute in the world: device removed ("relay: fence ... did not reach") in one, a title write fault at +0x50ebb82 in the other, and badly wrong lighting and stretched models on screen. The title's per-frame data most likely relies on that limit, so it has to stay. Writing it down so nobody else spends a run on it.
2. GetWriteWatch calls of one process don't overlap, and the title's faults wait with them
Local experiment (
ed867d7): ask_ahead's runs asked on the wide helpers (wide_each), not one after another on the submitting thread, with the answers merged back in order. A/B, 57 rounds of four phases, 33,286 frames:So spreading kernel calls over threads only makes them queue, and the title's own threads queue behind them. The other way round, every kernel call left out should help twice: the submitting thread and the title's faults.
3. The title's descriptor ring runs dry under a slow frame (one-byte fix, no fps)
The title fills root-table descriptors into a ring shared by all its contexts:
In a timeline (
7fbcd45, ~30 fps with the timeline on) the job threads slept there ~13 times a frame (257 in 20 frames), about 1.5 ms each (p90 2-2.5 ms). With the count patched to 128 (one byte, 24 MiB more) the sleeps went to 0 and the timeline frame from 33.2 to 29.8 ms (one run each). In normal runs there was no change: light 23.8 / 24.1 ms without against 23.7 / 23.9 with, heavy 30.7 / 31.3 against 31.1 / 30.8. It only bites when the frame is slowed, so maybe on slower PCs.4. Switches that do nothing on this PC (or cost)
All in ms of frame time, on minus off. A/B rows on
dcda41fanded867d7are matched by draw count (see the end) unless noted.7fbcd45dcda41fdcda41fed867d7ed867d7ed867d7ed867d7ed867d7RELAY_EACH and SUBMIT_FRAMES were written for a title polling its fence, and that is this PC (section 1). They still do nothing here: telling the title sooner or queueing deeper doesn't shorten the wait. What sets it is the time to finish frame N-1 (submitting thread, then card, then landing).
On the list threads: their recording is ~0.35 ms of a frame's chain in the timeline. Local changes to them on
7fbcd45(a lock skipped, hash sets kept across resets, a cheaper pointer hash) gave light -0.07 +-0.10 and heavy -0.15 +-0.14; the list-thread CPU saved shows up as idle, not as frame time. LIST_LOCK_FAST (#2764) was the change there that showed up: light -0.34 +-0.13, p90 -1.06 +-0.41, measured before it was merged.5. Where the submitting thread's time goes (
dcda41f, its own line)Per frame:
The lists' steps break down as refreshes 4.5 ms in 26 flushes of ~5,500 refreshes (~85 % known to copy nothing), and copies and fills 1.8 ms. Per frame there are also 274 kernel askings over ~1.5 GB, 3.0-3.8 ms of protection changes, and ~1,400 title faults costing ~7.7 ms of the title's threads.
The in-process sampler on this thread (
ed867d7, inclusive shares, they overlap) agrees: shadow::wide 27 % (8 % of it waiting on the helpers), refresh_front 21 %, kernel_written (GetWriteWatch) 9 %, ask_ahead 8 %. RTSSHooks64 (RivaTuner) shows up in 7 % of its samples but only 0.15 % on its own (the driver's ExecuteCommandLists runs through its hook), so it isn't a cost.How these were measured
Besides LEONIDA_AB's phase lines, every run wrote a line per frame: frame time, draws, the A/B bits, card idle, submitting thread worked, process CPU time. Each frame is compared only with frames of a like draw count (250-draw bins), and on minus off is taken per round of phases. On the same data that gave an error of +-0.08 ms, against +-0.21 for the same rounds without the matching.
@MoonEyes on GitHub · 2026-12-03 15:28 UTC · original
Triage Notes
What we've established so far:
d3d12/docs/switches.mdandd3d12/docs/findings.md. I could not independently reproduce the hardware/game run here.What we still need from you (@Yizzii):