Skip to content

D3D12.X: count skipped draws and dispatches by cause - #2625

Open
grahamster2 wants to merge 2 commits into
xcl-dev:mainfrom
grahamster2:skipcount-by-cause
Open

grahamster2 wants to merge 2 commits into
xcl-dev:mainfrom
grahamster2:skipcount-by-cause

Conversation

@grahamster2

@grahamster2 grahamster2 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

World runs of the retail title on one machine logged 5,347 and 6,803 skipped dispatches (aggregate counts from two runs), but nothing says which path skipped them, which blocks diagnosing a world-load stall. This keeps the two totals (DRAWS_SKIPPED, DISPATCHES_SKIPPED) and adds a counter per cause. The non-zero ones are appended to the existing periodic "console code so far" log line, e.g. ...; skipped by cause: building: no wrapper 4, released before submit 1, build failed 56, dropped at submit 1; coherent ... (the format, as printed by a unit test run). That line is printed when a total reaches a power of two (64, 128, ...), and the counters are plain relaxed atomics read without a lock, so a printed line is a snapshot that may be a count or two behind. No behaviour change except the replayed ExecuteIndirect case described below: every other skip site still skips exactly as before.

What is in it

  • crates/xcl/src/hle/d3d12x/bind.rs: a Cause enum with a counter each; skip(total, cause) replaces count(..._SKIPPED) at every skip site, including the ExecuteIndirect ones counted as DRAWS_SKIPPED (so the causes add up to the two totals); dispatch_dropped counts "dropped at submit". Causes: pipeline still building at record time and the call was not put off, split by why (bundle, predicated, no segments left, no wrapper, segment could not be made; plain "building" when nothing refused it, e.g. a late pipeline), put off but the stand-in was released before the submit, build failed, no translation (nothing builds the pipeline), dropped at submit (no allocator / Reset failed), two-pass pipeline, translated draw or dispatch whose arguments could not be bound. When a call could not be put off, that reason is kept through the wait for the build and is what gets reported, whatever the build did in the meantime (with XCL_PSO_WAIT_MS unset the call blocks until the build is done, so the state read after the wait says nothing about the refusal).
  • crates/xcl/src/hle/d3d12x/list_x.rs: defer returns Result<(), Cause> (the reason is worked out from the same checks split makes, after it said no); record_deferred marks the thread as recording at the submit (restored by a drop guard), which is how "released before submit" is told apart from "no translation".
  • crates/xcl/src/hle/d3d12x/bind.rs, execute_indirect: the one line that is not a counter. A put-off ExecuteIndirect dispatch is replayed at the submit; if the title released its stand-in by then, the release has forgotten the console-compute marker, the check for "this was a console dispatch" failed and the call fell through to the PC ExecuteIndirect. The replay now counts as one (AT_SUBMIT, which is only set for calls that were put off because they were console compute), so it is skipped and counted as released before submit, like the direct Dispatch. That is a behaviour change for that one case.
  • crates/xcl/src/hle/d3d12x/pso_async.rs: build_state(pso) (untracked, building, failed, built).
  • Tests: skipped_calls_are_counted_by_cause (failed build, still building with no wrapper for a Dispatch and an ExecuteIndirect dispatch, a refusal that wins over the failed build the wait ended with (checked on the state after the build, with no timing in it), no translation, released at the submit for a Dispatch and for an ExecuteIndirect dispatch whose stand-in was released before the replay, dropped, the guard after a panic), a_dispatch_that_cannot_be_put_off_is_counted_by_why (a bundle list and a predicated list through defer, on a real or WARP device), the_log_line_names_only_the_causes_that_happened, and cause assertions in the two-pass test and the deferred-dispatch test. They check each skip moves exactly one cause and that the causes add up to the totals, with per-thread mirrors of the counters (test builds only) so tests running in parallel do not see each other's skips.

Tested

  • AMD Ryzen 5 7600X, NVIDIA GeForce RTX 3080 (driver 32.0.16.1088), Windows 11 10.0.26200, rustc 1.94.0, debug (tests) and release (smoke)
  • cargo test -p xcl --lib on the head 428750f (rebased on main b49be18): 1312 passed, 0 failed, 27 ignored in two of three runs; 24 SKIPPED lines (wave64 and f16 GPU tests that this adapter cannot run). The third run failed two tests in hle::d3d12x::sparse::tests (a_tile_decommitted_and_committed_again_keeps_its_video_memory, flush_parked_does_not_free_or_reuse_tiles_while_unmap_is_in_flight); sparse:: alone passed 17 of 17, and main passed three of three full runs. I did not look into it; no file of this PR is in sparse.
  • skipped_calls_are_counted_by_cause, the cause filter, three runs in a row: pass. With the one-line fix in execute_indirect removed, the new released-ExecuteIndirect case fails.
  • a_dispatch_with_a_pipeline_still_building_waits_at_the_submit (an existing timing test) failed now and then when run together with other tests, on main too (4 of 20 runs of cargo test -p xcl --lib -- d3d12x::bind d3d12x::list_x on main 08db802); it did not fail in the runs above.

