[pr-tests] refresh_tests::unchanged_ranges_are_known asks under the watch journal's test lock (a watch:: test failed in 28 of 60 runs beside it) #262

Open
blazecoding2009 wants to merge 1 commit from blazecoding2009/Darner:pr/test-unchanged-ranges-view-lock into main
First-time contributor

Contributor role (optional)

  • Fluxer ID:

What it changes

  • The problem on main: watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_done fails by chance when it runs beside host::refresh_tests::unchanged_ranges_are_known, in 28 of 60 runs of watch::'s tests with that one test here:

    thread 'watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_done' panicked at crates\darner-gpu\src\watch.rs:9278:9:
    assertion failed: asked(p, p + 2 * PAGE).is_some()
    

    That one 20 of the 28 times, assertion failed: !is_kept() 7 times and "ask_ahead disturbed kept asking" once.

    The other way round, unchanged_ranges_are_known failed once in 8 whole runs of the crate's tests (host.rs:23219, "view false: taken": left: false, right: true).

unchanged_ranges_are_known asks the write watch (ask_once, ask_once_end) with one_submission's lock alone. The tests of watch:: that ask hold watch::one_view_test's lock and not that one, and the asking is one for the process, so the two end each other's. It is the only test of the crate that asks without one_view_test's lock: submission takes it since 6ecada3, and the six tests of refresh_tests that ask themselves take both.

It now asks under one_view_test's lock instead of one_submission's. Every test that holds one_submission's holds that one too while it asks, so those are kept out as before. Holding one lock, the test takes no part in the order of the two, so this needs nothing of #224 and adds nothing to what #224 fixes. Test code only: one closure in mod refresh_tests of host.rs.

