test(timeline): synchronize second thread start before lock-wait sleep #47

Open
Geekmemz wants to merge 1 commit from upstream-pr/47 into main
Geekmemz commented 2026-12-04 16:11:56 +00:00 (Migrated from github.com)

Imported from ReTerryDavis/ReVIctory. Originally posted by Geekmemz on 2026-12-04T16:11:56Z.


Summary

Fixes the intermittent failure in timeline::report::tests::real_waits_are_recorded_with_who_ended_them observed in Default tests on main (e.g., CI run 47363682552, panicking at crates/victory-gpu/src/timeline/report.rs:943:36).

Previously, the test acquired lock, spawned second, slept 20 ms, and immediately dropped held. Under parallel test load, second thread startup can take longer than 20 ms, allowing second to acquire lock uncontended after held is already dropped—leaving trace.waits without an entry for second and panicking on trace.waits[&second].

Changes

  • Synchronize second thread startup with an AtomicBool before starting the hold window (using an atomic spin/yield rather than Mutex/Condvar because hooks::wrap_own() is active and would record extra lock/condvar wait events).
  • Hold lock for 30 ms after second signals readiness before dropping held.
  • Replace bare trace.waits[&second] indexing with .get(&second).into_iter().flatten() so any unexpected failure surfaces cleanly through the assert_eq!(contended.map(|c| c.0), Some(me)) assertion.

Verification

Ran locally on Windows 11 (x86_64-pc-windows-msvc, Rust 1.98.1):

  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings — passed (0 warnings)
  • cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings — passed (0 warnings)
  • cargo test -p victory-gpu --lib --all-features --locked timeline::report -- --nocapture (5 consecutive runs) — 3 passed, 0 failed on all 5 runs
  • cargo test -p xtask --locked — 9 passed, 0 failed (asset policy: 407 files ok)
<!-- greyfinch-sync:ReTerryDavis/ReVIctory:issue:5649992558 --> Imported from [ReTerryDavis/ReVIctory](https://github.com/ReTerryDavis/ReVIctory/pull/47). Originally posted by [Geekmemz](https://github.com/Geekmemz) on 2026-12-04T16:11:56Z. --- ## Summary Fixes the intermittent failure in `timeline::report::tests::real_waits_are_recorded_with_who_ended_them` observed in `Default tests` on `main` (e.g., CI run `47363682552`, panicking at `crates/victory-gpu/src/timeline/report.rs:943:36`). Previously, the test acquired `lock`, spawned `second`, slept 20 ms, and immediately dropped `held`. Under parallel test load, `second` thread startup can take longer than 20 ms, allowing `second` to acquire `lock` uncontended after `held` is already dropped—leaving `trace.waits` without an entry for `second` and panicking on `trace.waits[&second]`. ## Changes - Synchronize `second` thread startup with an `AtomicBool` before starting the hold window (using an atomic spin/yield rather than `Mutex`/`Condvar` because `hooks::wrap_own()` is active and would record extra lock/condvar wait events). - Hold `lock` for 30 ms after `second` signals readiness before dropping `held`. - Replace bare `trace.waits[&second]` indexing with `.get(&second).into_iter().flatten()` so any unexpected failure surfaces cleanly through the `assert_eq!(contended.map(|c| c.0), Some(me))` assertion. ## Verification Ran locally on Windows 11 (`x86_64-pc-windows-msvc`, Rust `1.98.1`): - `cargo clippy -p victory-gpu --all-targets --locked -- -D warnings` — passed (0 warnings) - `cargo clippy -p victory-gpu --all-targets --all-features --locked -- -D warnings` — passed (0 warnings) - `cargo test -p victory-gpu --lib --all-features --locked timeline::report -- --nocapture` (5 consecutive runs) — 3 passed, 0 failed on all 5 runs - `cargo test -p xtask --locked` — 9 passed, 0 failed (asset policy: 407 files ok)
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/47:upstream-pr/47'
git switch 'upstream-pr/47'

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/47'
git switch 'upstream-pr/47'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/47'
git switch 'upstream-pr/47'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/47'
git switch 'main'
git merge --squash 'upstream-pr/47'
git switch 'main'
git merge --ff-only 'upstream-pr/47'
git switch 'main'
git merge 'upstream-pr/47'
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
ReTerryDavis/ReVIctory!47
No description provided.