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

Open
sage-sage wants to merge 1 commit from upstream-pr/2775 into main
sage-sage commented 2026-11-26 11:48:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by sage-sage on 2026-11-26T11:48:08Z.


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

  • AMD / Intel.
  • #2638 rewrites the quarantine (quarantine_tiles_for). It still marks every queue from known_queues, so this helper should still apply there, but I have not tested the two together.

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

<!-- greyfinch-sync:ivall/xcl:issue:5509467220 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2775). Originally posted by [sage-sage](https://github.com/sage-sage) on 2026-11-26T11:48:08Z. --- 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** - AMD / Intel. - #2638 rewrites the quarantine (`quarantine_tiles_for`). It still marks every queue from `known_queues`, so this helper should still apply there, but I have not tested the two together. **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](https://claude.com/claude-code)
DarkPanda69 commented 2026-11-26 14:03:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-26T13:37:55Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7193618846 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2775#issuecomment-7193618846). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-26T13:37:55Z. --- 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 commented 2026-11-26 16:33:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by rgroenewoudt on 2026-11-26T16:33:09Z.


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

Tested

  • AMD Radeon RX 9070, driver 32.0.32029.2010; AMD Ryzen 9 5950X; Windows 11 Pro build 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug build

  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1433 passed, 2 failed, 47 ignored. The 2 failures are fuzz_validate_and_gpu_1 (seed 722) and _3 (seed 1599), the AMD ones from #2115, not touched here.

  • cargo test -p xcl --lib -- --test-threads=12, 6 runs: a_tile_decommitted_and_committed_again_keeps_its_video_memory, flush_parked_does_not_free_or_reuse_tiles_while_unmap_is_in_flight and flush_parked_quarantines_tiles_until_title_queues_finish passed every time; 1307 passed, 2 failed (the same two fuzz tests), 27 ignored each run

  • SKIPPED (7): 6 × f16 / f32 per-lane forms refused (#1426); heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)

  • Before the change, on this card: cargo test -p xcl --lib -- hle:: --test-threads=12, 20 runs on #2700's head (base b49be18, the same sparse code as main): a_tile_decommitted_and_committed_again_keeps_its_video_memory failed 2/20

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.
<!-- greyfinch-sync:ivall/xcl:comment:7197793610 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2775#issuecomment-7197793610). Originally posted by [rgroenewoudt](https://github.com/rgroenewoudt) on 2026-11-26T16:33:09Z. --- **Tested on AMD Radeon RX 9070 (RDNA4) at this PR's head `e5e456c`**: the sparse tests pass in every run. **Tested** - AMD Radeon RX 9070, driver 32.0.32029.2010; AMD Ryzen 9 5950X; Windows 11 Pro build 26300; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug build - `cargo test --workspace --no-fail-fast -- --test-threads=4`: 1433 passed, 2 failed, 47 ignored. The 2 failures are `fuzz_validate_and_gpu_1` (seed 722) and `_3` (seed 1599), the AMD ones from #2115, not touched here. - `cargo test -p xcl --lib -- --test-threads=12`, 6 runs: `a_tile_decommitted_and_committed_again_keeps_its_video_memory`, `flush_parked_does_not_free_or_reuse_tiles_while_unmap_is_in_flight` and `flush_parked_quarantines_tiles_until_title_queues_finish` passed every time; 1307 passed, 2 failed (the same two fuzz tests), 27 ignored each run - SKIPPED (7): 6 × f16 / f32 per-lane forms refused (#1426); `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows) - Before the change, on this card: `cargo test -p xcl --lib -- hle:: --test-threads=12`, 20 runs on #2700's head (base `b49be18`, the same sparse code as `main`): `a_tile_decommitted_and_committed_again_keeps_its_video_memory` failed 2/20 **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.
github-actions[bot] commented 2026-12-01 02:35:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-12-01T02:35:18Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7298777309 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2775#issuecomment-7298777309). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-12-01T02:35:18Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 08:56:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T08:56:17Z.


Triage (#1607) – head e5e456c

No other PR makes this test change. #2638 rewrites the quarantine but does not touch these tests. The diagnosis holds on main: quarantine_tiles marks every queue of the same device from present::known_queues. D3D12CreateDevice on one adapter returns the same device, so queues from other tests count. The helper uses RetiredTiles::marks (Option<Vec<(ID3D12Fence, u64)>>), which still has this shape on main. main has since changed these tests (drained tiles now go to a cooling stage), so the branch conflicts. On rebase, the wait should go before every drain_quarantined() assertion.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7305986602 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2775#issuecomment-7305986602). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T08:56:17Z. --- **Triage (#1607)** – head e5e456c No other PR makes this test change. #2638 rewrites the quarantine but does not touch these tests. The diagnosis holds on main: `quarantine_tiles` marks every queue of the same device from `present::known_queues`. `D3D12CreateDevice` on one adapter returns the same device, so queues from other tests count. The helper uses `RetiredTiles::marks` (`Option<Vec<(ID3D12Fence, u64)>>`), which still has this shape on main. main has since changed these tests (drained tiles now go to a `cooling` stage), so the branch conflicts. On rebase, the wait should go before every `drain_quarantined()` assertion. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2775:upstream-pr/2775'
git switch 'upstream-pr/2775'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2775'
git switch 'upstream-pr/2775'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2775'
git switch 'upstream-pr/2775'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2775'
git switch 'main'
git merge --squash 'upstream-pr/2775'
git switch 'main'
git merge --ff-only 'upstream-pr/2775'
git switch 'main'
git merge 'upstream-pr/2775'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2765
No description provided.