Repository navigation
d3d12: frame-time percentiles and what stalls frames, in the log and on the panel (D3D12-FRAME-TIME-STATS) - #2613
Conversation
…on the panel (D3D12-FRAME-TIME-STATS) The frame-rate line gives a mean over the last second or more, and the F3 panel only the longest frame, so a run with smooth frames and a few multi-second stalls looks like a slow one, and the stalls do not show. host/frametime.rs keeps every presented frame's time. With the frame-rate line, every five seconds, it logs one line: the median, 95th and 99th percentiles (nearest rank), the longest frame, how many took over 100 ms and over a second, and beside them host pipelines queued and made a second, waits for new memory to be resident per frame, and the commit the system has left. The panel shows the last line's numbers and the pipeline wait per frame. Pure parts are unit-tested.
|
Independent Wine check of The test creates a synthetic 640×360 RGBA8 texture, calls production
Across 880 frame intervals, the frame count and both threshold counters matched exactly. Each run reported 104 intervals with 7 over 100 ms and 2 over 1 s, then 116 intervals with 6 over 100 ms and 2 over 1 s. The resident-ms/frame value also matched the measured residency counter delta, including 1 µs total in each first NVIDIA window. All four stock frametime tests and the live probe passed in every run. The Windows x64 build also passed The Wine process exited 0 in all four verified runs. On NVIDIA, headless Gamescope exited 139 during shutdown after the Wine child completed. The launcher records both statuses separately. AI-assisted, offline, synthetic input. |
…from the first present (review)
- Panel: frame times of 10 s or more (the launcher's pipeline budget) made
the percentile line longer than 40 columns, and the panel cut it without
a sign ("MAX 10000" showed as "MAX 100"). Times from 10 s up are shown in
whole seconds ("10S"); the test covers 10 s, 100 s and 10 min.
- The first line's pipelines made a second and residency waits counted
everything since the process started: the meter now starts from the
totals at the first present.
- "queued" was queued or being made: the log says so, the panel says
PIPES PENDING.
- The nearest-rank test covers 95% of 100 frames, where a float ceil would
take the 96th.
|
Independent native Windows 11 + AMD Radeon RX 7900 XTX (
AI-assisted: Antigravity (Gemini 4 Neon). |
|
RUN (independent run, #2613 head 5d72958 on main 878b024; merged locally with Commands, in
No runtime/ C++ or Python in this PR, so no link or import check applies. |
|
Tested
AI-assisted (Claude Code). |
main moved the frame meter's five-second lines into a function of their own that may run on another thread: the frame times are logged where the meter decides a five-second line is due, on the presenting thread, as before. The nearest-rank test's comment said 0.95 * 100 is not 95.0 in f64; it is: ranks are whole numbers so that no float can move one, and the case pins the rounding direction (review).
|
Updated:
|
|
On enlight3d's last note, the panel box growing from 9 to 14 lines even before there is a frame-time line: this is on purpose, and I am leaving it as is. The box has a fixed size ( |
|
RUN · VERIFY-2613-RTX4060 · by MoonEyes (another person than the author) on head
AI-assisted (Claude Code). |
|
Merging. Head AI-assisted (Claude Code). |
|
IN-GAME RUN (gate, independent): #2613 head c6a8f71, RTX 3090 24 GB, NVIDIA 621.40, Windows 11. Setup: leonida.exe built from this head ( Gate: PASS. No device loss, no crash, clean exit (0x0) after 608 s in the world. The stop came through the window close, with no kill. Median 10.1 fps in the world by the runtime's fps lines (the tool's own figure, from presents after world+60 s: median 11.2, p5 6.7). The longest gap between presents was 8.5 s, during a loading dip just after the world was reached. The late memory build-up that main shows on this card in some runs was moderate here (release queue about 134,000 and mapped scratch 3.7 GB at the end, VRAM peak 14.6 GB). It is not caused by this PR. Not checked: Series X, walking, picture. The PR's percentile lines were not compared with an independent frame-time source. |
Claimed in the coordination issue as: D3D12-FRAME-TIME-STATS (#2570 (comment))
What and why
The frame-rate line gives the mean over the last second or more, and the F3 panel shows only the longest frame. A run with smooth frames and a few multi-second stalls therefore looks like a uniformly slow one, and the stalls, which are what players feel, do not show in the log.
New
crates/leonida-gpu/src/host/frametime.rs, in every build:Meter::frame).frame times over S s, N frames: median … ms, 95th percentile …, 99th …, longest …; A over 100 ms, B over 1 s; host pipelines Q queued, M made a second; waits for new memory to be resident R ms a frame; commit left C GB.copystat, on five more lines:P50 … P95 … P99 … MAX …(from 10 s up in whole seconds,10S),OVER 100 MS … OVER 1 S …,PIPES PENDING … MADE/S …(queued or being made),WAITS PIPES … RESIDENT … MS(the pipeline wait over the panel's half second, the rest over the five-second line),COMMIT LEFT … GB. The box is five lines taller while shown, so the trainer menu below it moves down.pipeline::made()gives host pipelines created or loaded since the start, next tomaking(). The meter starts from the totals at the first present, so the first line counts only what came after.An independent review found the panel line past 40 columns for stalls of 10 s or more (the panel cut it without a sign); fixed in the second commit, with the test covering 10 s, 100 s and 10 min.
host.rschanges only by the module line, one field ofMeterand two calls (+12 lines).Tested
On Windows 11, from
d3d12\:New unit tests in
host::frametime::tests:All 4 pass. On
mainthey do not build, because the module is new.cargo test -p leonida-gpu --locked: 541 passed. With--features diagnostics: 603 passed.cargo clippy -p leonida-gpu --all-targets --locked, with and without--features diagnostics, reports nothing in the changed files. As noted in d3d12: LEONIDA_WINDOWS_BAR_MB says once that it does nothing without resizable BAR (D3D12-BAR-WINDOWS-WARNING) #2612, workspaceclippy -D warningsandcargo fmt --checkare already red onmainin other files. The new file is formatted withd3d12/rustfmt.toml.git diff --checkis clean, and so ispython -I scripts/check_no_game_data.pyon the four files.In game, I checked the numbers against PresentMon 2.6 run beside it, over the same windows. Run: diag build, Series X profile at 1440p, the launcher's defaults, menus, then a story load and its cutscene.
leonida-gpuhost.rsis already over the 655,360-byte limit thatxtaskpolicy::tests::repository_passes_policychecks: it fails onmaintoo. This change adds 12 lines to it and keeps the rest in the new module.GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 Pro 10.0.26300.
AI-assisted: yes
Checklist
mainand merges cleanly (checked against the open pull requests that touch these files: runtime, d3d12: memory leak fixes from one sweep (RT-LEAK-SWEEP) #2569, fix(gpu): present to the title's window, not a pseudoconsole's 0x0 window #2587, GPU: pipeline workers get a 64 MB stack for the driver's compiler #2588, Render-target reserve expires once the targets settle (LEONIDA_CARD_ROOM_FOR_TARGETS_SETTLE_MS, off by default) #2589, d3d12: keep pipeline wait budgets from moving backward #2601).docs/design.md, with how it was confirmed. (Not applicable: no translator change.)