Batch and coalesce mass fiber wakeups#94
Merged
Conversation
Non-owning view over a caller-owned bitmap of bits packed into 64-bit words, with set/test/clear and findBit for in-order enumeration of set or clear bits. Includes unit tests.
Add FiberFuture::setAll and FiberScheduler::scheduleAll to wake many parked fibers at once: enqueue each to its home ready queue, dedup the distinct target processors in a Bitmap, then ring each parked target's doorbell exactly once behind a single seq_cst fence and one submit - instead of a schedule/doorbell/submit per fiber. Cross-ring doorbells post straight into the target's CQ via IORING_OP_MSG_RING; IOSQE_CQE_SKIP_SUCCESS drops the send-side completion and the carrier is tagged CQE_TAG_WAKEUP for the drain to skip. Gated on the new IORING_FEAT_CQE_SKIP feature check at init. signal is split into extractWaitingFiber + schedule so setAll can reuse the extraction. enqueueReady now returns the processor whose doorbell the caller must ring (or null when it self-handled the wake), letting schedule and runFiber ring immediately while scheduleAll defers and coalesces. FiberSequencer drains through setAll; its trivial wait/increment/advance move inline to the header. Adds setAll tests and a SetAllWake benchmark.
There was a problem hiding this comment.
Pull request overview
This PR introduces batched wakeups for parked fibers by adding FiberFuture::setAll() and FiberScheduler::scheduleAll(), aiming to coalesce cross-CPU doorbells and reduce per-fiber io_uring submissions during mass wakeups.
Changes:
- Add
FiberFuture::setAll()to set many futures and batch-schedule their waiting fibers. - Add
FiberScheduler::scheduleAll()plus io_uring MSG_RING-based cross-ring doorbells to coalesce wakeups across target processors. - Introduce a small
Bitmaputility (with tests) to deduplicate wake targets; add tests and a benchmark forsetAll.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/util/tests/bitmap-test.cpp | Adds unit tests for the new Bitmap utility (bit ops + enumeration behavior). |
| src/util/bitmap.cpp | Implements Bitmap::findBit() using word scanning + countr_zero. |
| include/silk/util/bitmap.h | Adds the Bitmap non-owning view utility used for wake-target deduplication. |
| src/fibers/future.cpp | Refactors waiter extraction and adds FiberFuture::setAll() batching logic. |
| include/silk/fibers/future.h | Declares FiberFuture::setAll() and shared batching constant. |
| src/fibers/fiber.cpp | Adds MSG_RING wakeup plumbing, scheduleAll(), and updated enqueue/wakeup flow. |
| include/silk/fibers/fiber.h | Declares FiberScheduler::scheduleAll() and updates enqueueReady signature. |
| src/fibers/sequencer.cpp | Switches drain wakeups to use batched FiberFuture::setAll(). |
| include/silk/fibers/sequencer.h | Inlines trivial sequencer methods and introduces batching helper declaration/constants. |
| src/fibers/tests/future-test.cpp | Adds correctness tests for FiberFuture::setAll() (waiters/no-waiters/empty). |
| src/fibers/benchmarks/future-bench.cpp | Adds a benchmark measuring batched wake performance (SetAllWake). |
| include/silk/util/bounded-queue.h | Adds a documented convenience constructor for initialization-at-construction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Add FiberFuture::setAll and FiberScheduler::scheduleAll to wake many parked fibers at once: enqueue each to its home ready queue, dedup the distinct target processors in a Bitmap, then ring each parked target's doorbell exactly once behind a single seq_cst fence and one submit - instead of a schedule/doorbell/submit per fiber.
Cross-ring doorbells post straight into the target's CQ via IORING_OP_MSG_RING; IOSQE_CQE_SKIP_SUCCESS drops the send-side completion and the carrier is tagged CQE_TAG_WAKEUP for the drain to skip. Gated on the new IORING_FEAT_CQE_SKIP feature check at init.
signal is split into extractWaitingFiber + schedule so setAll can reuse the extraction. enqueueReady now returns the processor whose doorbell the caller must ring (or null when it self-handled the wake), letting schedule and runFiber ring immediately while scheduleAll defers and coalesces.
FiberSequencer drains through setAll; its trivial wait/increment/advance move inline to the header. Adds setAll tests and a SetAllWake benchmark.