How it was tested

  • Tested revision: 4efa7c7 (this one commit on main f3840d7).

  • Commands and results: cargo test --locked -p darner-gpu --lib --no-run on each revision, then that test binary run by itself with the filters host::refresh_tests::unchanged_ranges_are_known watch:: (89 tests, 2 s a run), 60 times each.

    A (main, f3840d7) B (4efa7c7)
    runs 60 60
    watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_done failed 28 0
    watch::tests::ask_once_by_res_splits_reservations_without_refusals failed (#150 is about it) 47 41
    watch::watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs failed 1 2
    watch::tests::single_pass_ask_once_caches_mixed_clustered_lone_and_unwatched_ranges failed 3 0
    watch::tests::an_asking_begun_first_is_made_and_more_is_asked_for failed 1 1
    all passed 9 19

    All of the crate's tests on 4efa7c7, 6 runs with a 150 s limit: 4 passed whole, 1 stood still (what #224 is about) and in 1 another test failed (host::refresh_tests::refresh_front_zero_arc_matches_and_runs_due). unchanged_ranges_are_known and asking_kept_fast_path_guards_ask_ahead_and_done passed in the five that ended.

  • Changes a default: no.

  • Gates run on that revision (the three in AGENTS.md; there is no CI): cargo clippy --workspace --all-targets --locked -- -D warnings: passed. The same with --all-features: passed. cargo xtask policy: 555 files ok. cargo test --workspace --locked: not run as one command on this revision. Of it, I ran darner-gpu's tests as above. On main that gate fails or stands still by chance in this crate (#224 has the counts), and in darner-shader one test fails, which #227 is about.

  • Gameplay: not run in the game. The change is in test code only.

  • Shader wave sizes tested, when relevant: not relevant.

  • Hardware dependence: likely general. How often the tests meet depends on timing and on the number of test threads: 16 here (Ryzen 7 8845HS, Windows 11 build 26300).

  • Coverage gaps: one PC. I did not see unchanged_ranges_are_known itself fail often enough to count it before and after (once in 8 whole runs on main, none in the 60 runs of the table on either side): the count is of the watch:: test it disturbed. The tests of the table that still fail on B have other causes: #150 is about the first, and I did not look for those of the others here.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, 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: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none found for this test. Searches of open and closed issues and pull requests for unchanged_ranges_are_known, asking_kept_fast_path and flaky found no report of it. I searched the diff of every open pull request (100): none changes this test or one_submission's users but #224, which changes submission, another function of the same module. #150 and #261 are about other tests of the crate that fail by chance.
  • Replaces or overlaps: none found

This change was made with AI assistance (Claude Code).

🤖 Generated with Claude Code

## Contributor role (optional) - Fluxer ID: ## What it changes - The problem on main: `watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_done` fails by chance when it runs beside `host::refresh_tests::unchanged_ranges_are_known`, in 28 of 60 runs of `watch::`'s tests with that one test here: ``` thread 'watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_done' panicked at crates\darner-gpu\src\watch.rs:9278:9: assertion failed: asked(p, p + 2 * PAGE).is_some() ``` That one 20 of the 28 times, `assertion failed: !is_kept()` 7 times and "ask_ahead disturbed kept asking" once. The other way round, `unchanged_ranges_are_known` failed once in 8 whole runs of the crate's tests (`host.rs:23219`, "view false: taken": `left: false, right: true`). `unchanged_ranges_are_known` asks the write watch (`ask_once`, `ask_once_end`) with `one_submission`'s lock alone. The tests of `watch::` that ask hold `watch::one_view_test`'s lock and not that one, and the asking is one for the process, so the two end each other's. It is the only test of the crate that asks without `one_view_test`'s lock: `submission` takes it since 6ecada3, and the six tests of `refresh_tests` that ask themselves take both. It now asks under `one_view_test`'s lock instead of `one_submission`'s. Every test that holds `one_submission`'s holds that one too while it asks, so those are kept out as before. Holding one lock, the test takes no part in the order of the two, so this needs nothing of #224 and adds nothing to what #224 fixes. Test code only: one closure in `mod refresh_tests` of `host.rs`. ## How it was tested - Tested revision: 4efa7c7 (this one commit on `main` f3840d7). - Commands and results: `cargo test --locked -p darner-gpu --lib --no-run` on each revision, then that test binary run by itself with the filters `host::refresh_tests::unchanged_ranges_are_known watch::` (89 tests, 2 s a run), 60 times each. | | A (main, f3840d7) | B (4efa7c7) | |---|---|---| | runs | 60 | 60 | | `watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_done` failed | 28 | 0 | | `watch::tests::ask_once_by_res_splits_reservations_without_refusals` failed (#150 is about it) | 47 | 41 | | `watch::watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochs` failed | 1 | 2 | | `watch::tests::single_pass_ask_once_caches_mixed_clustered_lone_and_unwatched_ranges` failed | 3 | 0 | | `watch::tests::an_asking_begun_first_is_made_and_more_is_asked_for` failed | 1 | 1 | | all passed | 9 | 19 | All of the crate's tests on 4efa7c7, 6 runs with a 150 s limit: 4 passed whole, 1 stood still (what #224 is about) and in 1 another test failed (`host::refresh_tests::refresh_front_zero_arc_matches_and_runs_due`). `unchanged_ranges_are_known` and `asking_kept_fast_path_guards_ask_ahead_and_done` passed in the five that ended. - Changes a default: no. - Gates run on that revision (the three in AGENTS.md; there is no CI): `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed. The same with `--all-features`: passed. `cargo xtask policy`: 555 files ok. `cargo test --workspace --locked`: not run as one command on this revision. Of it, I ran `darner-gpu`'s tests as above. On `main` that gate fails or stands still by chance in this crate (#224 has the counts), and in `darner-shader` one test fails, which #227 is about. - Gameplay: not run in the game. The change is in test code only. - Shader wave sizes tested, when relevant: not relevant. - Hardware dependence: likely general. How often the tests meet depends on timing and on the number of test threads: 16 here (Ryzen 7 8845HS, Windows 11 build 26300). - Coverage gaps: one PC. I did not see `unchanged_ranges_are_known` itself fail often enough to count it before and after (once in 8 whole runs on `main`, none in the 60 runs of the table on either side): the count is of the `watch::` test it disturbed. The tests of the table that still fail on B have other causes: #150 is about the first, and I did not look for those of the others here. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, 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: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none found for this test. Searches of open and closed issues and pull requests for `unchanged_ranges_are_known`, `asking_kept_fast_path` and `flaky` found no report of it. I searched the diff of every open pull request (100): none changes this test or `one_submission`'s users but #224, which changes `submission`, another function of the same module. #150 and #261 are about other tests of the crate that fail by chance. - Replaces or overlaps: none found This change was made with AI assistance (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`host::refresh_tests::unchanged_ranges_are_known` asks the write watch (`ask_once`,
`ask_once_end`) with `one_submission`'s lock alone. The tests of `watch::` that ask hold
`watch::one_view_test`'s lock and not that one, and the asking is one for the process, so
the two ended each other's: `watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_done`
failed in 28 of 60 runs of `watch::`'s tests beside this one (20 of them at
`assert!(asked(p, p + 2 * PAGE).is_some())`), and this test failed with "view false:
taken" in one whole run of the crate's tests. It was the only test of the crate that asks
without that lock.

It now asks under `one_view_test`'s lock instead. Every test that holds
`one_submission`'s holds that one too while it asks (`submission` and the six tests that
take both), so they are kept out as before, and holding one lock this test takes no part
in the order of the two.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
First-time contributor

Independent Windows build, gate, and code-read review of 4efa7c7f0 (based on main f3840d73d). Test-only change; not run in-game.

Environment

  • Windows 11 Pro 26H2 (build 26300.10075), Intel Core i9-14900K, NVIDIA RTX A2000 12GB (driver 621.47), Rust 1.98.1 (x86_64-pc-windows-msvc), MSVC 19.44.35230.