Regression run

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3080
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1642 (PresentX 1642)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14891 MB

PR:

xcl-smoke v1
commit: 428750f718f1ab9f9ca30a1be59b63eef268035d
gpu: NVIDIA GeForce RTX 3080
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1647 (PresentX 1647)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14695 MB

Frames 1647 vs 1642 on main, peak commit 14695 MB vs 14891 MB, one 60 s run each, default settings.

Not tested

  • cargo test --workspace (only -p xcl --lib was run); the e2e tests.
  • AMD GPUs, and the wave64 paths.
  • The new log line in a world run: I did not check whether the 60 s smoke run printed it.
  • A real title that releases a stand-in between recording and submit an ExecuteIndirect dispatch: the new case is covered by a fake list, not by a retail run.
  • The "no segments left" cause has no test (it needs a wrapper with its segments used up).

AI use

  • Claude Code, Claude Sonnet 5.5: wrote the code, the tests and this description; I ran the tests and smoke runs above.
    AI-assisted (Claude Code).

@DarkPanda69

DarkPanda69 commented Nov 26, 2026 •

Copy link
Copy Markdown

Update for head 428750f: rerun on main b49be18, same cards and --nocapture. The cause filter gives 2 passed on both the RX 9070 XT and the RTX 3060. d3d12x:: gives 257 passed, 0 failed, 2 ignored, no SKIPPED, on both.

AMD run (listed as untested) on an RX 9070 XT, plus an RTX 3060: the new tests pass, and the d3d12x:: tests pass on both cards.

Head f8c774a applied on main b49be18, debug, Windows 11 Pro 26200, card chosen with XCL_ADAPTER, run with --nocapture:

  • cause filter (skipped_calls_are_counted_by_cause, the_log_line_names_only_the_causes_that_happened): 2 passed on the RX 9070 XT (RDNA4, driver 32.0.32029.2010). The panicked at bind.rs:1876: a panic in a put-off call line in the output is the test's own catch_unwind case.
  • cargo test -p xcl --lib -- d3d12x::: 257 passed, 0 failed, 2 ignored, no SKIPPED, on both the RX 9070 XT and the RTX 3060 (driver 32.0.16.1088). a_dispatch_that_cannot_be_put_off_is_counted_by_why is among them.

Not tested: the wave64 gpu:: paths (this change is in bind.rs / list_x.rs / pso_async.rs), the e2e tests, the new log line in a world run, Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In skipped_calls_are_counted_by_cause, the waited worker sleeps for 50 ms and then fails, but the test relies on dispatch reaching is_pending before that timer expires. If this test thread is descheduled for more than 50 ms under the parallel suite, the worker can finish first; refused stays None and the skip is counted as BuildFailed instead of the asserted BuildingNoWrapper.

Could the worker wait on an explicit release signal until after the refusal path is entered, or could the precedence be asserted directly with unbuilt_cause(waited, Some(Cause::BuildingNoWrapper)) after a completed failure? This is a source review at head f8c774a3; I did not run the test.

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could deferred compute ExecuteIndirect retain its console identity when it is put off? A final stand-in release removes both its async record and CONSOLE_COMPUTE marker. On replay, resolve_wait returns the original value, both marker checks fail, and this falls into PC ExecuteIndirect without the new released before submit count. Direct deferred Dispatch reaches the classifier in the same situation. A regression that releases a deferred indirect stand-in before replay would cover this; the existing Released fixture keeps the console marker and invokes direct dispatch. Exact-head source review at f8c774a3b81cef5a21899af803760ecf7e021927; no runtime release/submit test was run. AI-assisted review with Codex.

In world runs of the retail title DISPATCHES_SKIPPED reaches thousands and
nothing says which path skipped them. Keep the two totals and add a counter
per cause: pipeline still building at record time (split by why the call
could not be put off: bundle, predication, no segments left, no wrapper,
segment failed), stand-in released before the submit, build failed, no
translation, put-off dispatch dropped at the submit, two-pass pipeline,
and translated draws or dispatches whose arguments could not be bound.
ExecuteIndirect skips counted as DRAWS_SKIPPED are covered too. The
non-zero causes are printed in the periodic "console code so far" line.
…stand-in is released before the submit

