Skip to content

Tests: the ExecuteIndirect bind test takes the warp-test lock - #3609

Open
fromthemoonx wants to merge 1 commit into
xcl-dev:mainfrom
fromthemoonx:tests/bind-execute-indirect-takes-warp-lock
Open

fromthemoonx wants to merge 1 commit into
xcl-dev:mainfrom
fromthemoonx:tests/bind-execute-indirect-takes-warp-lock

Conversation

@fromthemoonx

@fromthemoonx fromthemoonx commented Dec 1, 2026 •

Copy link
Copy Markdown

hle::d3d12x::bind::tests::later_queue_completion_during_sleep_reclaims_before_wait_deadline fails in parallel runs of its module: 10 of 30 runs of hle::d3d12x::bind::tests:: at --test-threads=8 on main 6bfb5c5 (bind.rs:10023, result is Stopped, not Progressed). It does not fail at 1 or 2 threads.

The fence-wait tests take lock_warp_tests because they count on the process-wide fenced two-pass batches (FENCED_RES / FENCED_BYTES). execute_indirect_reads_the_arguments_written_before_it does not take it. Once another test has hooked the device, its allocator Reset / Release go through alloc_reset / alloc_release -> console_list::allocator_reset -> release_allocator_res, which calls reclaim_fenced. I took backtraces of every reclaim_fenced call from that test in parallel runs (scratch change, not in this PR); run alone it makes none. In a failing run (an earlier scratch log of every caller) it reclaimed while FENCED_BYTES was 67371008, the waiting test's two batches (64 MiB + 256 KiB). It took the later batch the waiting test had just completed. The waiting test's own reclaim then found nothing, its scripted clock ran to the deadline, and wait_oldest_fenced_until returned Stopped. wait_oldest_fenced_reclaims_in_flight_buffer_before_refusing also failed once in 30 module runs of the same tree with a test-only PR merged (#3511); it did not fail in the 60 runs with this change.

What is in it

  • crates/xcl/src/hle/d3d12x/bind.rs (tests only): execute_indirect_reads_the_arguments_written_before_it takes lock_warp_tests like the other tests that reach the fenced batches. No runtime code changes. bind.rs counts as a runtime file for pr_check.py, so this needs the test-only label instead of a smoke pair.

Tested

  • RTX 3060 12 GB (driver 610.88), Ryzen 7 5700X, Windows 11 Pro 26300, rustc 1.100.0, debug.
  • hle::d3d12x::bind::tests:: --test-threads=8: 60 of 60 runs pass with this change (30 more on the current head 756325f8, rebased onto main f07e426d, also 30 of 30), against 20 of 30 on main 6bfb5c5 (10 failures of later_queue_completion_during_sleep_reclaims_before_wait_deadline).
  • execute_indirect_reads_the_arguments_written_before_it still runs here (not skipped): 1 passed.
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on 756325f8: 2904 passed, 0 failed, 51 ignored. SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same as main.

Not tested

  • AMD, and machines with fewer cores, where the module's thread count differs.
  • The failure rate in whole-suite runs: I measured it at module level only (the whole suite ran once, above).

AI use

  • Claude Code (Claude Opus 5.5): found the cause with the logging run, wrote the change and this description, and ran the tests above.

🤖 Generated with Claude Code

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 45ab946, diff read, not a merge-check; checks red):

  • The new comment names a path the test does not take. The comment at bind.rs ~5592 (and the description) says the test's submits reclaim the fenced batches through two_pass_submitted, but two_pass_submitted (~162-195) never calls reclaim_fenced, and the test submits with queue.ExecuteCommandLists on a queue it never adopts (~5680), so the submit does not reach alloc_pool::two_pass_after_submit either. The reclaim comes from another caller of reclaim_fenced (release_allocator_res or take_free, ~653 / ~667); the comment should name that, or the next person chasing this race will look in the wrong place.

Fine: test-only; the guard is the first local, so it is held until the test's lists and allocators are dropped, and taking the same lock_warp_tests the fence-wait tests use is the right fix for sharing FENCED_RES / FENCED_BYTES. The red check is PR description asking for smoke blocks because bind.rs counts as a runtime file; the test-only label is what clears it.

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

later_queue_completion_during_sleep_reclaims_before_wait_deadline failed
10 of 30 runs of hle::d3d12x::bind::tests:: at --test-threads=8 on main
6bfb5c5 (`result` Stopped, not Progressed), never at 1 or 2 threads.

The fence-wait tests take lock_warp_tests because they count on the
process-wide fenced two-pass batches (FENCED_RES / FENCED_BYTES).
execute_indirect_reads_the_arguments_written_before_it does not. Once
another test has hooked the device, its allocator Reset / Release go
through alloc_reset / alloc_release -> console_list::allocator_reset ->
release_allocator_res, which calls reclaim_fenced (backtraces of every
reclaim_fenced call from that test in parallel runs; run alone it makes
none). In a failing run it reclaimed while FENCED_BYTES held the waiting
test's two batches: it took the later batch the test had just completed,
so the test's own reclaim found nothing, its scripted clock ran to the
deadline and the wait stopped.

The test now takes the same lock. 60 of 60 module runs at 8 threads pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fromthemoonx
fromthemoonx force-pushed the tests/bind-execute-indirect-takes-warp-lock branch from 45ab946 to 756325f Compare December 1, 2026 21:07
@fromthemoonx

Copy link
Copy Markdown
Author

You're right, thanks: two_pass_submitted does not call reclaim_fenced. I had placed the call at bind.rs:221 in the wrong function; it is in TwoPassBuf::try_make_with_cap.

I took backtraces of every reclaim_fenced call from execute_indirect_reads_the_arguments_written_before_it (scratch change, not pushed). Run alone, the test makes none. In parallel runs of hle::d3d12x::bind::tests:: at 8 threads, all of its calls come through the allocator hooks another test has installed on the device:

  • alloc_reset -> reset_pc_allocator -> console_list::allocator_reset -> release_allocator_res -> reclaim_fenced
  • alloc_release -> alloc_pool::forget -> console_list::allocator_reset -> release_allocator_res -> reclaim_fenced

The comment and the commit message now name that path. The head is 756325f8, rebased onto main f07e426d; the description is updated. On that head: hle::d3d12x::bind::tests:: at 8 threads 30 of 30, and the whole suite 2904 passed, 0 failed, 51 ignored.

AI use: Claude Code (Claude Opus 5.5).

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Follow-up review (head 756325f, since 45ab946, diff read, not a merge-check; checks red):

  • The new comment names a path the test does not take: fixed. The comment at bind.rs ~5592 now says the reclaim comes from allocator Reset / Release through alloc_reset / alloc_release to release_allocator_res, which is the real path: alloc_reset (real.rs ~11578) and alloc_release (~11546, via alloc_pool::forget) both reach console_list::allocator_reset (~432), which calls release_allocator_res and so reclaim_fenced (bind.rs ~653); the test calls alloc.Reset() (~5714) and drops its allocators.

New: none.

Fine: the code is otherwise unchanged and test-only. PR description is red only because bind.rs counts as a runtime file; the test-only label clears it.

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

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-pr-check Failing the PR description check (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants