XMem tests: the range-lock read test runs alone against the tests that copy mappings (9 in 10 runs failed) #2439
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!2439
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2439"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@boraswim on GitHub · 2026-11-29 13:03 UTC · original
boraswim:fix/flaky-tests→main· +19 −0 · 1 files · 2 commits · openPart of #2420 (item 2).
What it changes
modules::xmem::tests::a_read_by_range_waits_only_for_a_remapping_that_meets_itasserts that a read apart from the remapped view is never refused (refused == 0). Butmap_aliasestakesvictory_gpu::title_memory_remapping(), which covers all of title memory whateverVICTORY_RANGE_LOCKsays (map_aliases_by_page). So any test that copies mappings on another thread of the same test process refuses that read, thousands of times per run (left: 5861, right: 0). That is the lock doing its job, not the range lock failing.Measured on Windows with
cargo test -p victory-hle --lib, repeated:VICTORY_RANGE_LOCK=1set beforehand, so it is not the switch being read late).a_scatter_of_many_pages_is_what_one_after_the_other_ismakes it fail (3 of 3). That test callsmap_aliaseswith 200 pages.The change is test-only. The five tests that call
map_aliaseshold astatic WHOLE: RwLock<()>shared, so they still run alongside each other, and the range test holds it alone. This is the same approach #724 took for the watch tests.How it was tested
cargo test -p victory-hle --lib --lockedcargo testpassed for the crates it touches: yes for this test.victory-hlestill has one rarer flake (below).Still flaky, not touched here (also listed in #2420):
xmem::tests::large_default_allocations_honour_write_watch_switch: 1 to 2 failures in 10 runs. AfterXMemFreeDefaultit checks that the reservation's base isMEM_FREE, but a test on another thread can reserve the freed range first, since title memory goes lowest address first (left: 8192=MEM_RESERVE). Making that check safe needs either a different check or a lock around every allocating test, which is a bigger change than this one.victory-gpu, each 1 to 2 failures in 8 runs:card_steps::tests::shared_scratch_eliminates_flight_settle_end_to_end,card_steps::tests::places_written_after_sending_are_learned,uav_pool::tests::host_list_uav_pool_lifecycle_retire_trim_and_info_queue,menu::tests::a_change_is_saved_at_once_however_the_game_was_started,watch::many_askers_tests::no_mapping_is_lost_between_askers.CI's clippy step will stay red on this PR until main's clippy errors are fixed (#2048). Nothing here adds a lint.
Checked for overlap
xmem.rs(#2133, #2263, #2390) change runtime code, not these tests.@Dukestar69 on GitHub · 2026-11-29 13:26 UTC · original · approved these changes
Tested locally merged onto
main(829188e9).crates/victory-hle/src/modules/xmem.rs.cargo test -p victory-hle --lib xmempassed twice in a row under default parallel execution (46 passed; 0 failed; 1 ignoredeach run, includinga_read_by_range_waits_only_for_a_remapping_that_meets_it) with 0 warnings invictory-hle.Clean test synchronization fix eliminating the parallel
xmemtest flake. LGTM.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github-bot referenced this pull request2026-11-29 13:44:39 +00:00
@fainty0 on GitHub · 2026-11-29 14:45 UTC · original · approved these changes
Approve, with non-blocking coverage notes
Root cause. This is real contention on process-wide mapping state, not a failure to exclude an overlapping reader. The 200-page scatter test calls
map_aliases(xmem.rs:5059). The aligned batched path takestitle_memory_remapping()beforePHYSICAL(xmem.rs:2110–2148), which takesMAPPINGand publishesALLinRANGES(watch.rs:3398, 3414, 3598–3622).RangeLockpublishes the writer's ranges before draining overlapping readers, so the unrelated reader correctly receivesNone(rangelock.rs:41–46, 83–121), and the assertion counts that expected refusal as a failure (xmem.rs:4945–4947, 4975).Review.
WHOLEisolates the unrelated batched writers without serialising the range test's own readers and writer (xmem.rs:3770–3781, 4922–4975). All three unit tests that can take the batched preflight are covered (xmem.rs:4372, 5035, 5101). The guards at xmem.rs:4498 and 4636 are conservative, since those cases only use range-awarealias_as/map_alias(xmem.rs:1921–1940). Consider narrowing the guard to the batched cases and describing the lock, not the preflight, as whole-address. Test-only; style fits.Coverage follow-up. The loop reuses the already-mapped page list (xmem.rs:4932, 4969–4971), and the fast path returns after taking the lock (xmem.rs:1759–1762, 1816–1832), so it need not exercise a real unmap/recommit gap. Alternate the two pages and coordinate worker startup. Pre-existing: the process-wide switch has a first-use race (watch.rs:3418–3444).
Windows Clippy (
829188e→3978372): no new diagnostics (default 5 → 5, all-features 4 → 4; HLE-only 3 → 3). Windows XMem repro not run independently.@boraswim on GitHub · 2026-11-29 14:48 UTC · original
Thanks, all checked against the code.
views_in_the_books_alone_are_read_from_their_pagesanda_copy_of_consecutive_pages_shows_them_through_one_viewonly reachalias_as/map_alias, which go throughremapping_and_viewsand lock their own range. Their guards are gone, and the comment now describes the lock (title_memory_remappingheld bymap_aliases' batched preflight), not the preflight. xmem tests: 0 failures in 10 parallel runs on Windows.@tyr0nsur on GitHub · 2026-12-01 00:15 UTC · original
Four fresh Windows
checkjobs on PRs based on7d93ee07hit the exact assertion this addresses. Each reported "a read apart from the remapping had to wait" with a nonzero count:github-bot referenced this pull request2026-12-01 01:03:23 +00:00
@tyr0nsur on GitHub · 2026-12-01 01:02 UTC · original
I independently reran the XMem test on current main
7d93ee07and the same tree with #2439 at3090dbb3applied. The merge changes onlyxmem.rs. Windows 11 / Ryzen 7 5800X, Rust 1.98.1, test executables built bycargo test --locked -p victory-hle --lib --no-run, default range-lock environment.a_scatter_of_many_pages_is_what_one_after_the_other_is(two threads)Runs alternated the binaries and swapped which one ran first each round. The failed pair runs all hit
a read apart from the remapping had to waitwith 3,061–4,174 refusals. The five doc, input, and diagnostics PR jobs now hitting this assertion make the same test failure visible in CI.@OGShotz on GitHub · 2026-12-01 13:02 UTC · original
Tested on current main
5fabb46eand the same tree with this PR (3090dbb3) merged. Windows 11, Ryzen 7 3700X, Rust 1.98.1; test executables built withcargo test --locked -p victory-hle --lib --no-run, default range-lock environment, run with the filtermodules::xmem::.a_read_by_range_waits_only_for_a_remapping_that_meets_itfailed in 10 of 10 runs.--librun passed 3 of 3.So it is a large improvement but not quite all of it on current main. The remaining failure is the same assertion with a much smaller count:
On current main, every test that calls
map_aliasesalready holdsWHOLEwith this PR applied (batched_copies_that_cannot_be_served_change_nothing,a_scatter_of_many_pages_is_what_one_after_the_other_is,a_batched_copy_with_an_unknown_source_leaves_every_destination_it_showed), so the remaining refusals seem to come from another test that takes the whole-title remap lock some other way. The last test that finished before the failure in the captured run wasa_reader_in_place_faults_into_a_lazy_view_while_a_mapping_waits, which may be worth checking.@Tan7rex on GitHub · 2026-12-01 14:37 UTC · original
Tested on Windows 11 Pro (build 26100), RTX 4090, with this PR's change applied onto current
main(5fabb46e; the branch itself is 589 commits behind, and the patch applies cleanly). Test binary built withcargo test --release --locked --no-run -p victory-hle --lib, then run repeatedly; counts are runs in whicha_read_by_range_waits_only_for_a_remapping_that_meets_itfailed.main5fabb46emain+ this PRvictory_hle-*.exe, default threads), 100 runsmodules::xmem::only, 100 runsEvery failure with the PR is the same assertion as before (
a read apart from the remapping had to wait).So the PR helps a lot but does not fully fix the test on current
main. Paired with each of the other 50modules::xmem::tests one at a time (15 runs per pair), it never failed. It fails with about 25 or more of them at once, and bisecting below that lost it. That suggests load or several tests together, not one more test missing theWHOLEguard. I didn't find the cause.One more thing seen, not proven to be caused by the PR: in the 100 whole-lib runs,
large_default_allocations_honour_write_watch_switchfailed 2 times with the PR and 0 times onmain.Not tested: the game (the change is test-only).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.