Skip to content

Fix alarm wake predicate to avoid scheduler busy-spin#15

Merged
viknash merged 1 commit into
masterfrom
perf/fix-alarm-wake-predicate
Jun 30, 2026
Merged

Fix alarm wake predicate to avoid scheduler busy-spin#15
viknash merged 1 commit into
masterfrom
perf/fix-alarm-wake-predicate

Conversation

@viknash

@viknash viknash commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • fix �larm::sleep to evaluate the wake predicate (_wake_up_func()) instead of checking function-object existence
  • this restores intended blocking behavior for idle worker threads
  • reduces unnecessary CPU spinning when no work is available

Why this is high-impact, low-effort

  • one-line change in the scheduler wait path
  • directly affects every worker thread idle cycle
  • preserves scheduler semantics while removing avoidable busy-loop behavior

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 30, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes task_scheduler::alarm::sleep so it evaluates the provided wake predicate (wake_up_function) rather than only checking whether the std::function object is non-empty, restoring proper blocking behavior for idle worker threads and avoiding unnecessary busy spinning.

Changes:

  • Update alarm::sleep to loop on _wake_up_func() (predicate result) instead of _wake_up_func (function object presence).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@viknash
viknash merged commit 8051467 into master Jun 30, 2026
1 check passed
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.

2 participants