Skip to content

[upstream #1123] D3D12.X: the GPU-wait watchdog says where a chain of waits ends - #37

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1123
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/1123

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Diagnostics only, the plan from xcl-dev#505 (comment). When the GPU-wait watchdog releases a wait, it now also logs, once per burst, where the chain of waits behind it ends. Part of xcl-dev#505.

Today's lines give each cell's recorded / submitted / completed values. Those read the same for a cycle of queues and for a chain of waits behind one queue that is busy or held by a wait outside the sync graph, because the 5 s start when the CPU issues the Wait, not when the queue reaches it. Nothing is released, pruned or signalled differently.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: before the watchdog releases expired waits, it takes the tracked Wait / Signal calls still in flight (calls_in_flight, read-only) and follows them from an expired wait's queue (wait_chain): a queue is held at its earliest tracked call in flight, and when that is a wait the chain goes on at the queue of the Signal that satisfies it. One xlog_warn! line per burst (at most one per 5 s timeout, 64 in all), written after the releases:
    D3D12.X: GPU wait chain: q3 Wait64(0x70416ab00>=0x577) -> q0 Wait64(0x70417fee8>=0x577) -> q2 end=signal (no tracked wait in front of it: executing, or behind a wait XCL does not track); same_end=5/5 (expired cells this tick), earlier_releases=0, write64_cycle_breaks=0, sparse queue fence=39141/39142 rb=17/18
    
    (format example with made-up values, not from a run)
    • end=cycle: back at a queue already on the chain, so every queue on it is held at a wait.
    • end=signal: no tracked wait is in front of the queue. It is executing, or behind one of XCL's own tile-mapping waits, which are not in the graph (@upipibi's point 2 on D3D12.X: bridge Wait64BitValueX to GPU fences with exact cycle breaking xcl-dev/xcl#795).
    • end=unsubmitted: no submitted Signal satisfies the last wait.
    • end=signal-gone: the cell counts the value as submitted, but the graph tracks no Signal for it and the fence is below it. The graph lost track (a CPU release dropped the Signal, or it was not queued because the fence was already there, and the fence went back since). Printed with the cell's submitted and cpu_signaled values.
    • same_end=n/m: of the m cells released in this tick, how many have a chain that ends the same way at the same queue.
    • earlier_releases: cells the watchdog released before this tick. write64_cycle_breaks: Write64 Signals signalled on the CPU so far (the "would close a GPU cycle" line stops after 32; its counter moved to module scope for this). Mixed title-fence breaks are not counted.
  • Limit: a CPU release (the watchdog's or a cycle break's) drops the cell's tracked Signals up to its value, although they may still be queued. After the first one, a queue can look held at a wait that really sits behind such a Signal, and a chain can end in a cycle that is none. The line is exact only while both counts are 0.
  • The watchdog now reads the clock once per tick, for the chain check and for the expiry test (one existing line), so both see the same waits as expired.
  • crates/xcl/src/hle/d3d12x/sparse.rs: fence_status() for the end of that line: the tile-mapping queue's fence and the readback fence, as completed / last value asked for (decimal, like wait_for's own line). The state keeps a second reference to both fences outside STATE, because a submit can sleep for 5 s in wait_for with STATE locked, which is the case the line is for. The values asked for are read with try_lock; when the state is busy they print as ?, with the value the submit sleeps on (wait_for=N, two atomic stores around the sleep). The watchdog never blocks on it.
  • Tests in list_x.rs: wait_chain_names_where_expired_waits_end (graphs built by hand, no GPU: cycle, signal, unsubmitted, signal-gone, the line's text and same_end, one line per burst) and wait_chain_leaves_out_completed_calls (real fences, WARP is enough: calls the GPU has completed are not on a chain; skips with "no GPU").

Cost: while no wait expires, one pass over the armed waits on the watchdog's existing 50 ms tick (it only runs while a wait is armed), skipped for 5 s after a line. Nothing on the title's threads.

Tested

  • NVIDIA GeForce RTX 3080 10 GB (driver 610.88 / 32.0.16.1088, 32-lane waves), AMD Ryzen 9 5900X, Windows 11 Pro 26200; Rust 1.100.0 stable-x86_64-pc-windows-msvc; tests in the default (debug) profile, smoke runs in release.
  • cargo test --workspace -- --test-threads=4: 739 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask and gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware, both "no wave64"). main 384f7f7 on the same machine: 737 passed, 0 failed, 41 ignored, the same two SKIPPED.
  • Game: the retail title (Xbox Series 1.0.2.1). In these 300 s runs it stayed in its first-run screens and menus (no ListX [upstream #1047] Tests: verify successful BCPack requests through the queue #101 call, no world loading), so no wait expired and no GPU wait chain line was produced.

Regression run

xcl-smoke v1
commit: 384f7f7f8c79fa4d4dee59336d650a4021af4c7e
gpu: NVIDIA GeForce RTX 3080
title: Leonida-game
seconds: 300
exit: 0x0
frames shown: 8339 (PresentX 8339)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 15524 MB
xcl-smoke v1
commit: 6a3c81a9da642f13c360e02b00ccaa79120410bf
gpu: NVIDIA GeForce RTX 3080
title: Leonida-game
seconds: 300
exit: 0x0
frames shown: 8346 (PresentX 8346)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15510 MB

Not tested

AI use

  • Claude Code with Claude Fable 5.2 wrote the code, the tests and this description; a Claude Opus 5.5 reviewer agent read the diff, and the fixes it asked for are in. The hardware suite and the smoke runs above were run by Claude Code (Claude Opus 5.5) agents on the RTX 3080 named, in a restricted local account; the counts and blocks are copied from those runs.

Mirror of xcl-dev#1123 (auto-synced, do not edit).

When a bridged Wait64 expires, the watchdog's lines give each cell's
recorded / submitted / completed values. They read the same for a cycle
of queues and for a chain of waits behind one queue that is busy, or
held by a wait outside the sync graph, because the 5 s start when the
CPU issues the Wait and not when the queue reaches it (xcl-dev#505).

Once per burst (at most one line per timeout, 64 lines in all) the
watchdog now follows the tracked waits from the queue of an expired
wait. A queue is held at its earliest tracked call in flight; when that
is a wait, the chain goes on at the queue of the Signal that satisfies
it. The line names the waits passed and where they end:

- end=cycle: a queue already on the chain,
- end=signal: a queue with no tracked wait in front of it, so it is
  executing or behind one of XCL's own tile-mapping waits, which are
  not in the graph (review of xcl-dev#795, point 2),
- end=unsubmitted: a wait that no submitted Signal satisfies,
- end=signal-gone: a wait on a cell that counts the value as submitted
  while the graph tracks no Signal for it and the fence is below it
  (the graph lost track; printed with the cell's submitted and
  CPU-signalled values).

With it: how many of the cells released in that tick end at the same
place, the watchdog's releases before this tick, the count of Write64
cycle breaks so far (their own line stops after 32), and the
tile-mapping queue's fence and readback fence as completed / asked for.

Limit: a CPU release (the watchdog's, a cycle break's) drops the cell's
tracked Signals up to its value although they may still be queued.
After the first one a queue can look held at a wait that really sits
behind such a Signal, and a chain can end in a cycle that is none. The
line is exact only while earlier_releases and write64_cycle_breaks are
0; mixed title-fence breaks are not counted.

No change to what is released or signalled. The calls in flight are
read under the graph lock before the releases, without pruning, and the
line is written after them. The watchdog now reads the clock once per
tick for the chain check and the expiry test, so both see the same
waits as expired. While no wait expires the cost is one pass over the
armed waits on the watchdog's 50 ms tick, skipped for one timeout after
a line. sparse.rs keeps a second reference to its two fences and the
value wait_for sleeps on, so that they can be read while a submit holds
the state.

Part of xcl-dev#505.

Assisted-by: Claude Code (Claude Fable 5.2)
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#1123 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/1123 branch November 25, 2026 00:14
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