Tests: wait for the late page list instead of sleeping #2736

Open
Therecalloftheonion wants to merge 1 commit from upstream-pr/2738 into main
Therecalloftheonion commented 2026-11-25 19:23:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Therecalloftheonion on 2026-11-25T19:23:49Z.


What

The late page-list test no longer sleeps 2 ms and hopes the copy has not started.

The copy reports the destination whose page list it found empty and started waiting for; the test fills the list only then. This deterministically covers the retry path instead of racing it.

Why

a_page_list_filled_after_its_request_starts failed intermittently under parallel test load: a 2 ms sleep can arrive after the 8 ms retry window. With the counter the fill happens while the copy is waiting.

Testing

  • cargo test -p victory-hle --lib: passed repeatedly (5 consecutive runs)
  • cargo test -p victory-hle --lib modules::dstorage: passed repeatedly
<!-- greyfinch-sync:Marvisak/VIctory:issue:5497700843 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2738). Originally posted by [Therecalloftheonion](https://github.com/Therecalloftheonion) on 2026-11-25T19:23:49Z. --- ## What The late page-list test no longer sleeps 2 ms and hopes the copy has not started. The copy reports the destination whose page list it found empty and started waiting for; the test fills the list only then. This deterministically covers the retry path instead of racing it. ## Why `a_page_list_filled_after_its_request_starts` failed intermittently under parallel test load: a 2 ms sleep can arrive after the 8 ms retry window. With the counter the fill happens while the copy is waiting. ## Testing - `cargo test -p victory-hle --lib`: passed repeatedly (5 consecutive runs) - `cargo test -p victory-hle --lib modules::dstorage`: passed repeatedly
kotekompotek commented 2026-11-25 20:06:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:06:19Z.


Makes the flaky test deterministic: the filler spins on LATE_DESTINATION (set exactly when the copy first finds the empty page list) instead of racing a fixed 2 ms sleep against the 8 ms retry window. 5 s bound with an assert means a broken wait fails loudly rather than timing out silently.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7173196941 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2738#issuecomment-7173196941). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T20:06:19Z. --- Makes the flaky test deterministic: the filler spins on LATE_DESTINATION (set exactly when the copy first finds the empty page list) instead of racing a fixed 2 ms sleep against the 8 ms retry window. 5 s bound with an assert means a broken wait fails loudly rather than timing out silently.
fuzeofficlal commented 2026-11-25 21:03:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T20:14:31Z.


Reviewed and verified 9caeb474 (merged cleanly onto main 13f91ca) on Windows 11 (rustc 1.98.1 MSVC).

  • Replacing the fixed 2 ms sleep with the LATE_DESTINATION AtomicUsize rendezvous (SeqCst) and a 5 s timeout eliminates the timing flake without deadlock risk (minor nit: resetting LATE_DESTINATION to 0 at the end of the test would keep it spotless if future tests ever share it).
  • cargo test -p victory-hle --lib --locked (3 consecutive full parallel runs): 3/3 passed (146 passed, 0 failed + crash_child 1/1 each run).
  • cargo test -p victory-hle --lib --locked -- modules::dstorage::tests:: (3 consecutive runs): 3/3 passed (16/16 each run).
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: 0 warnings; cargo xtask policy: 184 files ok.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7173382495 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2738#issuecomment-7173382495). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T20:14:31Z. --- Reviewed and verified `9caeb474` (merged cleanly onto `main` `13f91ca`) on Windows 11 (`rustc 1.98.1` MSVC). - Replacing the fixed 2 ms sleep with the `LATE_DESTINATION` `AtomicUsize` rendezvous (`SeqCst`) and a 5 s timeout eliminates the timing flake without deadlock risk (minor nit: resetting `LATE_DESTINATION` to `0` at the end of the test would keep it spotless if future tests ever share it). - `cargo test -p victory-hle --lib --locked` (3 consecutive full parallel runs): **3/3 passed** (`146 passed, 0 failed` + `crash_child` `1/1` each run). - `cargo test -p victory-hle --lib --locked -- modules::dstorage::tests::` (3 consecutive runs): **3/3 passed** (`16/16` each run). - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: **0 warnings**; `cargo xtask policy`: **184 files ok**.
Marvisak commented 2026-11-26 00:03:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:23:01Z.


Automated triage for the maintainers.

This makes a_page_list_filled_after_its_request_starts (crates/victory-hle/src/modules/dstorage.rs) deterministic: into_destination records the destination whose page list it found empty in a #[cfg(test)] LATE_DESTINATION, and the test's filler thread writes the page number only once that happens, instead of a fixed 2 ms sleep that can land before the copy starts (so the retry path is never exercised) or after the 8 ms retry window. I checked that the recorded request.destination is the same leaked list address the test waits on, that the hook compiles out of non-test builds, and that the 5 s bound fails loudly rather than hanging. CI (check) passes.

This is a recommendation for a maintainer to look, not an approval.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177484256 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2738#issuecomment-7177484256). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T23:23:01Z. --- <!-- victory-triage v1 head=9caeb474baebe0804caff01830788aeb058b2e64 verdict=merge-candidate at=2026-11-25T23:22:54Z --> Automated triage for the maintainers. This makes `a_page_list_filled_after_its_request_starts` (`crates/victory-hle/src/modules/dstorage.rs`) deterministic: `into_destination` records the destination whose page list it found empty in a `#[cfg(test)]` `LATE_DESTINATION`, and the test's filler thread writes the page number only once that happens, instead of a fixed 2 ms sleep that can land before the copy starts (so the retry path is never exercised) or after the 8 ms retry window. I checked that the recorded `request.destination` is the same leaked list address the test waits on, that the hook compiles out of non-test builds, and that the 5 s bound fails loudly rather than hanging. CI (`check`) passes. This is a recommendation for a maintainer to look, not an approval. --- _Generated by [Claude Code](https://claude.ai/code)_
futurepro62 commented 2026-11-26 13:04:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T12:50:05Z.


NVIDIA full-suite run, to go with the reports above by fuzeofficlal, since none of them names a GPU run. Tested exact head 9caeb47 (on its base da82e44).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 773 passed, 0 failed, 9 ignored.
  • No new #[test] functions in the diff.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7192521749 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2738#issuecomment-7192521749). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T12:50:05Z. --- NVIDIA full-suite run, to go with the reports above by fuzeofficlal, since none of them names a GPU run. Tested exact head `9caeb47` (on its base `da82e44`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **773 passed, 0 failed, 9 ignored**. - No new `#[test]` functions in the diff. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
Dukestar69 commented 2026-11-26 18:09:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T18:09:38Z.

Review: APPROVED


Reviewed the diff and verified locally on Windows 11 x64:

  • Synchronizing the filler thread on #[cfg(test)] LATE_DESTINATION removes the flaky 2 ms sleep race in a_page_list_filled_after_its_request_starts and guarantees the late-list retry path is exercised.
  • cargo test -p victory-hle --lib modules::dstorage:: -- --test-threads=1: 16 passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6078800929 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2738#pullrequestreview-6078800929). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T18:09:38Z. **Review:** APPROVED --- Reviewed the diff and verified locally on Windows 11 x64: - Synchronizing the filler thread on `#[cfg(test)] LATE_DESTINATION` removes the flaky 2 ms sleep race in `a_page_list_filled_after_its_request_starts` and guarantees the late-list retry path is exercised. - `cargo test -p victory-hle --lib modules::dstorage:: -- --test-threads=1`: 16 passed, 0 failed. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-27 01:46:34 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T01:46:34Z.

Review: APPROVED


Reviewed 9caeb474baebe0804caff01830788aeb058b2e64.

LGTM — signaling LATE_DESTINATION under #[cfg(test)] right as into_destination enters the pages.contains(&0) retry loop removes the blind 2ms sleep race in a_page_list_filled_after_its_request_starts cleanly, and leaking the per-test [0usize; 1] page list gives each run a distinct pointer address.

Verified locally:

  • cargo xtask policy (191 files ok) and cargo clippy -p victory-hle --all-targets / --all-features (-D warnings) pass cleanly.
  • cargo test -p victory-hle --lib modules::dstorage:: passed 5/5 default runs and 10/10 parallel stress runs (-- --test-threads=8, 16 passed per run).

Non-blocking notes:

  • rustfmt --edition 2024 --check flags import ordering at crates/victory-hle/src/modules/dstorage.rs:25-27 (#[cfg(test)] use std::sync::atomic::AtomicUsize; sorts ahead of the grouped std::sync::atomic::{...} import).
  • The write_volatile in the test thread paired with the non-atomic slice re-read in the worker still has no happens-before edge in Rust's memory model, and calling filler.join() before asserting wait(array, 0) == S_OK would avoid detaching the helper thread on failure.
<!-- greyfinch-sync:Marvisak/VIctory:review:6082405321 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2738#pullrequestreview-6082405321). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T01:46:34Z. **Review:** APPROVED --- Reviewed `9caeb474baebe0804caff01830788aeb058b2e64`. **LGTM** — signaling `LATE_DESTINATION` under `#[cfg(test)]` right as `into_destination` enters the `pages.contains(&0)` retry loop removes the blind `2ms` sleep race in `a_page_list_filled_after_its_request_starts` cleanly, and leaking the per-test `[0usize; 1]` page list gives each run a distinct pointer address. Verified locally: - `cargo xtask policy` (`191 files ok`) and `cargo clippy -p victory-hle --all-targets` / `--all-features` (`-D warnings`) pass cleanly. - `cargo test -p victory-hle --lib modules::dstorage::` passed 5/5 default runs and 10/10 parallel stress runs (`-- --test-threads=8`, 16 passed per run). Non-blocking notes: - `rustfmt --edition 2024 --check` flags import ordering at `crates/victory-hle/src/modules/dstorage.rs:25-27` (`#[cfg(test)] use std::sync::atomic::AtomicUsize;` sorts ahead of the grouped `std::sync::atomic::{...}` import). - The `write_volatile` in the test thread paired with the non-atomic slice re-read in the worker still has no happens-before edge in Rust's memory model, and calling `filler.join()` before asserting `wait(array, 0) == S_OK` would avoid detaching the helper thread on failure.
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/2738:upstream-pr/2738'
git switch 'upstream-pr/2738'

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/2738'
git switch 'upstream-pr/2738'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2738'
git switch 'upstream-pr/2738'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2738'
git switch 'main'
git merge --squash 'upstream-pr/2738'
git switch 'main'
git merge --ff-only 'upstream-pr/2738'
git switch 'main'
git merge 'upstream-pr/2738'
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
Marvisak/VIctory!2736
No description provided.