Skip to content

Fix stale wakeups from Scheduler#unblock interrupting other operations - #468

Open
tavianator wants to merge 1 commit into
mainfrom
fix-stale-unblock
Open

Fix stale wakeups from Scheduler#unblock interrupting other operations#468
tavianator wants to merge 1 commit into
mainfrom
fix-stale-unblock

Conversation

@tavianator

@tavianator tavianator commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Fixes: #467

Types of Changes

  • Bug fix.

Contribution

@ioquatix

Copy link
Copy Markdown
Member

Thanks for this work.

My initial feeling is, this is compensating for a bug that can manifest in other ways.

Spurious wakeups are a reality of high peformance concurrency - sometimes it's hard to track enough state, efficiently, to not wake something up incorrectly. It's usually more efficient to deal with the spurious wakeup (e.g. go back to sleep) rather than try to fix the source.

That being said, I'll review this PR in more detail soon.

@tavianator

Copy link
Copy Markdown
Contributor Author

Yeah that's fair, I think a reasonable alternative fix would be to have wait_*able loop and call io_wait again if it returns false before the timeout

@ioquatix

Copy link
Copy Markdown
Member

@tavianator I think that's the correct solution, but feel free to figure it out.

Eventually, I'd like to transition io-event and async to a ready-list based scheduler, so spurious wakeups may become more common.

@tavianator

Copy link
Copy Markdown
Contributor Author

@ioquatix Wrote up that alternative as #469. I like it a lot better except it doesn't fix sleep() waking up early (since Kernel#sleep(5) and ConditionVariable#wait(mutex, 5) are indistinguishable, but an unblock has to wake up the CV wait)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sleep/IO timeout can return early under concurrent per-fiber timeouts (async 2.42.0)

2 participants