Skip to content

Tests: wait for every quarantine mark before draining sparse tiles - #2775

Open
sage-sage wants to merge 1 commit into
xcl-dev:mainfrom
sage-sage:tests/sparse-quarantine-wait
Open

sage-sage wants to merge 1 commit into
xcl-dev:mainfrom
sage-sage:tests/sparse-quarantine-wait

Conversation

@sage-sage

Copy link
Copy Markdown

Two sparse tests fail now and then in parallel runs of the lib tests:

  • a_tile_decommitted_and_committed_again_keeps_its_video_memory fails at assert!(s.drain_quarantined()).
  • flush_parked_does_not_free_or_reuse_tiles_while_unmap_is_in_flight fails with "completed unmap batch should drain after fence completion".

The tests wait for the sparse queue's fence and then expect the quarantined tiles to drain. But quarantine_tiles also puts a mark on every queue in present::known_queues, and that list keeps every queue that ever went through note_execute, including queues of other tests that can still have work in flight. So a batch can rightly stay quarantined after the sparse queue is done. The runtime is right to wait. Now the tests wait too, for every mark of the quarantined batches (at most 30 s), before they check. Test-only change.

What is in it

  • crates/xcl/src/hle/d3d12x/sparse.rs (tests only): a wait_for_quarantine helper, called after s.wait_for(s.value) in the three places that then expect the batches to drain.

Tested

  • Setup: RTX 4080 SUPER (driver 621.40), Ryzen 5 7600X, Windows 11 26H2 build 26300.10075, rustc 1.100.0, debug build, base b49be18.
  • cargo test --workspace -- --test-threads=4: 1435 passed, 0 failed, 47 ignored, 29 SKIPPED lines, the same as main on this machine (wave64, debug layer, Developer Mode, heap windows).
  • The whole lib test binary at --test-threads=12, main's sparse code (main, or main plus an unrelated test-only fix in another file):
    • 9 of 450 runs had one of these two tests fail.
    • With this change, 0 of 300 runs.
    • 150 of the runs on each side alternated, run for run, so both saw the same load.
    • The other failures with this change were the known a_dispatch_with_a_pipeline_still_building_waits_at_the_submit, placed_title_textures_share_vram_and_preserve_pixels and writes_land_after_the_queue flakes.

Regression run

  • None needed: test-only change (only #[cfg(test)] mod tests in sparse.rs changes).

Not tested

AI use

  • Claude Code, Claude Opus 5.5: found the cause in repeated parallel runs, wrote the change, ran the tests and wrote this description.

🤖 Generated with Claude Code

Two sparse tests failed now and then in parallel runs of the lib tests
(a_tile_decommitted_and_committed_again_keeps_its_video_memory at
`assert!(s.drain_quarantined())`, and
flush_parked_does_not_free_or_reuse_tiles_while_unmap_is_in_flight at
"completed unmap batch should drain after fence completion").

The tests wait for the sparse queue's fence and then expect the
quarantined tiles to drain. But quarantine_tiles also signals a mark on
every queue in present::known_queues, which keeps every queue that ever
went through note_execute. In a parallel run those include other tests'
queues, which can still have work in flight, so a batch can stay
quarantined after the sparse queue is done. The runtime is right to
wait; the tests now wait for every mark of the quarantined batches too
(at most 30 s) before checking.

Measured on an RTX 4080 SUPER, whole lib test binary at
--test-threads=12: main 9 sparse failures in 450 runs, this change 0 in
300 (150 of them alternated with main runs).

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DarkPanda69

Copy link
Copy Markdown

AMD run (listed as untested): the sparse tests pass on an RX 9070 XT in 5 parallel runs in a row.

Head e5e456c applied on main b49be18, debug, Windows 11 Pro 26200, RX 9070 XT (RDNA4, driver 32.0.32029.2010):

  • cargo test -p xcl --lib -- d3d12x::sparse --nocapture --test-threads=4, 5 times: each run 17 passed, 0 failed, 1 ignored, no SKIPPED.

The sparse tests make their device on the default adapter (create_device(None, ..) / D3D12CreateDevice(None, ..)), which is the RX 9070 XT on this machine. One more run with XCL_ADAPTER=3060 gave the same result, but it still used the default adapter, so it is not an NVIDIA run of these tests.

I did not run main repeatedly to see the flake this PR fixes, so this shows the PR's tests are stable here, not that they failed before.

Not tested: Intel, #2638 together with this PR.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@rgroenewoudt

rgroenewoudt commented Nov 26, 2026 •

Copy link
Copy Markdown

Tested on AMD Radeon RX 9070 (RDNA4) at this PR's head e5e456c: the sparse tests pass in every run.

Tested

Not tested

  • The same 20-run hle:: loop on this PR's head; the 6 runs above were the whole lib

AI use

  • Claude Code (Claude Opus 5.5) ran the commands and wrote this report from the logs.

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.

3 participants