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

Open
github-bot wants to merge 1 commit from github-bot/gh-1065 into main AGit
Owner

@⁠homerrek on GitHub · 2026-11-24 11:09 UTC · original
homerrek:gpu-submission-timing → main · +45 −0 · 1 files · 1 commits · open

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.

**@⁠homerrek** on GitHub · 2026-11-24 11:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/1065) `homerrek:gpu-submission-timing` → `main` · +45 −0 · 1 files · 1 commits · open 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 #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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:42:20 +00:00
Author
Owner

@⁠Diskuss on GitHub · 2026-11-24 11:31 UTC · original

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?

**@⁠Diskuss** on GitHub · 2026-11-24 11:31 UTC · [original](https://github.com/xcl-dev/xcl/pull/1065#issuecomment-7130208327) **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?
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-24 15:54 UTC · original

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

  • XCL_GPU_TIMING=1 (the run in your "What I would run"): not run, so there are no submission timings here.
  • World loading and the #505 stop: a 60 s run ends before it.
  • cargo test --workspace, AMD, Linux.

AI use: Claude Code (Claude Opus 5.5)

**@⁠Kalmarv** on GitHub · 2026-11-24 15:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1065#issuecomment-7136809137) 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** - `XCL_GPU_TIMING=1` (the run in your "What I would run"): not run, so there are no submission timings here. - World loading and the #505 stop: a 60 s run ends before it. - `cargo test --workspace`, AMD, Linux. **AI use:** Claude Code (Claude Opus 5.5)
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 08:52 UTC · original

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

  • cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 08:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/1065#issuecomment-7157577770) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun. Thanks!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1065/head:github-bot/gh-1065'
git switch 'github-bot/gh-1065'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1065'
git switch 'github-bot/gh-1065'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1065'
git switch 'github-bot/gh-1065'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1065'
git switch 'main'
git merge --squash 'github-bot/gh-1065'
git switch 'main'
git merge --ff-only 'github-bot/gh-1065'
git switch 'main'
git merge 'github-bot/gh-1065'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.