Skip to content

D3D12.X: time ExecuteCommandLists submissions (XCL_GPU_TIMING) - #1065

Open
homerrek wants to merge 1 commit into
xcl-dev:mainfrom
homerrek:gpu-submission-timing
Open

homerrek wants to merge 1 commit into
xcl-dev:mainfrom
homerrek:gpu-submission-timing

Conversation

@homerrek

Copy link
Copy Markdown

Part of #505. Diagnostics only: a switch and three report.json fields, no behaviour change with
the flag off.

What is in it

  • crates/xcl/src/hle/d3d12x/real.rs — D3d12Stats gains submissions, slowest_submission_ms,
    slowest_submission_lists, all #[serde(default)] so an old report.json still parses.
  • crates/xcl/src/hle/d3d12x/real.rs — SUBMISSIONS, SLOWEST_SUBMISSION_US,
    SLOWEST_SUBMISSION_LISTS counters, gpu_timing_on() (XCL_GPU_TIMING=1) and
    slow_submission_us() (XCL_GPU_TIMING_MS, default 50).
  • crates/xcl/src/hle/d3d12x/real.rs — q_execute_command_lists takes one Instant before
    execute_with_waits_on and updates the counters after present::note_execute; any submission
    at or above the threshold logs ExecuteCommandLists: <us> µs on the CPU for <n> list(s).
  • crates/xcl/src/hle/d3d12x/real.rs — stats() fills the three fields.

Why

q_execute_command_lists is the single choke point for every title submission, and nothing
measures it. In #505 the run reaches the world, the title's state reads Game Running, the screen
stays on a spinner and the watchdog ends it 3–14 minutes in. From outside that looks identical
whether the CPU is spending seconds per submission (pipeline builds, allocator pools, texture
refresh) or the CPU is fine and the GPU never completes. presents and frame_boundaries do not
separate the two.

This separates them, cheaply, at the one place both cases pass through.

What it does not measure — stated in the field doc comment

ExecuteCommandLists returns before the GPU is done, so this is CPU submission cost, not GPU
execution time
. It shows pipeline, allocator and texture-refresh cost under the call. Real GPU
time needs fence timestamps per submission, which is a larger change and not in this PR.

Tested

  • Not run. No Windows toolchain, no GPU, no title on this machine.

Regression run

  • Not run. Requires scripts/smoke.ps1 on Windows with a GPU and a retail title.

Not tested

  • No build, no cargo test --workspace, no GPU run, no xcl-smoke blocks (main and head). All are
    required before merge.
  • No test added. CONTRIBUTING lists diagnostics and env-var switches as their own PR kind and
    exempts logging from tests; the counters sit behind OnceLock and a device, so a unit test would
    need a device or a restructure of the statics. Say if you want it restructured to be testable and
    I will do that instead.
  • Not measured with the flag on against a real world load — the numbers that would matter.

Cost when off

One OnceLock read per submission and nothing else: gpu_timing_on() is cached after the first
call, timed is None, and the counters are never touched. A world load submitting thousands of
times pays thousands of atomic-free branch checks.

AI use

  • Written by an AI agent (R9K) at the request of @homerrek. No part of it was executed.

What I would run, if I had the hardware

For the two xcl-smoke blocks, plus:

$env:XCL_GPU_TIMING=1
$env:XCL_GPU_TIMING_MS=200
xcl run <title folder>

Then logs\report.json → d3d12.submissions, d3d12.slowest_submission_ms,
d3d12.slowest_submission_lists, and the warnings in xcl.log. If the slowest submission is a few
ms while frames still do not come, the wall is GPU-side and this PR has done its job by ruling the
CPU out.

If you want the GPU side too, the next PR should be fence-completion timestamps per submission —
say so and I will write it as a stack on top of this one.

