xmem: the range lock's "never waits" test no longer counts the other tests' remappings (fails 20/20 on a 24-thread PC) #3643

Closed
github-bot wants to merge 1 commit from github-bot/gh-3643 into main AGit
Owner

@⁠Trillazill on GitHub · 2026-11-30 02:27 UTC · original
Trillazill:fix/xmem-range-test-flake → main · +22 −5 · 1 files · 1 commits · closed without merging

Fixes: no issue filed.

What it changes

modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_it (VICTORY_RANGE_LOCK) fails whenever it runs alongside the rest of the victory-hle suite on a PC with many cores:

assertion `left == right` failed: a read apart from the remapping had to wait
  left: 7648
 right: 0

The test counts every time its reader of view x is refused (title_memory_reading_of_now(x, ..) returns None) while it remaps view y 2000 times, and expects zero. But the module's other 46 tests run beside it in the same process. Their changes of mapping that take the whole of title memory (map_aliases_by_page, and every change made without the range lock) overlap x too, so the count includes waits this test didn't cause.

On 41adb551, on a 24-thread Ryzen 9 7900:

  • cargo test -p victory-hle --lib: failed in 20 of 20 runs (5905 to 9339 refusals counted).
  • The test alone: passes (5 of 5). The whole suite with --test-threads=1: passes.

That's probably also why CI's 4-vCPU runner rarely shows it, while a contributor's cargo test --workspace does.

The fix keeps the stress loop: it still checks that a reader of the remapped view never meets its gap, and that the other reader never faults. The refusal count goes. After the loop, the test holds exactly what XMemMapPhysicalPages of y holds (remapping_and_views(&[(y, 3 * PAGE)])) and asks for both views at once:

  • the read of x must be had at once ("a read apart from the remapping had to wait"),
  • the read of y must not ("a read of the view being remapped did not wait").

Writers take turns (RangeLock::write holds writer), so while the test holds that change, no other test's change of mapping can be the one in the way. The check is deterministic now, and it checks the same property.

Test-only change; nothing outside #[cfg(test)] is touched.

