Add awakened_from_remote() to bypass remote_ready_queue#3
Open
Akatsukis wants to merge 15 commits into
Open
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These mutex types are unused by the top-level project. Removes source files, headers, and references from CMakeLists.txt and all.hpp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes source, header, examples, and performance benchmarks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes source, header, examples, and performance benchmarks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes header, example, and include references from fiber.hpp and all.hpp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes source, header, dedicated test files, and dead do_wait() references in fiber tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes fss.hpp, detail/fss.hpp, test files, and cleans fss_data_ from context.hpp and context.cpp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes header, test files, and examples that solely used unbuffered_channel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unused by the top-level project. Removes rtm.hpp, spinlock_rtm.hpp, and strips BOOST_USE_TSX branches from spinlock.hpp. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Drops all timed-wait APIs from boost.fiber. Affected interfaces:
- boost::this_fiber::sleep_for / sleep_until
- condition_variable::wait_for / wait_until (both _any and the
mutex-bound variants)
- future<T>::wait_for / wait_until, shared_future<T>::wait_for / wait_until
- buffered_channel::push_wait_for / push_wait_until /
pop_wait_for / pop_wait_until
- context::wait_until, context::sleep_link / sleep_unlink /
sleep_is_linked, plus the sleep_hook_, sleep_waker_, tp_ members
- scheduler::wait_until, scheduler::sleep2ready_, sleep_queue_
- wait_queue::suspend_and_wait_until
algorithm::suspend_until(time_point) is renamed to algorithm::suspend()
since the time_point has no meaning without a sleep queue.
round_robin::suspend uses condition_variable::wait(lk, pred) instead of
the timed variant.
Also removes upstream tests and examples that exercised the removed
APIs and would no longer build:
- examples/priority.cpp, examples/wait_stuff.cpp
- test/test_buffered_channel_{dispatch,post}.cpp
- test/test_condition_variable_{,any_}{dispatch,post}.cpp
- test/test_fiber_{dispatch,post}.cpp
- test/test_future_{dispatch,post}.cpp
- test/test_mutex_{dispatch,post}.cpp
- test/test_shared_future_{dispatch,post}.cpp
The corresponding stanzas are stripped from examples/Jamfile.v2 and
test/Jamfile.v2. Untimed coverage of mutex/future/channel/fiber
behaviour remains in the MT variants (test_mutex_mt_*.cpp,
test_future_mt_*.cpp) and the unmodified barrier/promise/async/
packaged_task suites.
Intended for fiber pools where all synchronization is via untimed
waits + cross-thread wakeups; the sleep-queue scan in every dispatch
iteration is gone.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Introduces an optional algorithm hook, awakened_from_remote(context*),
that lets a scheduling algorithm with a thread-safe ready-queue (e.g.
a shared priority queue) take ownership of a remote wakeup directly,
bypassing the per-thread remote_ready_queue_ + spinlock indirection.
When BOOST_FIBERS_AWAKENED_FROM_REMOTE is defined:
- schedule_from_remote() offers non-pinned contexts to the algorithm
first; on a true return the wake is claimed and the algorithm is
notified. Falls back to remote_ready_queue_ for pinned contexts or
when the algorithm declines.
- A new worker_splk_ serializes attach_worker_context() and
detach_worker_context() against each other and against
worker_queue_ traversal in dispatch()/terminate(), so a remote
thread that calls ctx->detach() inside awakened_from_remote()
cannot race the owning thread attaching another fiber.
- A compile-time guard rejects builds that combine the new hook
with BOOST_FIBERS_NO_ATOMICS (single-thread mode).
Invariant asserts in schedule_from_remote() are hoisted above the
fast-path so the debug-time contract still applies when the hook
claims the wake.
Default awakened_from_remote() returns false, so algorithms that
don't override it behave exactly as before.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
c81895e to
0f0d947
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds an optional awakened_from_remote() hook on algorithm so that schedulers with thread-safe ready-queues can bypass the per-thread remote_ready_queue_ when schedule_from_remote() is invoked. It also (apparently inheriting from a dependent PR) removes the sleep-queue mechanism and all timed-wait/sleep public API along with associated tests and examples, and replaces algorithm::suspend_until with a parameterless suspend().
Changes:
- Add
algorithm::awakened_from_remote()virtual hook (default returns false) and integrate fast-path inscheduler::schedule_from_remote, plus a newworker_splk_to serialize attach/detach of worker contexts across threads. - Remove the sleep queue and all
wait_until/wait_for/sleep_for/sleep_untilAPI surface from scheduler, context, condition_variable[_any], future/shared_future, buffered_channel, operations, and wait_queue. - Delete the corresponding
_post/_dispatchtest files and thepriority/wait_stuffexamples, with matching removals intest/Jamfile.v2andexamples/Jamfile.v2.
Reviewed changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| include/boost/fiber/algo/algorithm.hpp | Replace suspend_until with suspend; add awakened_from_remote default hook. |
| include/boost/fiber/algo/round_robin.hpp | Override suspend() instead of suspend_until. |
| src/algo/round_robin.cpp | Implementation now waits unconditionally on the cv. |
| include/boost/fiber/scheduler.hpp | Remove sleep-queue type/state and wait_until; add worker_splk_ and AWAKENED_FROM_REMOTE guards. |
| src/scheduler.cpp | Remove sleep2ready_/wait_until; integrate awakened_from_remote fast path; lock worker_splk_ in attach/detach/terminate/dispatch. |
| include/boost/fiber/context.hpp | Drop sleep_hook, sleep_waker_, tp_, sleep_*/wait_until members. |
| src/context.cpp | Remove wait_until and sleep_* definitions/asserts. |
| include/boost/fiber/waker.hpp, src/waker.cpp | Remove suspend_and_wait_until. |
| include/boost/fiber/condition_variable.hpp | Remove wait_for/wait_until overloads on cv and cv_any. |
| include/boost/fiber/buffered_channel.hpp | Remove push_wait_for/until and pop_wait_for/until. |
| include/boost/fiber/future/future.hpp, .../shared_state.hpp | Remove wait_for/wait_until. |
| include/boost/fiber/operations.hpp | Remove sleep_for/sleep_until. |
| test/Jamfile.v2 | Drop test entries for the removed _post/_dispatch test files. |
| test/test_fiber_{post,dispatch}.cpp, test/test_mutex_, test/test_condition_variable*, test/test_future, test/test_shared_future_, test/test_buffered_channel_* | Deleted. |
| examples/Jamfile.v2, examples/priority.cpp | Remove priority and wait_stuff examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
133ac78 to
a7c0273
Compare
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.
Depends on #2