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.

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

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
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.

2 participants