Skip to content

Tests: the GPU-wait watchdog releases a bridged Wait64 whose producer was never submitted - #2443

Open
tiagonleal wants to merge 2 commits into
xcl-dev:mainfrom
tiagonleal:test-wait64-unsubmitted-producer
Open

tiagonleal wants to merge 2 commits into
xcl-dev:mainfrom
tiagonleal:test-wait64-unsubmitted-producer

Conversation

@tiagonleal

@tiagonleal tiagonleal commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1452.

A Wait64BitValueX is bridged to a GPU queue.Wait whenever a Write64BitValueX for the same address has been recorded (try_gpu_wait). If that producer list is recorded but never submitted, the log shows prod=qNone ... wait-before-signal and recorded=<v> submitted=0x0 completed=0x0, and the waiting queue stays blocked until the sync watchdog signals the fence on the CPU after XCL_GPU_WAIT_TIMEOUT_MS (5 s by default). Nothing in the test suite arms a wait this way and waits for the real xcl-sync-watchdog thread: the only test of the expiry path, cpu_watchdog_signal_with_inflight_gpu_signal_completes_cleanly, signals the fence by hand.

What is in it

  • One #[cfg(test)] test in crates/xcl/src/hle/d3d12x/list_x.rs, unsubmitted_write64_producer_wait_is_released_by_the_watchdog (+82 lines, nothing outside mod tests).
  • It records a COMPUTE list with Write64 and a DIRECT list with the matching Wait64, arms the DIRECT list's wait on its queue through execute_with_waits_on (the COMPUTE list is never submitted), then signals a fence on that queue. It checks that the fence stays at 0 while the wait is armed (submitted_max == 0), that it reaches 1 after the watchdog timeout and not before, that the cell records the CPU release (no armed waits left, cpu_signaled_max == 0x677), and that the queue runs more work afterwards.
  • The timeout is a OnceLock read from the environment, so the test uses whatever it resolved to (5 s by default, about 5.4 s of wall time) instead of setting a process-wide variable that could race with the other tests. Same GPU-or-WARP device setup as the neighbouring tests.

It passes on main and only pins the current behaviour; no runtime code changes. It will also catch a change that stops expiring waits with no known producer, which is what #1046, #1045 and #1123 touch.

Tested

  • Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 5070 Ti 16 GB (driver 617.42), AMD Ryzen 7 9800X3D, 32 GB RAM, on 3f277701 plus this commit. No game was running when the runs started.
  • cargo test -p xcl --lib unsubmitted_write64_producer -- --nocapture: 1 passed; the log shows the bridged to GPU queue.Wait (... prod=qNone ...; wait-before-signal ...) line and then did not complete within 5000 ms ... released on CPU. The same test binary run alone 5 times: 5/5 passed (5.3 s each).
  • hle::d3d12x with --test-threads=4, 3 runs: 246 passed, 0 failed, 2 ignored each time.
  • cargo test --workspace -j 6 -- --test-threads=4, 3 runs: 1275 passed, 5 failed, 26 ignored each time; the new test passes in all 3. The 5 failures are the same on 3f277701 without this commit (1274 passed, 5 failed, 26 ignored): gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0 to _3 and gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier. 24 SKIPPED lines per run on this adapter (no wave64 and similar).

Notes on the test

  • The DIRECT list is deliberately not executed (execute_with_waits_on still arms the queue.Wait): ExecuteCommandLists goes through the queue hook, which would add the queue, blocked for 5 s, to present::QUEUES, and the sparse tests (flush_parked..., a_tile_decommitted...) and readback_routing_tests then wait on it and fail when they run in that window. I found this because the first version executed the list and failed 3 other tests in a parallel run.
  • When another test has installed that hook, ExecuteCommandLists also re-enters execute_with_waits_on, so a bridged wait can be armed twice for one list (seen with --test-threads=4); the assertions accept one or more armed waits for that reason. Observation only, not changed here.

Update, second commit 84ee77d (review request)

  • The test now installs a guard right after its registrations. Its Drop runs the cleanup on a normal return and on unwind: on_release for both lists, the fence, and the two SYNC_GRAPH entries. +22/−7, still nothing outside mod tests.
  • Failure path checked with a panic! forced right after the guard: hle::d3d12x with --test-threads=4 gave 245 passed, 1 failed (the forced one), 2 ignored. The panic is not in the commit.
  • At 84ee77d: the test alone 5 of 5; hle::d3d12x 3 runs, 246 passed, 0 failed each; cargo test --workspace --no-fail-fast -j 4 -- --test-threads=4 twice, 1353 passed, 5 failed, 46 ignored each time (25 SKIPPED lines), the same 5 failures as above. These totals count every test binary of the workspace.

Regression run

xcl-smoke v1
commit: 3f2777019544c0ada2cd294aa792d3c378ff0df8
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1614 (PresentX 1614)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15046 MB
xcl-smoke v1
commit: 84ee77d1ba488413e901ad64213883387cc4fdf9
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1594 (PresentX 1594)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15781 MB