`q_execute_command_lists` is the one choke point every title submission goes through, and
nothing measures it. When a world load leaves the screen on a spinner and the GPU watchdog
ends the run (issue xcl-dev#505), there is no way to tell a slow submission from a stalled one.

With `XCL_GPU_TIMING=1`, wrap the submission in a clock and keep the slowest in
`report.json`: `d3d12.submissions`, `d3d12.slowest_submission_ms` and
`d3d12.slowest_submission_lists` (how many command lists that submission carried). Any
submission at or above `XCL_GPU_TIMING_MS` (default 50 ms) is logged as a warning.

It measures the CPU side of the call only, and the field comment says so: the call returns
before the GPU is finished, so this shows pipeline and allocator cost under the submission,
not GPU execution time. Off by default.

Counters only exist while the flag is on, so an ordinary run's `report.json` gains three
zero fields and nothing else.
@Diskuss

Diskuss commented Nov 24, 2026

Copy link
Copy Markdown

Tested on AMD Radeon RX 9070 XT (RDNA4) at 49a3f1a7061a760f9a38fedd0f95fcfe4b30db49

Ryzen 7 5700X3D, 32 GB, Windows 11 Pro 26300.9974, AMD driver 32.0.32015.7029, Rust 1.100.0 msvc, DXC 1.9.2602.17, debug build.

Tested (PR head is 0 commits behind main 47efa2e, so no merge was needed; the bare head was tested):

  • cargo build --workspace: OK (1 existing warning, Atomic::fetch_update deprecation).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 741 passed, 0 failed, 41 ignored. 0 SKIPPED printed; 2 debug-layer tests skip silently, no Graphics Tools installed. No device removal.
  • Same command again with XCL_GPU_TIMING=1: 741 passed, 0 failed, 41 ignored. No change in behavior, no timing output in the captured logs.
  • The PR adds no tests, so there are no named tests to run. The timing code is only reached through the title's ExecuteCommandLists hook, which no unit test exercises, so the new report.json fields (submissions, slowest_submission_ms, slowest_submission_lists) and the slow-submission warning were not checked.
  • Main 47efa2e baseline: 741/0/41, so the counts are identical.

Not tested: retail title / scripts/smoke.ps1 (no game files), release build.

Report written by Claude Code (Claude Sonnet 5.5) from a real run on this machine.

Do the maintainers find these AMD/RDNA4 test reports useful, or would something else (different tests, a different format) help more?

@Kalmarv

Kalmarv commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Regression pair for 49a3f1a against main 47efa2e (this PR's base), for the Regression run section. Both runs pass: no device removal, no crash, 99 % of main's frames, 104 % of its peak commit.

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74), AMD Ryzen 9 9950X, Windows 11 Pro 26200.
  • scripts/smoke.ps1, the same retail title for 60 s each: main at 47efa2e (this PR's base) first, then this PR's head, one after the other on the same machine. XCL_GPU_TIMING was unset, so this is the flag-off path.

main 47efa2e:

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1309 (PresentX 1309)
presents per 2 s (last 3): 34 36 54
device removals: 0
crashes: 0
peak commit: 27494 MB

this PR, 49a3f1a:

xcl-smoke v1
commit: 49a3f1a7061a760f9a38fedd0f95fcfe4b30db49
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA VI
seconds: 60
exit: 0x0
frames shown: 1297 (PresentX 1298)
presents per 2 s (last 3): 32 54 4
device removals: 0
crashes: 0
peak commit: 28679 MB
  • With the flag off, this PR's report.json has the three new fields at zero (submissions 0, slowest_submission_ms 0.0, slowest_submission_lists 0), and xcl.log has no ExecuteCommandLists: … on the CPU line. main's report.json doesn't have the fields.

Not tested

AI use: Claude Code (Claude Opus 5.5)

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 26, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
bmjask pushed a commit to bmjask/xcl that referenced this pull request Nov 27, 2026
Adapt the opt-in timing from upstream PR xcl-dev#1065 to the exact native chunks emitted by the current submission planner. Keep count and slowest duration/list count as one coherent sample in report.json; ordinary submissions read no clock.

Assisted-by: Codex (GPT-5.6-sol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants