perf(runtime): coalesce external submission wakes - #1027
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Optimizes cross-thread scheduling by coalescing worker wake notifications while preserving no-lost-wake behavior.
Changes:
- Adds per-worker wake coalescing and queue rechecks before polling.
- Retries interrupted backend eventfd writes.
- Adds tests, benchmarking, and documentation updates.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
include/elio/runtime/worker_thread.hpp |
Adds pending-wake state and helpers. |
include/elio/runtime/scheduler.hpp |
Resets wake claims before blocking polls. |
include/elio/io/epoll_backend.hpp |
Retries eventfd writes on EINTR. |
include/elio/io/io_uring_backend.hpp |
Retries eventfd writes on EINTR. |
tests/unit/test_scheduler.cpp |
Adds wake coalescing and race tests. |
examples/quick_benchmark.cpp |
Benchmarks external submission bursts. |
README.md |
Documents coalesced wakes and benchmark coverage. |
CHANGELOG.md |
Records the optimization. |
wiki/API-Reference.md |
Updates worker wake semantics. |
wiki/Performance-Tuning.md |
Explains wake coalescing and performance effects. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Owner
Author
|
@copilot Please review the current head only. Please do not modify code or push commits. |
Contributor
Reviewed the current head only. I don’t see additional actionable issues in the updated wake-coalescing and regression-test changes. |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Coalesce cross-thread task-submission notifications at the worker boundary so
bursts share one outstanding
eventfdwake instead of issuing one write peraccepted task.
The worker clears the pending-wake claim immediately before a blocking poll and
then rechecks both external queues. Submissions published before the clear are
observed by that recheck; submissions after the clear claim a new notification
and interrupt the poll. This preserves the no-lost-wake guarantee without
reintroducing the former
idle_-sampled lazy-wake race.Type of Change
Related Issues
Closes #1026
Changes Made
Core Changes
acquire clear observes the full producer release sequence before rechecking
the MPSC inbox and overflow queue.
lifecycle stop/drain wakes remain unconditional.
EINTR, because aclaimed wake cannot rely on a later coalesced producer to repair the write.
io_uring, plus an external-submission burst measurement in
quick_benchmark.API Changes (if applicable)
None. Scheduling, affinity, and ownership contracts are unchanged.
Testing
Unit Tests
Integration Tests
Sanitizer Testing
Test Results
Three paired, CPU-pinned quick-benchmark runs measured the producer-side
external submission burst at 686.42 ns/submit on
mainand 155.38 ns/submit onthis branch: a 77.4% reduction (4.42x). Scheduler reschedule remained stable at
22.66 ns on
mainand 22.48 ns on this branch. Timing values are reported aslocal evidence only and are not CI thresholds.
Checklist
Code Quality
Documentation
Testing
Compatibility
Performance (if applicable)
Screenshots / Diagrams
Not applicable.
Additional Notes
Wake coalescing is intentionally separate from scheduler service-quantum work:
this PR removes redundant producer work but does not change how long a worker
may execute its local runnable deque before servicing I/O or external queues.
Reviewer Guidance
Areas requiring special attention:
wake_for_submission(); replacing theexchange with a failed compare-and-exchange would not publish a skipped
producer's queue write.
Questions for reviewers:
handshake?
worker-level claim?
Thank you for contributing to Elio! 🎉