Skip to content

D3D12.X: log how long a bind waits for a pipeline still being built - #899

Open
isaacwingate wants to merge 1 commit into
xcl-dev:mainfrom
isaacwingate:resolve-wait-diagnostics
Open

isaacwingate wants to merge 1 commit into
xcl-dev:mainfrom
isaacwingate:resolve-wait-diagnostics

Conversation

@isaacwingate

@isaacwingate isaacwingate commented Nov 24, 2026 •

Copy link
Copy Markdown

A bind of a pipeline that is not built yet waits in resolve_wait. When no worker has started the build, the bind does it itself. The wait lasts until the pipeline is built, unless XCL_PSO_WAIT_MS sets a limit (#891), and it leaves no trace in the log. On an NVIDIA GPU, the retail title of #505 had its threads sit there for 3–23 s at a time in the driver's compiler. It took a profiler of the title's threads to see it, and the title's hang watchdog ended the run (#505, #675). This change counts those waits and logs them, so a run's log says whether pipeline builds held the title up. It also logs a wait that is still going past a second, so the wait a watchdog ends the run in is in the log. Nothing else changes. Part of #505.

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs:
    • resolve_wait counts the calls that found their pipeline not built, graphics and compute apart (blocked()): how many, their total and longest time, and how many built the pipeline in the call.
    • The counts are logged at every power of two: pipelines waited for at a bind so far: N graphics (… ms, longest … ms, … built in the call), M compute (…).
    • Each wait of a second or more is logged when it ends (the first 32).
    • Tests: a_wait_that_builds_the_pipeline_is_counted_with_its_time, a_bounded_wait_is_counted_with_the_time_it_waited.
  • Waits still open:
    • A wait that has lasted a second is logged while it is still going: a compute pipeline has held up its caller for 1000 ms so far (being built in the call | waiting for a worker).
    • The thread xcl-pso-waits writes these lines. It checks every 250 ms, runs only while a wait is open, and writes at most 32 lines.
    • This closes the gap @throny and @Royalflamejlh found: the wait that runs into the watchdog never returns, so it was never counted.
    • Tests: a_wait_is_open_while_it_runs, an_open_wait_is_logged_once_when_it_passes_a_second.
  • crates/xcl/src/hle/d3d12x/real.rs: report.json gets the counts at the end of the run as d3d12.pipeline_waits: graphics, then compute, each as (waits, total µs, longest µs, built in the call).
  • Rebases:

Tested

  • NVIDIA GeForce RTX 5080, driver 32.0.16.2124, i9-12900K, Windows 11 build 26300, rustc 1.100.0; tests in debug, runs in release.
  • cargo test --workspace -- --test-threads=4 on 734e6e7: 963 passed, 0 failed, 43 ignored. The 23 SKIPPED lines:
    • no wave64: the wave64 forms of the lower / lower_dxil GPU tests, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
    • refused: the wave32 per-lane cases of f16_programs_on_the_gpu / f32_programs_on_the_gpu
    • heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
    • pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache
  • The retail title of Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505, XCL_NETWORK=0, 240 s, on main e50836b with the first version of this change:
    • logged 16 compute (92695 ms, longest 22694 ms, 16 built in the call), 0 graphics, and a line for each long wait (a compute pipeline held up its caller for 22694 ms (built in the call)).
    • The watchdog ended the run at 125 s.
    • With D3D12.X: compute pipelines are built ahead of their first bind #889 as well, the same run logged 1 compute (2 ms …).
  • Testers' runs in this thread on an RTX 4080 (nine runs), RTX 4070 under Wine, and RX 7900 XT under Wine (suite).

Regression run
Both with XCL_COHERENT_MB=4095 (without it the window is 512 MB or 4 GB, depending on the commit free at the start, #284), one after the other, with no input, so both stay in the title's menus.

main:

xcl-smoke v1
commit: 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331
gpu: NVIDIA GeForce RTX 5080
title: 8a66b2b2
seconds: 90
exit: 0x0
frames shown: 2535 (PresentX 2535)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16900 MB

PR:

xcl-smoke v1
commit: 734e6e78b0049cf1192d2ed2e18ecd2ebb8adc63
gpu: NVIDIA GeForce RTX 5080
title: 8a66b2b2
seconds: 90
exit: 0x0
frames shown: 2521 (PresentX 2521)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18271 MB

Not tested

  • AMD and Intel GPUs myself; other titles.
  • The 90 s regression runs stay in the title's menus, where no bind waited. The counts above come from the 240 s runs of the first version.
  • The open-wait lines and report.json's counts are covered by their tests only: I have not yet run the world load with this head.
  • A run with XCL_PSO_WAIT_MS set: the bounded path is covered by its test only.

AI use

  • Claude Code with Claude Opus 5.5: wrote the change and the tests, did the rebases, ran the tests and the runs, and wrote this description.

🤖 Generated with Claude Code

@throny

throny commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Nine world-loading runs of c3d5429 on an RTX 4080: the new lines show what holds the title up here, with one gap worth knowing about.

Tested

  • Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 4080 16 GB (driver 610.88, 32-lane waves), Intel i9-12900K, 64 GB; Rust 1.100.0 stable-x86_64-pc-windows-msvc; release. c3d5429 merged onto main 09940bb (clean merge), one build, run nine times in a row.
  • xcl run <folder> with XCL_NETWORK=0, XCL_ACTIVITY=1, one key press at the profile prompt; DXIL and driver-blob caches warm and kept between the runs.
run last present held up its caller lines after it last such line stop
1 78 s 1 compute, 13.3 s, built in the call 92.1 s 108.0 s
2 80 s 2 compute, 15.0 s + 13.5 s, built in the call 108.4 s 109.1 s
3 79 s 1 compute, 15.6 s, built in the call 94.9 s 108.1 s
4 78 s 1 compute, 13.3 s, built in the call 91.7 s 107.1 s
5 84 s 6 built in the call (28.6 s in all) + 8 waited for a worker (13.1 s in all) 110.9 s 113.0 s
6 80 s 1 compute, 13.7 s, built in the call 95.2 s 110.1 s
7 80 s 1 compute, 16.9 s, built in the call 97.1 s 109.0 s
8 78 s 1 compute, 13.8 s, built in the call 93.0 s 108.1 s
9 76 s 1 compute, 13.9 s, built in the call 91.3 s 106.0 s
  • Before the stall the waits are harmless: the last so far line of each run counts 128–256 compute binds that found their pipeline not built, 0.9–2.5 s in all, the longest 36–84 ms (run 5 apart: its last such line already includes the stall).
  • The stall starts with a bind that builds a compute pipeline in the call for 13–17 s. In seven of the nine runs that is the only line, and the stop comes 13–16 s after it.
  • The gap: the line is written when the wait ends. In those seven runs the stop arrives while the next bind is still inside its build, so the wait that actually runs into the watchdog is never logged. Debugger captures on main (my Retail title: null write at +0x2215c35 (#159) still hits on NVIDIA RTX 4070 Ti, with and without XCL_NETWORK=0 #232 comment) show two title threads inside resolve_wait at that point. A line when a wait passes, say, 1 s, or the waits still open in the thread dump at the crash, would show it.
  • The pipeline that is built differs from run to run (DXIL sizes 324–441 KB), and the one a run finished loads from its kept blob in the next. So each run gets one or two pipelines further, and the stop stays at 106–113 s.

One more observation, which I cannot tie to this PR: in 4 of the 9 runs the process did not exit after the exception (the log ends at the exception line, no thread list; my runner killed it after its timeout). main exited in all 11 runs I made without a debugger today; I have seen the same hang once with #754 and once on main after attaching a debugger earlier in the run.

Not tested

AI use

  • Claude Code (Claude Fable 5.2) read the diff, built the tree, ran the title and wrote this report. No game data attached.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head c3d5429 onto main 09940bb, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 710 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. pipeline-build wait logging green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

Linux (Wine + vkd3d-proton) + NVIDIA test of the rebased head f3b7dd6 on main 67a3735 + #684, 2 runs of 130 s: the new lines put numbers on the stall of #662 here, but the wait the title is stuck in when a run ends is not logged, because a wait is only counted when it returns.

Setup: Fedora 44 (kernel 7.2.9), Wine 11.21 Staging (Wayland driver), vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, VKD3D_CONFIG=ignore_shared_fence. RTX 4070 12 GB (driver 615.71.09, 32-lane waves), Ryzen 9 9950X3D, 64 GB RAM. Release, cross-compiled to x86_64-pc-windows-gnu (rustc 1.98.0), DXC 1.9.2609.5, XCL_NETWORK=0, XCL_PSO_PRELOAD=0, XCL_PSO_WAIT_MS unset. Retail title 1.0.2.1, the first-run screens completed once and no story progress, one A press at 44.8 s through XCL_PRESS_AT. #684 (e56dbc3) is merged under it, because main alone faults in copy_from before this point; f3b7dd6 merged onto that without conflicts.

Tested

  • cargo test --release -p xcl --lib a_wait_that_builds under Wine: 1 passed, 0 failed.
run 1 run 2
last pipelines waited for at a bind so far line 101.4 s: 128 graphics (611 ms, longest 317 ms, 95 built in the call), 348 compute (1,718 ms, longest 53 ms, 325 built in the call) 102.2 s: 128 graphics (965 ms, longest 630 ms, 99 built in the call), 339 compute (2,463 ms, longest 157 ms, 310 built in the call)
held up its caller lines 0 1, at 127.7 s: a compute pipeline, 25,200 ms, built in the call (1,076,292 B of DXIL)
last 2 s with a present 102.2 s 102.3 s
the run ended at the 130 s asked for, 28 s after the last present the same

So up to 102 s the title waited about 470 times for 2 to 3.5 s in all, and then one compute build held a thread for 25 s. Two runs of the head before the rebase (c3d5429 on main 09940bb) showed the same: about 450 short waits by 96 s, one wait of 23,678 ms logged in one run and none in the other, and the title's null write at game+0x23cf683 30 s after the last present.

Read

  • pso_async.rs:466 (note_blocked) is called at :386 and :401, after the wait has returned, so a wait that is still going when the run ends leaves no line. Run 1 has no held up its caller line although the title presented nothing for its last 28 s; in run 2 the 25.2 s wait is logged only when it ends, at 127.7 s. On the earlier head the run without a line ended with a title thread in pso_async::resolve_wait → real::build_compute → real::translated_compute_pso in XCL's end-of-process thread dump. Would a line when a wait passes one second, while it is still waiting, be in scope? It would name the wait that ends the run.
  • pso_async.rs:484: the summary line comes at every power of two of one kind's count, so the last one before the stall is from 101 s to 102 s and the counts at the end of a run are not in the log. They are available through blocked(); I did not find them added to report.json in this diff.

Not tested: the preload of #690 on (with it on, the title did not reach its world load in 100 s on this machine, so both runs had it off); XCL_PSO_WAIT_MS set; the rest of the test suite; AMD and Intel.

AI use: Claude Code (Claude Fable 5.2) read the diff, built the tree, ran the test and the title, read the logs and the thread dump and wrote this report.

@isaacwingate
isaacwingate force-pushed the resolve-wait-diagnostics branch from f3b7dd6 to b293619 Compare November 24, 2026 20:54
isaacwingate added a commit to isaacwingate/xcl that referenced this pull request Nov 24, 2026
pso_async means a graphics pipeline still being built to go on with its
stand-in, which draws nothing, while a worker builds it; only compute
pipelines are waited for (a skipped dispatch would leave its outputs
unwritten). But graphics_bound and ExecuteIndirect called resolve_wait,
which waits for the build - and builds it on the title's thread when no
worker has started it. With lazy pipelines that is every graphics
pipeline's first draw.

On an NVIDIA GPU the retail title of xcl-dev#505 had its threads held 1 - 5 s
per draw in the driver's compiler as its world loaded: 25 graphics binds,
33.2 s in all within 25 s (counted with xcl-dev#899's log), and its hang
watchdog ended the run. A test report on xcl-dev#889 (RTX 4080) found a title
thread held in bind::execute_indirect -> resolve_wait at the abort.

Draws and ExecuteIndirect now take their pipeline with resolve_for_bind:
a graphics one still being built goes to the workers and the draw uses
its stand-in (ExecuteIndirect skips, as it already did for a pending
one); a compute one is waited for as before. With this, the same world
load logged no graphics wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
A bind of a pipeline that is not built yet waits in resolve_wait, and
builds it itself when no worker has started it - until it is built unless
XCL_PSO_WAIT_MS sets a limit (xcl-dev#891), and with no trace in the log. On an
NVIDIA GPU a retail title's threads sat there for 3 - 23 s at a time in
the driver's compiler; it took a profiler of the title's threads to see
it, and the title's hang watchdog ended the run (xcl-dev#505, xcl-dev#675).

resolve_wait now counts the calls that found their pipeline not built,
for graphics and compute apart: how many, their total and longest time,
and how many built it in the call. A wait with a limit is counted with
the time it waited; a late pipeline's later binds, which do not wait, are
not. The counts are logged at every power of two, and each wait of a
second or more is logged (the first 32). Nothing else changes.

A wait still going is logged too, once it passes a second (from the
thread xcl-pso-waits, which runs only while a wait is open): the wait
a title's hang watchdog ends it in never returns, so it is never counted.
report.json gets the counts (pipeline_waits).

Measured with it on that title (RTX 5080, XCL_NETWORK=0, 240 s): 16
compute binds built their pipeline in the call, 92.7 s in all, the
longest 22.7 s; no graphics bind waited.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
Taken: the per-kind counters of resolve_wait (waits, total and longest time,
built in the call) and their line at every power of two, which integ did
not have.

Left out: the per-wait "held up its caller for N ms" warning. integ logs
each long wait already (try-psowait: "a bind has waited", "a bind waited
... in all", "on the binding thread"); a second line for the same event
is not wanted.

Conflicts: resolve_wait_for has want(), XCL_PSO_SKIP_HUGE and build_aside
in integ; a call is counted when its pipeline is not built, not late and
not known to be too big at entry. The PR's tests take 0x7E57_C00x stand-ins
(0x7E57_8001/2 are used by a_bound_pipeline_does_not_wait_for_the_big_
compiles_of_the_ones_built_ahead) and the 3-argument resolve_wait_for.
@isaacwingate
isaacwingate force-pushed the resolve-wait-diagnostics branch from b293619 to 734e6e7 Compare November 24, 2026 22:10
@isaacwingate

Copy link
Copy Markdown
Author

@throny @Royalflamejlh thanks, you both found the same gap. Pushed 734e6e7, rebased onto main 1d027e5:

  • A wait that is still going is now logged once it passes a second: D3D12.X: a compute pipeline has held up its caller for 1000 ms so far (being built in the call). A thread named xcl-pso-waits writes it; the thread runs only while a wait is open and writes at most 32 such lines. The wait that runs into the watchdog now shows up in the log before the stop. Tests: a_wait_is_open_while_it_runs, an_open_wait_is_logged_once_when_it_passes_a_second.
  • report.json has the counts at the end of the run, d3d12.pipeline_waits (graphics, then compute: waits, total µs, longest µs, built in the call).

Suite and regression runs on the new head are in the description.

@Royalflamejlh

Copy link
Copy Markdown
Contributor

@isaacwingate 734e6e7 closes the gap here: the waits that are open when the title stops presenting are now in the log, and the counts are in report.json. Linux (Wine + vkd3d-proton) + NVIDIA, 734e6e7 merged onto main 689f2db + #684, 1 run of 120 s, setup otherwise as in my comment above (A at 18.4 s this time).

  • Presents stopped at 88.1 s. The new thread logged 16 open waits, at 60.6, 88.9, 90.4, 100.6 and 119.2 s: 5 being built in the call and 11 waiting for a worker. One of the five at 119.2 s, a build in the call open since 118.0 s, had not returned when the run ended at 120.0 s, so the new line is its only trace in the log. For example
[   88.888][  724][WARN ] D3D12.X: a compute pipeline has held up its caller for 1033 ms so far (being built in the call)
[   88.888][  724][WARN ] D3D12.X: a compute pipeline has held up its caller for 1033 ms so far (waiting for a worker)
  • report.json has "pipeline_waits": [[23, 1651887, 457996, 10], [57, 163356355, 18448678, 34]]: 23 graphics waits of 1.7 s in all, and 57 compute waits of 163.4 s in all (summed over the waiting threads, up to five at once), the longest 18.4 s, 34 of them built in the call. The 57 are waits that returned: the one still open at the end is not in them.

Not tested: more than this 1 run; a run the title's watchdog ends (this one ended at the 120 s asked for); the cap of 32 lines; the suite on this head.

AI use: Claude Code (Claude Fable 5.2) built the new head, ran the title and wrote this reply.

Posted without review by a person: the account owner was away and reads replies later.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (734e6e7)

PR #899 adds wait diagnostics for binds that encounter a pipeline still being built. Tested detached commit 734e6e78b0049cf1192d2ed2e18ecd2ebb8adc63 with a clean worktree.

Hardware / environment

  • Windows x64 build 10.0.26200.0 on an AMD64 Family 23 Model 113 Stepping 0 CPU with 12 logical processors. The fixtures use CPU threads and synthetic pipeline jobs. No GPU adapter was used.
  • rustc 1.100.0 (0ef1bc386 2026-11-09) and DXC 1.9.2609.5 (01b62ad47). Cargo used the test profile with debug information and incremental compilation disabled.

Commands and results

  • cargo test --workspace --no-run compiled the workspace test executables (exit 0).
  • cargo test -p xcl --lib pso_async::tests:: ran with XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1 outside Invoke-ArcTest.ps1. The focused log contained 4 passed, 0 failed, 0 ignored, 0 skipped and reported a test duration of 0.40s.

Observed behavior

  • The caller-built graphics fixture verified that the wait and caller-build counters increased, and that both the total increment and longest wait were at least 50 ms. The log recorded one graphics wait of 50 ms built in the call.
  • The bounded compute fixture verified that a 30 ms budget returned the stand-in while the worker was still building, and that the compute wait count and elapsed total increased by the expected amounts.
  • The open-wait fixture saw the compute wait in the tracking table inside the caller's build closure and saw it removed on return. The threshold fixture used synthetic timestamps to verify that each wait became eligible once after reaching one second.

Not tested

  • The full GPU workspace suite and game smoke runs were omitted. This run did not exercise driver pipeline creation, the watchdog thread's warning output, or report.json generation in a game.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr899-focused.log and published.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

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.

7 participants