The replayed call no longer asks for the console-compute marker, which the release forgets, and falls through to the PC ExecuteIndirect. The 50 ms sleep in skipped_calls_are_counted_by_cause is replaced by a check on the state after the build.
@grahamster2

Copy link
Copy Markdown
Collaborator Author

Both points are fixed in 428750f.

Timing test: the 50 ms sleep is gone. The refusal-wins-over-build-failure case no longer races a build against the call. It now waits for the build to fail, checks build_state is Failed and that unbuilt_cause(waited, None) is BuildFailed, then checks that unbuilt_cause(waited, Some(BuildingNoWrapper)) is BuildingNoWrapper and counts as exactly one skip (bind.rs:1867). That is your second suggestion. I did not keep a variant that calls dispatch while a worker is held, because the call blocks in resolve_wait until the build ends, and any signal that opens the gate only after the refusal was decided would need a hook into the wait that does not exist. The one thing this no longer exercises is the dispatch call site passing refused through, which the "still building, not put off" case above it still covers for the not-waited path.

I ran the cause filter three times in a row and the full lib suite three times. One full run failed two hle::d3d12x::sparse tests that this PR does not touch; they pass alone and in the other runs (details in the description).

AI use: Claude Code (Claude Sonnet 5.5) wrote this reply.

@grahamster2

Copy link
Copy Markdown
Collaborator Author

Good catch, it did not keep its identity, and it is fixed in 428750f.

What happened: a put-off ExecuteIndirect is recorded only when signature_dispatches(sig) && is_pending(raw_pso) && is_console_compute(raw_pso) (bind.rs:380). At the submit it is replayed through at_submit (list_x.rs:2726). If the title released the stand-in in between, standin_released (real.rs:1711) calls forget_pso, which removes the CONSOLE_COMPUTE entry, and pso_async::released drops the pending entry. On the replay resolve_wait returns the address unchanged, is_console_compute is false for both raw_pso and pso, so the check at bind.rs:430 did not match and the call went on to the PC ExecuteIndirect, with no skip and no released before submit count. A deferred direct Dispatch was fine: its branch (!is_translated_compute) does not look at the marker and reaches unbuilt_cause, which reports Released through the AT_SUBMIT flag (bind.rs:153). The old Released fixture kept the marker, so it only covered that Dispatch path.

Fix: the check at bind.rs:430 now also matches when AT_SUBMIT is set, since only a console compute call is ever put off, so the marker is not needed to know what the replayed call was. It is skipped and counted under Released. This is a behaviour change for that one case: before, the call reached the PC ExecuteIndirect; now it is skipped, like the Dispatch.

Test: skipped_calls_are_counted_by_cause has a new case (bind.rs:1883): a console compute pipeline registered then forgotten (marker gone, no stand-in), an ExecuteIndirect with a dispatch signature replayed through at_submit. It expects one skip under Released and no PC ExecuteIndirect call on the fake list. With the one-line fix removed, the test fails. It runs on a fake list, not a real release and submit, so the retail path is not run.

The smoke pair is refreshed on the new head (1647 frames vs 1642 on main, no device removals, no crashes), and the description is updated.

AI use: Claude Code (Claude Sonnet 5.5) wrote this reply.

@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 428750f, diff read, not a merge-check; it conflicts with main, so not built or run):

  • Main has moved too far for a rebase. bind.rs went from about 1.8k to 10k lines with about 25 skip sites, and put-off calls now go through defer_retained / PipelineResolution / execute_indirect_retained. Main already counts what happens to put-off calls (pso_async::PutOff: deferred / refused / recorded / skipped / dropped, from Merge nvidia-dev into main (makes #2572 mergeable) #3203), and frame dumps carry a per-call capture::Outcome. Record-time skips aren't broken down by cause on main yet.
  • The AT_SUBMIT.get() || change in execute_indirect (~430) is a behaviour fix inside a counters PR, and on main it no longer applies: the replay uses the kept resolution (is_compute(), failing closed on Unavailable), not the CONSOLE_COMPUTE marker.
  • refusal() (list_x.rs ~2666) works out why the split failed by repeating its checks afterwards; main's defer_with refuses for more reasons (poisoned recording, alloc_pool off, bounded waits), which would all be counted as "put-off failed".
  • The BuildingNoWrapper case (~1867) passes its cause straight to skip(), so it tests nothing, and the 13 names / counters are kept in step with the enum by hand (a new variant without a name panics inside a D3D12 hook).

Fine: relaxed counters, the test-only per-thread copies, the log format and build_state. Recommendation: close, and if record-time causes are still wanted, a new PR counting them at main's skip sites without the ExecuteIndirect change.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

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.

5 participants