Skip to content

D3D12.X: a long PC call pauses the GPU wait watchdog only up to a cap - #3305

Open
grahamster2 wants to merge 1 commit into
xcl-dev:mainfrom
grahamster2:pr/held-wait-cap
Open

grahamster2 wants to merge 1 commit into
xcl-dev:mainfrom
grahamster2:pr/held-wait-cap

Conversation

@grahamster2

Copy link
Copy Markdown
Collaborator

wait_expired resets an armed bridged GPU wait's clock on every watchdog tick while pso_async::title_held() is true. A hold can depend on the very GPU wait it pauses, and then the title freezes for good. Seen on an RTX 3080 in a retail title (stacks from an external sampler): a title thread in execute_indirect → split → CreateCommandList was blocked in the NVIDIA driver (D3DKMTDestroyAllocation2) waiting on the GPU while holding a D3D12Core lock. The submit thread inside q_execute_command_lists (a PC call, so the title stays held) was blocked on that lock in alloc_pool::reset_list, and the GPU was stuck behind one armed wait that the watchdog never released.

The two kinds of hold are now told apart (pso_async::held_for_build, pso_async::held_by_pc_call). A hold for a pipeline build (a bind or submit waiting for one: the HELD counter) still pauses the clock for as long as it lasts. A hold by a long PC call, the kind that can wait on the GPU as in the freeze above, pauses it only until cap_from (new in ArmedGpuWait: when the wait was armed, moved on while the title is held for a build, so build-hold time does not use up the cap) + the cap: XCL_HELD_WAIT_CAP_MS, default 20000, 0 = no cap. After that the wait expires on the normal watchdog timeout, so about 25 s with the defaults. The 20 s default is not tuned on a measurement: nothing here shows it is long enough for every submission whose driver call does a long compile of its own. On a branch from before "fail closed on unproven wait timeouts" the wait was released 25 s after it was armed and rendering resumed. On main an expired wait without a proven cycle stops the title (stop_for_unresolved_wait) unless XCL_WAIT_TIMEOUT_CONTINUE=1. So on main this cap turns the permanent freeze into that stop, or with XCL_WAIT_TIMEOUT_CONTINUE=1 into the release seen in that run. It also means that a PC-call hold longer than the cap (for example a long load that keeps a submission or texture placements going without a frame) now ends in that stop by default, where before it paused the watchdog for as long as it lasted.

No issue.

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs: held_for_build() and held_by_pc_call() (now public); title_held() is their OR, unchanged.
  • crates/xcl/src/hle/d3d12x/list_x.rs: ArmedGpuWait::cap_from; wait_expired / wait_expired_at / take_expired_gpu_wait take both flags, and only the PC-call hold is capped; held_wait_cap() with the pure parse_held_wait_cap(); the PC calls are not looked at while a build hold pauses the clock anyway; a warning (logged at most 8 times) when a wait expires although a PC call holds the title. The existing tests that build ArmedGpuWait get the new field.
  • README.md: XCL_HELD_WAIT_CAP_MS next to XCL_WAIT_TIMEOUT_MS / XCL_GPU_WAIT_TIMEOUT_MS, and that past it the wait stops the title unless XCL_WAIT_TIMEOUT_CONTINUE=1.
  • Tests (times from a fixed base forward, so nothing is subtracted from Instant::now()): wait_expired_a_pc_call_hold_pauses_the_gpu_wait_watchdog_only_up_to_the_cap fails without the change (checked by putting back the uncapped if held reset); wait_expired_a_build_hold_pauses_the_gpu_wait_watchdog_past_the_cap (a build hold never lets a wait expire early, and a PC-call hold after a long build hold gets the whole cap from its end); held_wait_cap_parses_unset_zero_junk_and_a_value.

Tested

  • NVIDIA GeForce RTX 3080 10 GB, driver 610.88; AMD Ryzen 5 7600X; Windows 11 build 10.0.26200.9974; rustc 1.94.0 (4a4ef493e 2026-03-02); tests in the debug profile, smoke runs on a release build (cargo build --release -p xcl)
  • on a0519dfdc862c79d6921cb71dffa76a81c72f9b7: cargo build --workspace ok; cargo test --workspace -- --test-threads=4: 2611 passed, 0 failed, 49 ignored
  • 29 SKIPPED lines on this adapter (no wave64 on NVIDIA, no heap windows, no D3D12 debug layer):
    • SKIPPED gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole: no wave64
    • SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64
    • SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64
    • SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64
    • SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu: const_mask, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))
    • SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 arithmetic, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))
    • SKIPPED gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu: f16 packed, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 conversions, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: f64, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64
    • SKIPPED gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu: mask_ff0_flbit, wave64: no wave64
    • SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64
    • SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64
    • SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
    • SKIPPED hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap: no heap windows (opt-in: XCL_HEAP_WINDOWS=1)
    • SKIPPED the title under the debug layer (dred: false): no d3d12SDKLayers.dll
    • SKIPPED the title under the debug layer (dred: true): no d3d12SDKLayers.dll
    • SKIPPED uploads_start_from_each_subresources_state: no D3D12 debug layer (The application requested an operation that depends on an SDK component that is missing or mismatched. (0x887A002D))
  • On an earlier revision of this branch the first run of that command stopped early once: the xcl lib test binary exited with STATUS_ACCESS_VIOLATION (0xc0000005) while GPU tests (gpu::agility, gpu::bvh, gpu::dxil::bitstream) were running, and printed no counts. It did not come back in two lib-only runs then, nor in the whole-suite run above, which passed on its first try.

Regression run

  • scripts/smoke.ps1 -Game <title folder> -Seconds 60 -StartupTimeoutSeconds 900 with XCL_DEVICE_TYPE=lockhart XCL_PREPARE=0 (Series S mode as in the contributor's runs; no startup shader preparation, so pipelines are built in game) (smoke.ps1 sets XCL_NETWORK=0); same retail title, same settings for both runs. Both stay on the title's first screens (about 660 draws per 2 s) for the 60 s.

main:

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

this PR's head:

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

Not tested

  • The freeze itself was not reproduced on this PR's head commit. The 25 s release was seen on an older branch, before main's fail-closed wait timeout. The 60 s smoke run stays on the title's first screens and does not reach this freeze.
  • PC-call holds longer than 20 s in long loads: not seen in the smoke run; with this change such a hold ends in the stop on main (default), which no run here exercised.
  • AMD GPUs, other titles, and XCL_WAIT_TIMEOUT_CONTINUE=1 on this head.

AI use

  • Claude Code with Claude Opus 5.5: wrote the code and tests, ran the tests and smoke runs, drafted this description. A separate Claude Code agent that did not write the change reviewed the diff adversarially and its findings were fixed before opening.

wait_expired reset an armed bridged wait's clock on every watchdog tick
while pso_async::title_held() was true, and a hold can depend on the
very GPU wait it pauses. Seen frozen for good: a title thread in
execute_indirect -> split -> CreateCommandList blocked in the driver
(D3DKMTDestroyAllocation2) waiting on the GPU while holding a D3D12Core
lock; the submit thread inside q_execute_command_lists (a pc_call, so
the title stays held) blocked on that lock in alloc_pool::reset_list;
the GPU stuck behind one armed wait the watchdog never released.

The two kinds of hold are told apart now (pso_async::held_for_build,
held_by_pc_call). A hold for a pipeline build still pauses the clock for
as long as it lasts. A hold by a long PC call - the kind that can wait
on the GPU, as in the freeze above - pauses it only until cap_from
(new in ArmedGpuWait: when the wait was armed, moved on while it is held
for a build) + the cap (XCL_HELD_WAIT_CAP_MS, default 20000,
0 = no cap); after that the wait expires on the normal timeout. Seen on
an RTX 3080, stacks from an external sampler: on a branch from before
"fail closed on unproven wait timeouts" the wait was released 25 s
after it was armed and rendering resumed. On main an expired wait
without a proven cycle stops the title (stop_for_unresolved_wait)
unless XCL_WAIT_TIMEOUT_CONTINUE=1, so here the cap turns the permanent
freeze into that stop, or with XCL_WAIT_TIMEOUT_CONTINUE=1 into the
release seen in that run. A PC-call hold longer than the cap in a long
load now ends the same way.

README documents XCL_HELD_WAIT_CAP_MS next to the other wait timeouts.

Assisted-by: Claude Code (Claude Opus 5.5)
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) labels Nov 29, 2026
@Aniseto

Aniseto commented Nov 29, 2026

Copy link
Copy Markdown

Ran the capped PC-call wait tests at a0519dfd on an NVIDIA Blackwell desktop part.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib wait_expired_a_pc_call_hold_pauses_the_gpu_wait_watchdog_only_up_to_the_cap -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib wait_expired_a_build_hold_pauses_the_gpu_wait_watchdog_past_the_cap -- --test-threads=1: 1 passed, 0 failed, 0 ignored.
  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib held_wait_cap_parses_unset_zero_junk_and_a_value -- --test-threads=1: 1 passed, 0 failed, 0 ignored.

What this adds
All three new tests pass: a long PC-call hold pauses the GPU wait watchdog only up to the cap, a pipeline-build hold still pauses it past the cap, and the cap parses unset/zero/junk/value inputs. The thread has no comments yet, so this is the first datapoint in it and the first from an RTX 5070 Ti on driver 32.0.16.2140. These are CPU-side timing tests; no title run or device-hang reproduction was attempted here.

Not tested
A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.

@Foniass

Foniass commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Review (diff read, not a merge-check):

Suggested verdict: not yet (exempt in-call pipeline builds, or make the cap opt-in).

(Review written with Claude Code, Claude Opus 5.5; the first point was traced in the code.)

@ClosetPie107

Copy link
Copy Markdown

Test report for #3305 at a0519dfdc862c79d6921cb71dffa76a81c72f9b7, against its merge-base with main, fa204595, under Wine on AMD.

Tested

Not tested

  • native Windows
  • NVIDIA
  • the gpu:: tests in the suite runs
  • the workspace's other crates and integration tests (only -p xcl --lib)
  • a game run (no regression block)

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: d0832e6
head: a0519df
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2893 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (list_x.rs +136/-15, pso_async.rs +8/-2, README). Past 20 s a long PC call no longer pauses the GPU wait watchdog, so about 25 s after a wait was armed it expires and main's stop_for_unresolved_wait stops the title (the PR says so). Findings: (1) some PC calls are the title's own pipeline compiles: the whole-form build on a title thread is held as a PC call (dispatch_chain.rs ~195, whole(true), the default when XCL_CS_PSO_WAIT_MS is unset) and so is finish_pso (real.rs ~4996), and main's own comment (dispatch_chain.rs ~339) records a render thread in the driver for over two minutes on a large whole form. A GPU wait armed during such a compile is now stopped at ~25 s, where main paused the watchdog. Leaving title-thread pipeline compiles out of the cap, or measuring them against it, would avoid stopping a title that was only compiling. (2) Every build hold restarts the cap (~2903), so if a bind waits for a build during the freeze the cap never applies (speculative: a worker's driver call stuck behind the same lock). (3) The 20 s default isn't based on a measurement (the PR says so). Fine: the wait_expired_at tests use fixed times, build holds behave as before, there's no new lock order, and it's independent of #3306 / #3307.
performance: 60 s smoke of a retail title, main d0832e6 vs this merge (56bba02e): 1516 -> 1673 frames shown (110 %; last presents per 2 s: 60 60 60), peak commit 18133 -> 17101 MB, 0 device removals, 0 crashes. This run doesn't show whether a long PC call overlapped a GPU wait, so it doesn't settle finding (1).
verdict: not yet: the cap also stops titles whose GPU wait spans a long title-thread pipeline compile (finding 1), which main waited out
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

@brainhay5

Copy link
Copy Markdown

merge-check claim
head: a0519df

@brainhay5

Copy link
Copy Markdown

merge-check claim withdrawn
Our automated merge-check loop claimed this PR and then stopped before posting a check — two loops were running at once and both are now shut down. No check from us is coming, so this claim is void and the head is free for someone else to take.

AI use: an agent posted this withdrawal.

@Hurtibabi

Hurtibabi commented Dec 1, 2026 •

Copy link
Copy Markdown

merge-check
base: 6bfb5c5
head: a0519df
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2907 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no d3d12SDKLayers.dll, 2 no heap windows, 1 no D3D12 debug layer, 1 cannot disable the driver cache without Developer Mode); failing: none
review: read the whole diff (list_x.rs, pso_async.rs, README). (1) Confirms Foniass's finding: the cap applies to every pc_call, and title-thread pipeline compiles register one (real/dispatch_chain.rs:195 whole(true), real.rs:5053 finish_pso when not on a build worker). The code's own notes give 22–172 s for such compiles (pso_async.rs:11203, dispatch_chain.rs:339). A bridged GPU wait armed during such a compile now expires about 25 s after cap_from and stop_for_unresolved_wait stops the title, where main paused the watchdog for the whole compile. (2) Every watchdog tick with a build hold moves cap_from to now (wait_expired_at), so the cap never applies while some bind waits for a build; if that build is stuck behind the same driver lock as in the described freeze, the freeze stays (not reproduced, reasoned from the code). (3) The 20 s default is not based on a measurement (the PR says so). Fine: the three new tests run and pass here, the fixed-time tests subtract nothing from Instant::now(), build holds behave as before, no new lock is taken in the watchdog (held_by_pc_call was already called through title_held). No duplicate found: no open or merged PR makes this change, and #1607 has no group for it. Not tested: no retail title run (Tier 2 smoke) on this merge, the freeze itself, AMD.
performance: reasoned, not measured: per watchdog tick the same checks as before (the PC-call lookup is now skipped while a build hold is active), one more Instant per armed wait. No frame-time or memory cost by default expected; the behaviour change is that a PC-call hold over ~20 s now stops the title.
verdict: not yet: the cap also stops titles whose GPU wait spans a long title-thread pipeline compile (finding 1), which main waited out; no retail smoke run on this merge
hardware / tool and model: NVIDIA GeForce RTX 4090 (driver 621.40 / 32.0.16.2140), Intel Core i7-14700K, Windows 11 Pro 10.0.26200.9974, rustc 1.100.1, debug / Claude Code, Claude Opus 5.5 (claude-opus-5-5)

@bmjask bmjask 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.

Review of a0519dfd: 3 finding(s). 2 are inline. These are on lines outside the diff:

crates/xcl/src/hle/d3d12x/real/dispatch_chain.rs:226: A title thread waiting synchronously for a whole-form compute pipeline compile registers a pso_async::pc_call(), not a Held build hold, so the new cap applies to what is really a pipeline build. A late giant compile serialized behind real::huge_compile_turn keeps the thread in Chain::whole(true) past 20 s. held_for_build() is false and held_by_pc_call() is true, so the armed GPU wait expires at about 25 s and stop_for_unresolved_wait ends the title. Before this PR the clock stood for the whole compile, and the PR says build holds stay uncapped.


These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

// (time held for a build does not count towards the PC-call cap)
aw.cap_from = now;
}
let pc_call_pauses = pc_call_held && cap.map_or(true, |cap| now.saturating_duration_since(aw.cap_from) < cap);

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.

The cap counts from when the wait was armed, so a known, legitimate long run of PC calls without a frame now stops the title by default. The PcCall doc in pso_async.rs (~3457) records a retail title placing 16 384 textures in 29 s without a frame. A GPU wait armed near the start of that load stops pausing at 20 s and expires at about 25 s, and with XCL_WAIT_TIMEOUT_CONTINUE unset main calls stop_for_unresolved_wait. A load that used to finish now ends the title.

fn wait_expired_at(aw: &mut ArmedGpuWait, build_held: bool, pc_call_held: bool, now: Instant, timeout: Duration, cap: Option<Duration>) -> bool {
if build_held {
// (time held for a build does not count towards the PC-call cap)
aw.cap_from = now;

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.

Build holds stay uncapped and global (HELD counts any bind or submit), and any build hold resets cap_from for every armed wait, so the targeted freeze can still be permanent. In the described deadlock (a driver call holding the D3D12Core lock while waiting on the GPU), a pipeline worker's Create*PipelineState can block on the same lock. The title bind waiting on it (build_foreground -> Held::new()) keeps held_for_build() true forever. The same happens if any other title thread waits on a build at least once every 20 s: cap_from keeps moving and the stuck wait never expires.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants