hle: only a changed condition-variable word is a wake; loosen probe_s… #64

Merged
AnastasisKon merged 2 commits from upstream-pr/64 into main 2026-11-26 17:08:16 +00:00
AnastasisKon commented 2026-11-26 12:13:48 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by AnastasisKon on 2026-11-26T12:13:48Z.


…ync's scheduling bounds

The native_probe waits test failed about 1 run in 3 on a busy machine. Two timing-based causes, fixed the way the frame.rs tests were:

  • sleep_condition treated any return from wait_on_address as a wake, but spurious returns are possible (the other wait_on_address callers re-check). A spurious return left the CV word unchanged yet was reported as signalled, so a time-out wait could come back 'woken'. Now the word is re-checked after every return and the wait goes on until the word changes or the deadline passes, so a time-out is always a real time-out.
  • probe_sync's waits for another thread to be scheduled at all were bounded at 3-20 s; on a busy host scheduling can take longer, which dropped later check bits (and the T_CS_TRY path returned early). Those bounds are now 30 s (THREAD_SCHEDULED_MS); waits that must time out stay short, since a time-out cannot come early.

Unit tests cover both: a word-less wake must still end as a time-out, and a real WakeConditionVariable ends the wait at once.

Closes #20

What this changes

How it was tested

  • cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings
  • Ran the game (say how far it got), or not needed

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md
  • New diagnostics are behind a VICTORY_* variable and documented
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6626409929 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/64). Originally posted by [AnastasisKon](https://github.com/AnastasisKon) on 2026-11-26T12:13:48Z. --- …ync's scheduling bounds The native_probe waits test failed about 1 run in 3 on a busy machine. Two timing-based causes, fixed the way the frame.rs tests were: - sleep_condition treated any return from wait_on_address as a wake, but spurious returns are possible (the other wait_on_address callers re-check). A spurious return left the CV word unchanged yet was reported as signalled, so a time-out wait could come back 'woken'. Now the word is re-checked after every return and the wait goes on until the word changes or the deadline passes, so a time-out is always a real time-out. - probe_sync's waits for another thread to be scheduled at all were bounded at 3-20 s; on a busy host scheduling can take longer, which dropped later check bits (and the T_CS_TRY path returned early). Those bounds are now 30 s (THREAD_SCHEDULED_MS); waits that must time out stay short, since a time-out cannot come early. Unit tests cover both: a word-less wake must still end as a time-out, and a real WakeConditionVariable ends the wait at once. Closes #20 ## What this changes <!-- One change per pull request. Link the issue or ROADMAP item. --> ## How it was tested - [ ] `cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory` - [ ] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` - [ ] Ran the game (say how far it got), or not needed ## Checklist - [ ] No game files, game code, disassembly listings or SDK files are included - [ ] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md - [ ] New diagnostics are behind a `VICTORY_*` variable and documented
LakshanSivakumar commented 2026-11-26 12:48:26 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:48:26Z.

Review: CHANGES_REQUESTED


Thanks, the lost-wakeup analysis checks out and both new tests fail on the old code. Small things:

  1. INFINITE waits still return 1 on any return, spurious or not. That's legal for a condition variable, but please make the PR text and code comment match.
  2. wait_on_address returns true on EFAULT-type errors without waiting, so a finite wait would spin hot until its deadline. Please add a backoff or a shortcut: comment.
  3. Please fill in the template checklist, and say what you ran and how many times, since the PR removes the "known flaky" line from AGENTS.md.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6074388718 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/64#pullrequestreview-6074388718). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T12:48:26Z. **Review:** CHANGES_REQUESTED --- Thanks, the lost-wakeup analysis checks out and both new tests fail on the old code. Small things: 1. INFINITE waits still return 1 on any return, spurious or not. That's legal for a condition variable, but please make the PR text and code comment match. 2. `wait_on_address` returns true on EFAULT-type errors without waiting, so a finite wait would spin hot until its deadline. Please add a backoff or a `shortcut:` comment. 3. Please fill in the template checklist, and say what you ran and how many times, since the PR removes the "known flaky" line from AGENTS.md.
LakshanSivakumar commented 2026-11-26 13:26:55 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T13:26:55Z.

Review: CHANGES_REQUESTED


Thanks for addressing the code comment on INFINITE waits and adding the 100 us backoff in 841b1f4. Two items from the earlier review are still open before this can merge:

  1. Please update the PR description to match the code comment on INFINITE (u32::MAX) waits returning on any wake.
  2. Please fill in the PR template checklist and note which test command you ran and how many iterations passed without flaking, since this removes the known-flaky note from AGENTS.md.
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6074931446 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/64#pullrequestreview-6074931446). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T13:26:55Z. **Review:** CHANGES_REQUESTED --- Thanks for addressing the code comment on `INFINITE` waits and adding the 100 us backoff in `841b1f4`. Two items from the earlier review are still open before this can merge: 1. Please update the PR description to match the code comment on `INFINITE` (`u32::MAX`) waits returning on any wake. 2. Please fill in the PR template checklist and note which test command you ran and how many iterations passed without flaking, since this removes the known-flaky note from `AGENTS.md`.
LakshanSivakumar commented 2026-11-26 14:55:58 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T14:55:58Z.

Review: CHANGES_REQUESTED


Thanks, the EFAULT backoff is in. Two description items remain: say in the PR text that INFINITE waits return on any wake (the code comment already does), and fill in "What this changes", the testing section and the checklist, including how many times you ran native_probe, since this removes the "known flaky" line from AGENTS.md.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6076268979 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/64#pullrequestreview-6076268979). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T14:55:58Z. **Review:** CHANGES_REQUESTED --- Thanks, the EFAULT backoff is in. Two description items remain: say in the PR text that INFINITE waits return on any wake (the code comment already does), and fill in "What this changes", the testing section and the checklist, including how many times you ran native_probe, since this removes the "known flaky" line from AGENTS.md.
LakshanSivakumar commented 2026-11-26 16:04:00 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T16:04:00Z.

Review: CHANGES_REQUESTED


The EFAULT backoff is in. Still open: the testing section and checklist in the description are unfilled. Please say how many times you ran native_probe, since this removes the known-flaky line from AGENTS.md, and note in the text that INFINITE waits return on any wake. The main CI check also failed on this PR; please look at it.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6077225712 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/64#pullrequestreview-6077225712). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T16:04:00Z. **Review:** CHANGES_REQUESTED --- The EFAULT backoff is in. Still open: the testing section and checklist in the description are unfilled. Please say how many times you ran native_probe, since this removes the known-flaky line from AGENTS.md, and note in the text that INFINITE waits return on any wake. The main CI check also failed on this PR; please look at it.
LakshanSivakumar commented 2026-11-26 16:04:08 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T16:04:08Z.


Correction to my review: I wrote that the main CI check failed on this PR, which I had not verified for this branch. Please disregard that sentence; the open points are the description items only.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7197137085 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/64#issuecomment-7197137085). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T16:04:08Z. --- Correction to my review: I wrote that the main CI check failed on this PR, which I had not verified for this branch. Please disregard that sentence; the open points are the description items only.
LakshanSivakumar commented 2026-11-26 17:08:43 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T17:08:43Z.


Merged in 8c47ddd. native_probe passes here. Next time please fill in the testing section of the description. Thanks!

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7198563610 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/64#issuecomment-7198563610). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T17:08:43Z. --- Merged in 8c47ddd. `native_probe` passes here. Next time please fill in the testing section of the description. Thanks!
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
LakshanSivakumar/Native-Victory-macOS!64
No description provided.