First block: main 3f277701; second: this PR's head 84ee77d1; same title, built from clean trees, run again after the second commit.

Not tested

  • XCL_GPU_WAIT_TIMEOUT_MS set to a non-default value (the value is read once per process).
  • Linux / Wine + vkd3d-proton, Intel and AMD GPUs, WARP (the test falls back to it, but it was run on the GPU).

AI use

  • Claude Code with Claude Sonnet 5.5: wrote the test and this description and ran the tests on my machine. Claude Code with Claude Fable 5.2: chose the case from our run logs and reviewed the diff.

🤖 Generated with Claude Code

… was never submitted

Part of xcl-dev#1452.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 19:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head 9dd81efd3145e6456cbc72025794eb3b9949c831 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1355 passed, 3 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 9dd81efd3145e6456cbc72025794eb3b9949c831
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1557 (PresentX 1557)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14277 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@SlopTart

Copy link
Copy Markdown

gpu_ suite (cold cache): 160 passed / 4 failed, no crashes. The four are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, depth-buffer state refusal, and gpu_promoted_uav_clear_values_pass_create_committed_resource (report); none caused by this PR.
Targeted run of the new watchdog tests (unsubmitted_write64_producer_wait_is_released_by_the_watchdog and friends): 3 passed, including the 5 s release path, on this lane. Related to the failures I logged on #2439: the two d11_* tests that hang until the watchdog fires are the same mechanism, and this PR's harness approach looks compatible.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@luckyteagirl

Copy link
Copy Markdown
Contributor

One test-isolation issue: this fixture calls on_create for both lists and records the fake va in the sync graph, but on_release and the graph/fence cleanup run only after the assertions and the final expect. If the watchdog behavior regresses, an assertion panics first; the COM lists and cell then drop while their raw addresses remain in global test state. Later tests running in the same process can encounter stale registrations and report secondary failures unrelated to their own code.

Could you install a small scope guard immediately after registration to run the existing cleanup on both normal return and unwind? This is especially useful for a test whose purpose is to catch a timeout/failure path.

Read-only review of head 9dd81efd3145e6456cbc72025794eb3b9949c831; I did not build or run it. AI use: OpenAI Codex and a Luna subagent inspected the diff and drafted this finding.

…d assertion too

The test registered its two fake command lists and the fence in the global
sync graph, but released them only after its last assertion. A failed
assertion left raw addresses of dropped COM objects in global state, so other
tests in the same process could fail for unrelated reasons.

A local guard created right after the registrations now runs the same cleanup
(on_release for both lists, forget_fence_for_test, title_fences and cells
entries) on normal return and on unwind, before the COM lists and the cell
drop. It takes over poisoned locks instead of panicking.

With a deliberate panic after the guard, only that test failed and the other
245 tests of hle::d3d12x passed in the same process. Test alone x5 and
hle::d3d12x x3: pass. cargo test --workspace --no-fail-fast x2: 1353 passed,
5 failed, 46 ignored (fuzz_validate_and_gpu_0..3 and
lower_dxil::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier,
which also fails without this change), 25 SKIPPED lines.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@luckyteagirl

Copy link
Copy Markdown
Contributor

Focused RX 6800M report for exact PR head 9dd81efd3145e6456cbc72025794eb3b9949c831 (clean detached worktree).

Tested

  • AMD Radeon RX 6800M, driver 30.0.13002.13003; Windows 11 Home build 26200; Rust 1.99.0 MSVC.
  • XCL_ADAPTER=6800M XCL_REQUIRE_GPU=1 XCL_DIRECT_DXIL=1 cargo test --locked -p xcl --lib -j 2 unsubmitted_write64_producer_wait_is_released_by_the_watchdog -- --test-threads=1 --show-output: 1 passed, 0 failed, 0 ignored, 0 skipped. The expected 5-second GPU wait timeout released on CPU; no SKIPPED record appeared. Resource guard: none. Log: filter-unsubmitted-write64-watchdog.log.

Not tested

  • Full test suite, retail-title smoke, other GPUs.

AI use

  • OpenAI Codex (exact model variant unavailable in this session) ran this focused test and drafted this report.

@tiagonleal

Copy link
Copy Markdown
Contributor Author

Done in 84ee77d. The test now installs a guard right after the registrations, and its Drop runs the cleanup that used to sit at the end of the test: on_release for both lists, the fence, and the two SYNC_GRAPH entries. It runs on a normal return and on unwind, and it takes over a poisoned lock so it cannot panic a second time.

To check the failure path I forced a panic! right after the guard and ran cargo test -p xcl --lib -- hle::d3d12x --test-threads=4: 245 passed, 1 failed (the forced one), 2 ignored. The panic is not in the commit.

The suite counts and the two smoke blocks in the description are for the new head.

@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

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.

6 participants