darner-gpu: isolate watch, queue and present state across parallel tests #565

Open
groster17800 wants to merge 0 commits from groster17800/Darner:pr/gate3-watch-locks into Main
First-time contributor

Refs #389

Thank you to Cyber-Croissant for filing #389 with the parallel darner-gpu failure breakdown. Using Refs #389 rather than Fixes #389 because two separate items remain outside this test-only PR:

  1. watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue also fails deterministically in --test-threads=1 due to a product bug in RemapQueue / HostHeap::new (#563).
  2. darner-shader's oracle64::legacy_mul_forms_are_exact runtime and darner-loader's intermittent workspace failure in console_insn::tests are untouched here.

Contributor role (optional)

  • Fluxer ID: VectorSoay#2100

What it changes

  • The problem on main (official/main c8258f9):
    • 2 / 10 parallel runs of cargo test -p darner-gpu --lib --locked failed:
      • Run 01 (44.93s): watch::watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs (crates\darner-gpu\src\watch.rs:9823:9)
      • Run 03 (45.05s): queue::tests::a_line_in_hand_outlives_its_queue_and_is_retired (crates\darner-gpu\src\queue.rs:2316:9) and watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue (crates\darner-gpu\src\watch.rs:7616:9)
    • Serial control (cargo test -p darner-gpu --lib --locked -- --test-threads=1, 175.29s) also failed 2 tests (1803 passed; 2 failed; 81 ignored):
      • pipeline::make::tests::a_capped_draw_waits_once_then_drops (crates\darner-gpu\src\pipeline\make.rs:3416:9, waited its cap (4.2µs))
      • watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue

Test-only fixes in #[cfg(test)] across 22 files in crates/darner-gpu/src/, using the existing crate::watch::one_view_test() lock (from #262 / #224) and upstream's title_memory_freed / title_memory_allocated cache invalidation pattern:

  1. Acquire crate::watch::one_view_test() on tests reaching Host::execute, present_planes, bump_ahead_gen, remapped_ranges, fence::signal, or watch::asked/writes directly: Host::execute calls Host::submit -> watch::ask_once_end(), clearing global JOURNAL.ahead mid-test for concurrent watch tests. Where another lock (texback::POOL_TEST_LOCK, host::uav_pool::SERIAL) is also held, one_view_test() is always acquired first to prevent lock-order inversions.
  2. Invalidate RES_CACHE around VirtualAlloc / VirtualFree and ensure unwatched neighbours: call title_memory_freed(ptr, 0) (or title_memory_allocated(at, len) for host::refresh_tests::title) so recycled virtual addresses cannot reuse stale watchable: false / reservation entries in RES_CACHE. In watch::tests::ask_rest_falls_back_per_piece_when_touching_unwatched_neighbour, retry adjacent (p, q) allocation until VirtualAlloc(p + 2 * PAGE, ...) succeeds so p + 2 * PAGE cannot land inside an earlier test's unfreed write-watched block in serial runs.
  3. Serialize queue::tests sharing global static WAITING: take crate::watch::one_view_test() in a_present_keeps_another_queues_wait_for_one_frame, a_line_in_hand_outlives_its_queue_and_is_retired, a_retired_line_is_not_run, and a_queued_wait_or_signal_keeps_its_fence so release_held(false) cannot pop another test's Held::Run.
  4. Isolate PRESENTED_US in pipeline::make::tests::a_capped_draw_waits_once_then_drops: hold one_view_test() and reset PRESENTED_US.store(0, Ordering::Relaxed) so earlier present tests do not leave a >20 s timestamp that makes held_room() return Duration::ZERO.

How it was tested

  • Tested revisions:

    • PR 2 standalone: ef9024f on pr/gate3-watch-locks (based on official/main c8258f9)
    • Combined verification (PR 2 cherry-picked onto pr/remap-published-on-new-heap 149c5f4): c52c07a
  • Commands and results:

    Command Baseline (official/main c8258f9) Combined PR 2 on PR 1 (c52c07a)
    cargo test -p darner-gpu --lib --locked (10x parallel) 2 / 10 failed (3 failures total; 8 / 10 ok: 1805 passed; 81 ignored) 0 / 10 failed (all 10 runs: 1806 passed; 0 failed; 81 ignored, 32.16s–35.54s)
    cargo test -p darner-gpu --lib --locked -- --test-threads=1 (serial) FAILED (1803 passed; 2 failed; 81 ignored, 175.29s) PASSED (1806 passed; 0 failed; 81 ignored, 123.80s)
    • cargo test --workspace --locked --no-fail-fast -- --skip oracle64::legacy_mul_forms_are_exact on c52c07a (587.1s, rc=101):
      • Every workspace crate, integration test binary, and doc-test passed with 0 failures (darner-gpu lib: 1824 passed; 0 failed; 81 ignored; darner-shader lib: 567 passed; 0 failed; 16 ignored; 1 filtered out) except darner-loader lib (96 passed; 2 failed), where console_insn::tests::clzero_on_a_guarded_line_goes_through_the_guard and console_insn::tests::an_sse4a_instruction_becomes_sse2 failed. darner-loader is untouched from official/main (c8258f9), and cargo test -p darner-loader --lib --locked alone passed 1/1 on official/main c8258f9 (98 passed; 0 failed) and 5/5 on pr/gate3-watch-locks ef9024f (98 passed; 0 failed).
    • Separate darner-shader crash repro check (cargo test -p darner-shader --lib --locked -- --skip oracle64::legacy_mul_forms_are_exact):
      • 2 / 2 runs passed with 0 crashes / STATUS_ACCESS_VIOLATION (567 passed; 0 failed; 16 ignored; 1 filtered out in 573.13s and 566.82s, plus 491.12s in the workspace run; stopped after 2 clean dedicated runs).
  • Changes a default: no (test code only).

  • A/B result: not applicable (test-only isolation changes).

  • Gates run on PR 2 (ef9024f):

    • Gate 1 (cargo clippy --workspace --all-targets --locked -- -D warnings): passed (exit 0, 13.8s)
    • Gate 2 (cargo clippy --workspace --all-targets --all-features --locked -- -D warnings): passed (exit 0, 14.7s)
    • Asset policy (cargo xtask policy): asset policy: 576 files ok (exit 0)
    • Gate 3 (cargo test --workspace --locked): run on combined c52c07a skipping oracle64::legacy_mul_forms_are_exact (see results above).
  • Gameplay, when relevant: not run in game (tests only).

  • Shader wave sizes tested, when relevant: n/a.

  • Hardware dependence: Windows D3D12 host + crate::watch tests.

  • Coverage gaps: full darner-gpu --lib 10x verification ran on combined c52c07a (with PR 1) because streamed_texture_written_through_an_alias_reaches_a_full_queue requires PR 1; oracle64::legacy_mul_forms_are_exact was skipped in workspace testing due to runtime; dedicated darner-shader crash repro stopped after 2 clean runs (+ 1 workspace pass).

Checklist

  • I ran this change in the game, or say below why it can't be (tests only).
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on #563 (pr/remap-published-on-new-heap) for watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #563 (RemapQueue::cursor)
  • Replaces or overlaps: none found

🤖 Generated with Claude Code

Refs #389 Thank you to Cyber-Croissant for filing #389 with the parallel `darner-gpu` failure breakdown. Using `Refs #389` rather than `Fixes #389` because two separate items remain outside this test-only PR: 1. `watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue` also fails deterministically in `--test-threads=1` due to a product bug in `RemapQueue` / `HostHeap::new` (#563). 2. `darner-shader`'s `oracle64::legacy_mul_forms_are_exact` runtime and `darner-loader`'s intermittent workspace failure in `console_insn::tests` are untouched here. ## Contributor role (optional) - Fluxer ID: VectorSoay#2100 ## What it changes - The problem on main (`official/main` `c8258f9`): - **2 / 10 parallel runs** of `cargo test -p darner-gpu --lib --locked` failed: - Run 01 (`44.93s`): `watch::watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs` (`crates\darner-gpu\src\watch.rs:9823:9`) - Run 03 (`45.05s`): `queue::tests::a_line_in_hand_outlives_its_queue_and_is_retired` (`crates\darner-gpu\src\queue.rs:2316:9`) and `watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue` (`crates\darner-gpu\src\watch.rs:7616:9`) - **Serial control** (`cargo test -p darner-gpu --lib --locked -- --test-threads=1`, `175.29s`) also failed 2 tests (`1803 passed; 2 failed; 81 ignored`): - `pipeline::make::tests::a_capped_draw_waits_once_then_drops` (`crates\darner-gpu\src\pipeline\make.rs:3416:9`, `waited its cap (4.2µs)`) - `watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue` Test-only fixes in `#[cfg(test)]` across 22 files in `crates/darner-gpu/src/`, using the existing `crate::watch::one_view_test()` lock (from #262 / #224) and upstream's `title_memory_freed` / `title_memory_allocated` cache invalidation pattern: 1. **Acquire `crate::watch::one_view_test()` on tests reaching `Host::execute`, `present_planes`, `bump_ahead_gen`, `remapped_ranges`, `fence::signal`, or `watch::asked`/`writes` directly:** `Host::execute` calls `Host::submit` -> `watch::ask_once_end()`, clearing global `JOURNAL.ahead` mid-test for concurrent `watch` tests. Where another lock (`texback::POOL_TEST_LOCK`, `host::uav_pool::SERIAL`) is also held, `one_view_test()` is always acquired first to prevent lock-order inversions. 2. **Invalidate `RES_CACHE` around `VirtualAlloc` / `VirtualFree` and ensure unwatched neighbours:** call `title_memory_freed(ptr, 0)` (or `title_memory_allocated(at, len)` for `host::refresh_tests::title`) so recycled virtual addresses cannot reuse stale `watchable: false` / reservation entries in `RES_CACHE`. In `watch::tests::ask_rest_falls_back_per_piece_when_touching_unwatched_neighbour`, retry adjacent `(p, q)` allocation until `VirtualAlloc(p + 2 * PAGE, ...)` succeeds so `p + 2 * PAGE` cannot land inside an earlier test's unfreed write-watched block in serial runs. 3. **Serialize `queue::tests` sharing global `static WAITING`:** take `crate::watch::one_view_test()` in `a_present_keeps_another_queues_wait_for_one_frame`, `a_line_in_hand_outlives_its_queue_and_is_retired`, `a_retired_line_is_not_run`, and `a_queued_wait_or_signal_keeps_its_fence` so `release_held(false)` cannot pop another test's `Held::Run`. 4. **Isolate `PRESENTED_US` in `pipeline::make::tests::a_capped_draw_waits_once_then_drops`:** hold `one_view_test()` and reset `PRESENTED_US.store(0, Ordering::Relaxed)` so earlier present tests do not leave a >20 s timestamp that makes `held_room()` return `Duration::ZERO`. ## How it was tested - Tested revisions: - PR 2 standalone: `ef9024f` on `pr/gate3-watch-locks` (based on `official/main` `c8258f9`) - Combined verification (PR 2 cherry-picked onto `pr/remap-published-on-new-heap` `149c5f4`): `c52c07a` - Commands and results: | Command | Baseline (`official/main` `c8258f9`) | Combined PR 2 on PR 1 (`c52c07a`) | |---|---|---| | `cargo test -p darner-gpu --lib --locked` (10x parallel) | **2 / 10 failed** (3 failures total; 8 / 10 ok: `1805 passed; 81 ignored`) | **0 / 10 failed** (all 10 runs: `1806 passed; 0 failed; 81 ignored`, `32.16s`–`35.54s`) | | `cargo test -p darner-gpu --lib --locked -- --test-threads=1` (serial) | **FAILED** (`1803 passed; 2 failed; 81 ignored`, `175.29s`) | **PASSED** (`1806 passed; 0 failed; 81 ignored`, `123.80s`) | - `cargo test --workspace --locked --no-fail-fast -- --skip oracle64::legacy_mul_forms_are_exact` on `c52c07a` (`587.1s`, `rc=101`): - Every workspace crate, integration test binary, and doc-test passed with `0` failures (`darner-gpu` lib: `1824 passed; 0 failed; 81 ignored`; `darner-shader` lib: `567 passed; 0 failed; 16 ignored; 1 filtered out`) **except** `darner-loader` lib (`96 passed; 2 failed`), where `console_insn::tests::clzero_on_a_guarded_line_goes_through_the_guard` and `console_insn::tests::an_sse4a_instruction_becomes_sse2` failed. `darner-loader` is untouched from `official/main` (`c8258f9`), and `cargo test -p darner-loader --lib --locked` alone passed `1/1` on `official/main` `c8258f9` (`98 passed; 0 failed`) and `5/5` on `pr/gate3-watch-locks` `ef9024f` (`98 passed; 0 failed`). - Separate `darner-shader` crash repro check (`cargo test -p darner-shader --lib --locked -- --skip oracle64::legacy_mul_forms_are_exact`): - **2 / 2** runs passed with `0` crashes / `STATUS_ACCESS_VIOLATION` (`567 passed; 0 failed; 16 ignored; 1 filtered out` in `573.13s` and `566.82s`, plus `491.12s` in the workspace run; stopped after 2 clean dedicated runs). - Changes a default: no (test code only). - A/B result: not applicable (test-only isolation changes). - Gates run on PR 2 (`ef9024f`): - Gate 1 (`cargo clippy --workspace --all-targets --locked -- -D warnings`): passed (`exit 0`, `13.8s`) - Gate 2 (`cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`): passed (`exit 0`, `14.7s`) - Asset policy (`cargo xtask policy`): `asset policy: 576 files ok` (`exit 0`) - Gate 3 (`cargo test --workspace --locked`): run on combined `c52c07a` skipping `oracle64::legacy_mul_forms_are_exact` (see results above). - Gameplay, when relevant: not run in game (tests only). - Shader wave sizes tested, when relevant: n/a. - Hardware dependence: Windows D3D12 host + `crate::watch` tests. - Coverage gaps: full `darner-gpu --lib` 10x verification ran on combined `c52c07a` (with PR 1) because `streamed_texture_written_through_an_alias_reaches_a_full_queue` requires PR 1; `oracle64::legacy_mul_forms_are_exact` was skipped in workspace testing due to runtime; dedicated `darner-shader` crash repro stopped after 2 clean runs (`+` 1 workspace pass). ## Checklist - [x] I ran this change in the game, or say below why it can't be (tests only). - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on #563 (`pr/remap-published-on-new-heap`) for `watch::tests::streamed_texture_written_through_an_alias_reaches_a_full_queue` ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #563 (`RemapQueue::cursor`) - Replaces or overlaps: none found 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Refs #389

1. Hold crate:⌚:one_view_test() across tests calling Host::execute, Host::present_planes, bump_ahead_gen, remapped_ranges, fence::signal/set, or watch::asked/writes directly without it, so Host::submit's watch::ask_once_end() and concurrent asks cannot clear JOURNAL.ahead mid-test. Where another lock (texback POOL_TEST_LOCK, uav_pool SERIAL) is also taken, one_view_test() is always acquired first.

2. Call watch::title_memory_freed(ptr, 0) / title_memory_allocated(at, len) around VirtualAlloc/VirtualFree in watch, watch_pipe and host refresh tests so recycled virtual addresses invalidate stale RES_CACHE and refusal entries, and retry adjacent (p, q) allocation in ask_rest_falls_back_per_piece_when_touching_unwatched_neighbour until q succeeds so p + 2 * PAGE cannot land on an unfreed write-watched allocation from an earlier test.

3. Serialize queue::tests that drain global static WAITING using watch::one_view_test() so a_retired_line_is_not_run / a_queued_wait_or_signal_keeps_its_fence / a_present_keeps_another_queues_wait_for_one_frame cannot pop another test's Held::Run.

4. Isolate PRESENTED_US in pipeline::make::tests::a_capped_draw_waits_once_then_drops with watch::one_view_test() and PRESENTED_US.store(0, Ordering::Relaxed) so earlier present tests do not exhaust held_room() in serial or parallel runs.

Depends on PR 1 (pr/remap-published-on-new-heap) for streamed_texture_written_through_an_alias_reaches_a_full_queue.

Co-Authored-By: Gemini <[email protected]>
TrustNo1 changed title from [pr-tests] darner-gpu: isolate watch, queue and present state across parallel tests to darner-gpu: isolate watch, queue and present state across parallel tests 2026-12-06 03:27:01 +00:00
This branch is already included in the target branch. There is nothing to merge.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/gate3-watch-locks:groster17800-pr/gate3-watch-locks'
git switch 'groster17800-pr/gate3-watch-locks'

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 'groster17800-pr/gate3-watch-locks'
git switch 'groster17800-pr/gate3-watch-locks'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'groster17800-pr/gate3-watch-locks'
git switch 'groster17800-pr/gate3-watch-locks'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'groster17800-pr/gate3-watch-locks'
git switch 'Main'
git merge --squash 'groster17800-pr/gate3-watch-locks'
git switch 'Main'
git merge --ff-only 'groster17800-pr/gate3-watch-locks'
git switch 'Main'
git merge 'groster17800-pr/gate3-watch-locks'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
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.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!565
No description provided.