Measured results

  • Gate 1 (cargo clippy --workspace --all-targets --locked -- -D warnings): PASS
  • Gate 2 (cargo clippy --workspace --all-targets --all-features --locked -- -D warnings): PASS
  • cargo xtask policy: PASS (asset policy: 555 files ok)
  • cargo test --locked -p darner-gpu --lib host::refresh_tests::unchanged_ranges_are_known: 20/20 PASS
  • cargo test --locked -p darner-gpu --lib -- unchanged_ranges_are_known watch:: (89 tests, 10 runs):
    • unchanged_ranges_are_known: 10/10 PASS
    • watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_done: 10/10 PASS (0/10 failures)
    • Separate pre-existing watch::tests flakes observed (matching the PR's table): ask_once_by_res_splits_reservations_without_refusals (#150, 5/10), single_pass_ask_once_caches_mixed_clustered_lone_and_unwatched_ranges (1/10), an_asking_begun_first_is_made_and_more_is_asked_for (1/10).

Code-read audit

  • Lock-order check (clear): Replacing one_submission() with crate::watch::one_view_test() (crates/darner-gpu/src/host.rs:23215) holds only a single lock, so it cannot form an AB-BA deadlock cycle with submission() or #224. Because every one_submission() caller in host.rs also acquires one_view_test() while asking, this still excludes one_submission() callers as well as watch:: tests.
  • Minor non-blocking note: Because let _view = crate::watch::one_view_test(); is inside the look closure, title(8 * PAGE, view) (host.rs:23199), the inter-look writes (23228, 23234), and the trailing copy.nothing_new(region, 6 * PAGE) (23237) still run outside one_view_test(), unlike the other 6 refresh_tests and watch::one_view_test()'s documented scope (watch.rs:3012-3016). Hoisting let _view = crate::watch::one_view_test(); to the top of unchanged_ranges_are_known (still a single lock) would cover the whole test cleanly.

Verdict: PASS.

AI-assisted: yes (Gemini 4 Neon).

Independent Windows build, gate, and code-read review of `4efa7c7f0` (based on `main` `f3840d73d`). Test-only change; not run in-game. ### Environment - Windows 11 Pro 26H2 (build 26300.10075), Intel Core i9-14900K, NVIDIA RTX A2000 12GB (driver 621.47), Rust 1.98.1 (`x86_64-pc-windows-msvc`), MSVC 19.44.35230. ### Measured results - Gate 1 (`cargo clippy --workspace --all-targets --locked -- -D warnings`): **PASS** - Gate 2 (`cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`): **PASS** - `cargo xtask policy`: **PASS** (`asset policy: 555 files ok`) - `cargo test --locked -p darner-gpu --lib host::refresh_tests::unchanged_ranges_are_known`: **20/20 PASS** - `cargo test --locked -p darner-gpu --lib -- unchanged_ranges_are_known watch::` (89 tests, 10 runs): - `unchanged_ranges_are_known`: **10/10 PASS** - `watch::ask_holds::asking_kept_fast_path_guards_ask_ahead_and_done`: **10/10 PASS** (`0/10` failures) - Separate pre-existing `watch::tests` flakes observed (matching the PR's table): `ask_once_by_res_splits_reservations_without_refusals` (#150, 5/10), `single_pass_ask_once_caches_mixed_clustered_lone_and_unwatched_ranges` (1/10), `an_asking_begun_first_is_made_and_more_is_asked_for` (1/10). ### Code-read audit - **Lock-order check (clear):** Replacing `one_submission()` with `crate::watch::one_view_test()` (`crates/darner-gpu/src/host.rs:23215`) holds only a single lock, so it cannot form an AB-BA deadlock cycle with `submission()` or #224. Because every `one_submission()` caller in `host.rs` also acquires `one_view_test()` while asking, this still excludes `one_submission()` callers as well as `watch::` tests. - **Minor non-blocking note:** Because `let _view = crate::watch::one_view_test();` is inside the `look` closure, `title(8 * PAGE, view)` (`host.rs:23199`), the inter-`look` writes (`23228, 23234`), and the trailing `copy.nothing_new(region, 6 * PAGE)` (`23237`) still run outside `one_view_test()`, unlike the other 6 `refresh_tests` and `watch::one_view_test()`'s documented scope (`watch.rs:3012-3016`). Hoisting `let _view = crate::watch::one_view_test();` to the top of `unchanged_ranges_are_known` (still a single lock) would cover the whole test cleanly. **Verdict:** PASS. AI-assisted: yes (Gemini 4 Neon).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'pr/test-unchanged-ranges-view-lock:blazecoding2009-pr/test-unchanged-ranges-view-lock'
git switch 'blazecoding2009-pr/test-unchanged-ranges-view-lock'

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 'blazecoding2009-pr/test-unchanged-ranges-view-lock'
git switch 'blazecoding2009-pr/test-unchanged-ranges-view-lock'
git rebase 'main'
git switch 'main'
git merge --ff-only 'blazecoding2009-pr/test-unchanged-ranges-view-lock'
git switch 'blazecoding2009-pr/test-unchanged-ranges-view-lock'
git rebase 'main'
git switch 'main'
git merge --no-ff 'blazecoding2009-pr/test-unchanged-ranges-view-lock'
git switch 'main'
git merge --squash 'blazecoding2009-pr/test-unchanged-ranges-view-lock'
git switch 'main'
git merge --ff-only 'blazecoding2009-pr/test-unchanged-ranges-view-lock'
git switch 'main'
git merge 'blazecoding2009-pr/test-unchanged-ranges-view-lock'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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!262
No description provided.