Skip to content

D3D12.X: with XCL_LOOK_STATS=2 split a present's time on the submitter - #2955

Open
thisguyStan wants to merge 1 commit into
xcl-dev:nvidia-devfrom
thisguyStan:d3d12x/presentx-timers
Open

thisguyStan wants to merge 1 commit into
xcl-dev:nvidia-devfrom
thisguyStan:d3d12x/presentx-timers

Conversation

@thisguyStan

@thisguyStan thisguyStan commented Nov 27, 2026 •

Copy link
Copy Markdown

Targets nvidia-dev (ecc0bb57). Part of #2688 (workstream 8).

In the world, presents take most of the submitting thread's time on NVIDIA (93 % on an RTX 4080 in #2729's breakdown), but calls of the submitting thread (2 s) shows a present as one presents entry with only its wait for frame N−2's copy (PresentCopyWait) apart, so where that time goes cannot be told. This adds four entries, timed only with XCL_LOOK_STATS=2 like that wait:

  • the wait for the present before it (PRESENTX_LOCK, PRESENTER),
  • the copy (or composite) of the frame recorded and submitted, from the allocator's reset to its Signal,
  • the swap chain's Present, which DXGI holds while the frames before it are queued (a GPU-bound frame waits there),
  • the wait for a frame dump's copy (XCL_FRAME_DUMP, XCL_DUMP_TARGETS, up to 2 s).

What a present spends besides them is the rest of presents (the plane checks, the frame-rate line, the device-removal check). When the fallback presents on a submission (a title that does not call PresentX), these parts run inside ExecuteCommandLists rather than inside presents, as the copy wait already did; the doc comment on the entries says so. Diagnostics only: no change with the switch off. #2729 adds entries to the same Call list, and an is_sub_call list of the calls that nest inside another (PresentCopyWait among them); the four new entries nest inside presents too, so whichever lands second rebases and puts them there.

What is in it

  • crates/xcl/src/hle/api_cost.rs: PresentLockWait, PresentRecord, PresentSwap, PresentDumpWait and their names in CALLS.
  • crates/xcl/src/hle/d3d12x/present.rs: the four timers around the two lock waits, the recording and submit, Present, and the frame-dump wait.

Tested

  • RTX 4070 Ti 12 GB (driver 32.0.16.1088, 32-lane waves), Ryzen 9 5900X, 64 GB RAM, Windows 11 Pro build 26200, rustc 1.100.0, DXC 1.9.2602.17; tests in debug, smokes in release.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on dd85383e: 1823 passed, 8 failed, 48 ignored.
    • All 8 fail the same way on nvidia-dev ecc0bb57 (run by name there): async_compute_pso_registers_real_pso_and_not_standin, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays, texture_upload::tests::pieces_hold_the_texels_of_their_levels, split_compute_prefers_the_offline_whole_pipeline and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (each in two test binaries).
    • kernelx::tests::gpu_visible_fallback_memory_is_write_watched passed here; it failed once in an earlier full run on 1a6ddc2c (assertion failed: !in_graphics_reservation(a)) and passes alone.
  • SKIPPED: 29 (21 no wave64, 3 per-lane forms refused, 2 no heap windows, 3 no D3D12 debug layer).
  • The timers on: scripts/smoke.ps1 on 1a6ddc2c (release; the same code as dd85383e) with XCL_LOOK_STATS=2, XCL_PREPARE=0, 60 s in the intro and menus (1354 frames, no device removal, no crash). Every calls of the submitting thread (2 s) line (from 12 s on) has the new entries. From 14 s on, the parts add up to the presents entry within 0–4 ms per 2 s (the rest of a present); the first present (12 s) took 51 ms, of them 1 ms in the parts. From 26 s on, every 2 s:
    • 60 presents in 37–58 ms,
    • 120 waits for the present before (two per present) in 0 ms, 60 waits for the last frame's copy in 0 ms,
    • 60 copies recorded and submitted in 16–30 ms,
    • 60 swap chain Presents in 17–24 ms.
    • The slowest 2 s (at 18 s): 54 presents in 225 ms, of them 124 ms recording and submitting and 98 ms in the swap chain's Present.
    • No frame-dump waits (no XCL_FRAME_DUMP): that entry is not printed.
  • Into the world: two runs of dd85383e with XCL_LOOK_STATS=2, XCL_ACTIVITY=1, XCL_PREPARE=0, played past the intro, were stopped as the world loads by a device removal (0x887a0005, no DRED breadcrumbs) and then the title's breakpoint at the same address (at 228 s and 114 s). nvidia-dev ecc0bb57 with the timers off stops the same way (223 s), so the world itself was not reached. In the first run, while the world loaded (178–226 s, 9–13 fps), every 2 s:
    • 1–61 presents in 3–190 ms, of them 1–117 ms recording and submitting and 2–102 ms in the swap chain's Present; the parts add up to presents within 0–4 ms,
    • the waits for the present before and for the last frame's copy stay at 0 ms,
    • ExecuteCommandLists takes 57–1005 ms.

Regression run
60 s scripts/smoke.ps1 runs of the same title, all with XCL_PREPARE=0 (as the other nvidia-dev PRs' runs; e120925e predates the launch preparation and does not read it). main is the commit before #2555 (e120925e), run on a copy of a main-only shader cache; the nvidia-dev base and this PR on copies of one nvidia-dev shader cache. XCL_LOOK_STATS unset, so these show the switched-off path.

main (e120925e):

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 4070 Ti
title: 83ce7bf6
seconds: 60
exit: 0x0
frames shown: 1317 (PresentX 1317)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15791 MB

nvidia-dev base (ecc0bb57):

xcl-smoke v1
commit: ecc0bb57976b1bc94854199ddf4f915fd00e0a59
gpu: NVIDIA GeForce RTX 4070 Ti
title: 83ce7bf6
seconds: 60
exit: 0x0
frames shown: 1323 (PresentX 1323)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15275 MB

This PR (dd85383e):

xcl-smoke v1
commit: dd85383eb9a6162b21856463185a5f420c526850
gpu: NVIDIA GeForce RTX 4070 Ti
title: 83ce7bf6
seconds: 60
exit: 0x0
frames shown: 1309 (PresentX 1309)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14962 MB

Not tested

  • A run in the world: on this machine nvidia-dev stops with a device removal as the world loads (above), so the split in the world is not measured.
  • The frame-dump wait (XCL_FRAME_DUMP, XCL_DUMP_TARGETS) and the composite path of a present.
  • AMD and Intel GPUs, 64-lane wave GPUs, Linux / Wine.

AI use

  • Claude Code (Claude Opus 5.5): wrote the change and this description, ran the tests and the smoke runs on the machine above.

@ettehn

ettehn commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

One accounting detail for the #2729 integration, checked at 1a6ddc2c. The submission-driven fallback calls present_now directly, so it emits PresentRecord and PresentSwap without an enclosing Call::Present sample. It runs inside the enclosing ExecuteCommandLists timer. Those samples belong to Submit on that route and to Present on the boundary route. In both cases, #2729’s non-overlapping total should treat them as sub-calls.

A standalone Windows x64 fixture compiled this head’s api_cost.rs and fed it the fallback sequence. It reported Present=0, PresentRecord=12 ms, PresentSwap=20 ms, Submit=40 ms. The durations are fixture inputs. This checks the counters and the source call sites. If the new metrics are meant to break down presents, a route guard or separate fallback labels would keep that interpretation accurate.

OpenAI Codex assisted with verification.

On a 16 GB NVIDIA card in the world, presents took 93 % of the
submitting thread's time (xcl-dev#2688), but a present was one entry with only
its wait for the copy of the frame before apart, so where that time
goes could not be told.

Four more entries, timed with XCL_LOOK_STATS=2 only, as that wait is:
- the wait for the present before it (PresentX's lock, the presenter's),
- the copy (or composite) of the frame recorded and submitted, from the
  allocator's reset to its Signal,
- the swap chain's Present, which DXGI holds while the frames before it
  are queued (a GPU-bound frame waits there),
- the wait for a frame dump's copy (XCL_FRAME_DUMP, XCL_DUMP_TARGETS),
  up to 2 s each.

With XCL_ACTIVITY they appear in "calls of the submitting thread (2 s)"
next to "presents"; what a present spends besides them is the rest
(the plane checks, the frame-rate line, the device-removal check). No
change with the switch off.

When the fallback presents on a submission (a title that does not call
PresentX), its parts are timed inside ExecuteCommandLists rather than
inside presents, as the copy wait already was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thisguyStan
thisguyStan force-pushed the d3d12x/presentx-timers branch from 1a6ddc2 to dd85383 Compare November 27, 2026 05:00
@thisguyStan

Copy link
Copy Markdown
Author

Thanks, that's right: on the submission-driven fallback present_now runs inside ExecuteCommandLists, so its parts land in Submit, not in Present. The copy wait already did the same. I kept the timing as it is. A Present timer around the fallback would count the same time in both entries, and Call::Present deliberately covers only PresentX and the console-method fallback. Instead, dd85383e says it in the doc comment on the entries, the commit message and the description. For #2729's non-overlapping total, all four new entries belong in is_sub_call along with PresentCopyWait, on both routes. That's in the description too, for whichever PR lands second. (Claude Code with Claude Opus 5.5 checked the call sites.)

@thisguyStan
thisguyStan marked this pull request as ready for review November 27, 2026 06:07
@LocranKing

Copy link
Copy Markdown

Tested PR #2955 (dd85383e) on Windows 11 in a 180 s open-world run with XCL_LOOK_STATS=2 to cover the open-world PresentX breakdown noted under Not tested.

Environment

  • GPU: NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2140)
  • CPU / RAM: AMD Ryzen 5 5500 (6C/12T), 32 GB DDR4, Windows 11 Build 26300
  • Shader cache & runtime: Frozen nvidia-dev DXIL cache (XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, XCL_TEXTURE_LEVEL_PAGES=1, XCL_PREPARE_GRAPHICS=0, XCL_DRED=1, XCL_LOOK_STATS=2), Series S (lockhart) profile.

180 s Open-World Run (XCL_LOOK_STATS=2)

  • Outcome: exit: 0x0, 0 crashes, 0 device removals, 1760 frames (PresentX 1760), heavy world draws began at 108.55 s, peak commit 29509 MB, peak local VRAM 10279 MB, peak non-local 4982 MB.
  • Aggregated calls of the submitting thread (2 s) breakdown:
Scope Intervals ExecuteCommandLists waits for pipelines being built presents total waits of a present for the one before waits of a present for the last frame's copy copies of a present recorded and submitted swap chain Presents
Full 180 s run 87 4686 (76,902 ms) 64 (3,226 ms) 1760 (32,086 ms) 3520 (0 ms) 1760 (0 ms) 27,148 ms (84.6%) 4,818 ms (15.0%)
In world (t >= 100 s) 47 1382 (50,349 ms) 64 (3,226 ms) 108 (25,543 ms) 216 (0 ms) 108 (0 ms) 22,895 ms (89.6%) 2,624 ms (10.3%)

World observations

  • Once in the world (t >= 100 s), presents (25,543 ms) accounted for ~33.6% of {ExecuteCommandLists + presents} submitter call time (75,892 ms), and copies of a present recorded and submitted dominated presents at 89.6% (22,895 ms across 108 presents), with swap chain Presents at 10.3% (2,624 ms) and lock/copy waits at 0 ms (residual remainder 24 ms / 0.1%).
  • Single 2 s world spikes reached up to 2172 ms for 2 presents (2167 ms in copies of a present recorded and submitted, 4 ms in swap chain Presents, at 144.993 s) and 1654 ms for 1 present (1653 ms in copies of a present recorded and submitted, at 187.661 s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants