Repository navigation
D3D12.X: a long PC call pauses the GPU wait watchdog only up to a cap - #3305
grahamster2 wants to merge 1 commit into
Conversation
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)
|
Ran the capped PC-call wait tests at System
Results
What this adds Not tested 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. |
|
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.) |
|
Test report for #3305 at Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
merge-check claim |
|
merge-check claim withdrawn AI use: an agent posted this withdrawal. |
|
merge-check |
bmjask
left a comment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
wait_expiredresets an armed bridged GPU wait's clock on every watchdog tick whilepso_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 inexecute_indirect→ split →CreateCommandListwas blocked in the NVIDIA driver (D3DKMTDestroyAllocation2) waiting on the GPU while holding a D3D12Core lock. The submit thread insideq_execute_command_lists(a PC call, so the title stays held) was blocked on that lock inalloc_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: theHELDcounter) 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 untilcap_from(new inArmedGpuWait: 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) unlessXCL_WAIT_TIMEOUT_CONTINUE=1. So on main this cap turns the permanent freeze into that stop, or withXCL_WAIT_TIMEOUT_CONTINUE=1into 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()andheld_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_waittake both flags, and only the PC-call hold is capped;held_wait_cap()with the pureparse_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 buildArmedGpuWaitget the new field.README.md:XCL_HELD_WAIT_CAP_MSnext toXCL_WAIT_TIMEOUT_MS/XCL_GPU_WAIT_TIMEOUT_MS, and that past it the wait stops the title unlessXCL_WAIT_TIMEOUT_CONTINUE=1.Instant::now()):wait_expired_a_pc_call_hold_pauses_the_gpu_wait_watchdog_only_up_to_the_capfails without the change (checked by putting back the uncappedif heldreset);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
cargo build --release -p xcl)a0519dfdc862c79d6921cb71dffa76a81c72f9b7:cargo build --workspaceok;cargo test --workspace -- --test-threads=4: 2611 passed, 0 failed, 49 ignoredSKIPPEDlines 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 wave64SKIPPED gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu: no wave64SKIPPED gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu: no wave64SKIPPED gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu: no wave64SKIPPED gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu: no wave64SKIPPED gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu: no wave64SKIPPED gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu: const_mask, wave64: no wave64SKIPPED 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 wave64SKIPPED 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 wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 arithmetic, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 compares, wave64: no wave64SKIPPED 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 wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 rounding, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 three-source, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu: f32 transcendentals, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu: f64, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer arithmetic, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu: integer carries, wave64: no wave64SKIPPED gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu: mask_ff0_flbit, wave64: no wave64SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windowsSKIPPED 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.dllSKIPPED the title under the debug layer (dred: true): no d3d12SDKLayers.dllSKIPPED 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))xcllib 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 900withXCL_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 setsXCL_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:
this PR's head:
Not tested
XCL_WAIT_TIMEOUT_CONTINUE=1on this head.AI use