d3d12: frame-time percentiles and what stalls frames, in the log and on the panel (D3D12-FRAME-TIME-STATS) #2613
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2613"
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 ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-29T14:46:49Z.
Claimed in the coordination issue as: D3D12-FRAME-TIME-STATS (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7249422163)
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 #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: #2569, #2587, #2588, #2589, #2601).docs/design.md, with how it was confirmed. (Not applicable: no translator change.)Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-29T14:56:11Z.
Independent Wine check of
5d1d6c85fintegrated cleanly withbd643e46e. I cross-builtleonida-gpufor Windows x64 with Rust 1.98.1,cargo xwin, profilediaganddiagnostics. Runs used CachyOS, Wine 11.22, VKD3D-Proton71cae091, DXVK 3.1.1-97 and a real DXGI swap chain under headless Gamescope.The test creates a synthetic 640×360 RGBA8 texture, calls production
Host::presentand independently timestamps its return. It feeds short delays, 150 ms hitches and 1.12 s stalls, and checks the meter snapshot after each reporting window.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
cargo xwin checkwithoutdiagnostics.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.
Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-29T18:42:37Z.
Independent native Windows 11 + AMD Radeon RX 7900 XTX (
gfx1100, driver32.0.32029.2010, Windows 1110.0.26200) check of5d72958bfmerged cleanly ontomain4755667f5(no game files):main4755667f5):cargo test -p leonida-gpu --lib -- --test-threads=4->544 passed; 0 failed; 47 ignored(12.27 s).#2613(5d72958bf) +main4755667f5:cargo test -p leonida-gpu --lib -- --test-threads=4->548 passed; 0 failed; 47 ignored(12.30 s, +4 newframetimetests, 0 regressions, 0 new compiler warnings).python -I scripts/check_no_game_data.pyon all 4 touched files: clean.AI-assisted: Antigravity (Gemini 4 Neon).
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T21:32:15Z.
RUN (independent run, #2613 head
5d72958bfon main878b024f4; merged locally withgit merge --no-ff, no conflicts; also no conflict with #2566 head7b5cb2941pergit merge-tree --write-tree).Commands, in
d3d12/, target x86_64-pc-windows-msvc, toolchain 1.98.1:cargo check --tests -p leonida-gpuand the same with--features diagnostics(the panel code only builds with it): both OK on the merged tree.cargo test -p leonida-gpu: green, 548 passed / 0 failed / 47 ignored. With--features diagnostics: 610 passed / 0 failed / 47 ignored. The 4host::frametime::testspass in both.frametime.rs, tests kept): rank rounded down instead of up (percent * n / 100) makespercentiles_are_nearest_rank_without_float_roundingfail; counting and the longest frame only while times are still kept makespast_the_kept_times_the_counts_stay_exactfail.frametime.rs, the tests do not compile (E0432/E0425,FrameTimes,Summary,KEPT,shortnot found).ceil(p/100 * n)instead of the integer rank passes all 4 tests. The test comment says 0.95 * 100 is 95.00000000000001 in f64; I get exactly 95.0, and the two ways of ranking agree for every n from 1 to 4096 and p in 50/95/99. So the "without float rounding" case guards nothing beyond the floor/ceil direction; harmless, but the comment is inaccurate.Meter::presented/line(called every 5 s from the frame-rate meter) and the panel box growing from 9 to 14 lines (it grows even when no line exists yet).No runtime/ C++ or Python in this PR, so no link or import check applies.
Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T21:36:42Z.
Tested
5d72958bfmerged (no commit) withmain060c47160: Windows 11, Rust toolchain fromd3d12/rust-toolchain.toml, CPU only, no game run.cargo test -p leonida-gpu --lib --locked:main549 passed, 47 ignored; with this PR 553 passed, 47 ignored, 0 failed. The 4 new tests inhost::frametimepass (percentiles, counts past the kept window, nearest-rank without float rounding, panel lines fit the box).cargo clippy -p leonida-gpu --locked -- -D warnings: 10 findings onmainand the same 10 with the PR, all inleonida-luaandleonida-shader; this PR adds none.mainand does not force a rebase of #2566.host.rsandpipeline.rs, so before merge it should also run in game for 300 s with no device loss, as this project now asks of render-path changes.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-30T16:36:48Z.
Updated:
mainis merged in atc6a8f7164, and the conflict is resolved. The pull request's own change is otherwise unchanged.mainmoved the frame meter's five-second lines intoMeter::lines. That function may now run on a thread of its own (meter_beside). The frame times belong to the meter, so they are still logged whereMeter::framedecides that a five-second line is due, on the presenting thread, as before.0.95 * 100is exactly95.0in f64, and for 50, 95 and 99 a float rankceil(p / 100 * n)agrees with the whole-number rank for every n up to 4096 (I checked the same). The comment now says what the case does: ranks are whole numbers,(percent * n).div_ceil(100), so no float can move one, and the case pins the rounding direction at 100 frames.cargo test -p leonida-gpu --locked: 575 passed. The 4frametimetests also pass with--features diagnostics. clippy: nothing in the changed lines.Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-30T17:20:55Z.
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 (
LINES, used once inpanel.rsto size its buffers), so it does not need new buffers when the frame-time lines appear. The five extra lines are empty only until the first five-second line, about 5 s after the first present. Making the box grow would mean making its buffers again at that point, for 5 s of empty space. Both branches still merge cleanly withmainad25611b5, and CI is green.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T17:39:11Z.
RUN · VERIFY-2613-RTX4060 · by MoonEyes (another person than the author) on head
c6a8f7164merged withmain1d4949d58. Windows 11 Pro 26300, RTX 4060 8 GB,-SeriesS -FrameGen 2, diag build.cargo test -p leonida-gpu --lib --locked: 576 passed, 0 failed.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T17:39:23Z.
Merging. Head
c6a8f7164merges cleanly withmain99167bcafand does not force a rebase of #2566. Run in the game of 480 s without device loss on RTX 4060 posted on this head; cargo test 576 passed. Merged by MoonEyes.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-30T20:49:11Z.
IN-GAME RUN (gate, independent): #2613 head
c6a8f7164, RTX 3090 24 GB, NVIDIA 621.40, Windows 11.Setup: leonida.exe built from this head (
d3d12/scripts/build-nvidia.ps1, diag profile, no DLSS files). After a 300 s warm-up, the gate run used the game-gate tool from #2782 (head22e096e47) with-WorldSeconds 600 -MaxMinutes 20,-SeriesS -NoDlss -NoFrameGen, Enter pressed through a keys file until the world, nothing after, the same save restored, standing still. Other jobs could run on the PC at the same time, so the frame rates are not comparable with other runs.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.