How it was tested

  • GPU and profile: none. No game was run: test-only change, no GPU needed.
  • Before (41adb551): cargo test --locked -p victory-hle --lib failed this test in 20 of 20 runs.
  • After: 10 of 10 runs of the same command pass (423 passed, 0 failed); the test alone passes too.
  • Still catches the regression it exists for: with remapping_and_views made to take the whole of title memory (if true { in place of if !victory_gpu::title_memory_by_range() {), it fails with "a read apart from the remapping had to wait".
  • cargo clippy -p victory-hle --all-targets: nothing new in xmem.rs. The three victory-hle findings on main (gameinput.rs ×2, lifecycle.rs) are #3530's.
  • For shader changes, the wave sizes tested: not a shader change.
  • cargo test passed for the crates it touches: yes (victory-hle).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: none for this test. #3530 (main's clippy) touches other files of victory-hle, with no overlap.

🤖 Generated with Claude Code

**@⁠Trillazill** on GitHub · 2026-11-30 02:27 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3643) `Trillazill:fix/xmem-range-test-flake` → `main` · +22 −5 · 1 files · 1 commits · closed without merging Fixes: no issue filed. ## What it changes `modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_it` (`VICTORY_RANGE_LOCK`) fails whenever it runs alongside the rest of the `victory-hle` suite on a PC with many cores: ``` assertion `left == right` failed: a read apart from the remapping had to wait left: 7648 right: 0 ``` The test counts every time its reader of view `x` is refused (`title_memory_reading_of_now(x, ..)` returns `None`) while it remaps view `y` 2000 times, and expects zero. But the module's other 46 tests run beside it in the same process. Their changes of mapping that take the whole of title memory (`map_aliases_by_page`, and every change made without the range lock) overlap `x` too, so the count includes waits this test didn't cause. On 41adb551, on a 24-thread Ryzen 9 7900: - `cargo test -p victory-hle --lib`: **failed in 20 of 20 runs** (5905 to 9339 refusals counted). - The test alone: passes (5 of 5). The whole suite with `--test-threads=1`: passes. That's probably also why CI's 4-vCPU runner rarely shows it, while a contributor's `cargo test --workspace` does. The fix keeps the stress loop: it still checks that a reader of the remapped view never meets its gap, and that the other reader never faults. The refusal count goes. After the loop, the test holds exactly what `XMemMapPhysicalPages` of `y` holds (`remapping_and_views(&[(y, 3 * PAGE)])`) and asks for both views at once: - the read of `x` must be had at once ("a read apart from the remapping had to wait"), - the read of `y` must not ("a read of the view being remapped did not wait"). Writers take turns (`RangeLock::write` holds `writer`), so while the test holds that change, no other test's change of mapping can be the one in the way. The check is deterministic now, and it checks the same property. Test-only change; nothing outside `#[cfg(test)]` is touched. ## How it was tested - GPU and profile: none. No game was run: test-only change, no GPU needed. - Before (41adb551): `cargo test --locked -p victory-hle --lib` failed this test in 20 of 20 runs. - After: 10 of 10 runs of the same command pass (423 passed, 0 failed); the test alone passes too. - Still catches the regression it exists for: with `remapping_and_views` made to take the whole of title memory (`if true {` in place of `if !victory_gpu::title_memory_by_range() {`), it fails with "a read apart from the remapping had to wait". - `cargo clippy -p victory-hle --all-targets`: nothing new in `xmem.rs`. The three `victory-hle` findings on main (`gameinput.rs` ×2, `lifecycle.rs`) are #3530's. - For shader changes, the wave sizes tested: not a shader change. - `cargo test` passed for the crates it touches: yes (`victory-hle`). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: none for this test. #3530 (main's clippy) touches other files of `victory-hle`, with no overlap. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
a_read_by_range_waits_only_for_a_remapping_that_meets_it counted every
time the reader of view x was refused during 2000 remappings of view y,
and wanted none. The 46 other tests of the module run beside it in the
same process, and their changes of mapping that take the whole of title
memory (map_aliases_by_page, and every one without the range lock) meet x
too. On 41adb551 it failed in 20 of 20 runs of the victory-hle suite on a
24-thread PC (5905 to 9339 refusals), and passed alone and with
--test-threads=1.

The loop stays, for the reads it checks. The refusal count goes; after
the loop the test holds what XMemMapPhysicalPages of y holds
(remapping_and_views) and asks for x and for y at once. Writers take
turns (RangeLock::write), so meanwhile no other test's change can be in
the way: x must be had, y must not. With remapping_and_views made to take
the whole of title memory, it fails as before ("a read apart from the
remapping had to wait").

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 02:31:50 +00:00
github-bot closed this pull request 2026-11-30 02:47:33 +00:00
Author
Owner

@⁠Trillazill on GitHub · 2026-11-30 02:45 UTC · original

Closing in favour of #3621, which fixes the same test and was opened first. It also keeps the range lock this test turns on (set_range_lock(true), process-wide) away from the module's other tests, which this PR doesn't. For #3621's reviewers: on a 24-thread Ryzen 9 7900, main (41adb551) failed this test in 20 of 20 runs of cargo test -p victory-hle --lib, and passed alone and with --test-threads=1, which matches #3621's diagnosis.

**@⁠Trillazill** on GitHub · 2026-11-30 02:45 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/3643#issuecomment-7267286199) Closing in favour of #3621, which fixes the same test and was opened first. It also keeps the range lock this test turns on (`set_range_lock(true)`, process-wide) away from the module's other tests, which this PR doesn't. For #3621's reviewers: on a 24-thread Ryzen 9 7900, main (41adb551) failed this test in 20 of 20 runs of `cargo test -p victory-hle --lib`, and passed alone and with `--test-threads=1`, which matches #3621's diagnosis.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!3643
No description provided.