-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC 2: Skeleton for ExecutionContext #15350
Open
ysbaddaden
wants to merge
10
commits into
crystal-lang:master
Choose a base branch
from
ysbaddaden:feature/execution-context-skeleton
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
RFC 2: Skeleton for ExecutionContext #15350
ysbaddaden
wants to merge
10
commits into
crystal-lang:master
from
ysbaddaden:feature/execution-context-skeleton
+480
−50
Conversation
This file contains 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
- Add the `ExecutionContext` module; - Add the `ExecutionContext::Scheduler` module; - Add the `execution_context` compile-time flag. When the `execution_context` flag is set: - Don't load `Crystal::Scheduler`; - Plug `ExecutionContext` instead of `Crystal::Scheduler` in `spawn`, `Fiber`, ... This is only the skeleton: there are no implementations (yet). Trying to compile anything with `-Dexecution_context` will obviously fail for the time being.
The current ST and MT schedulers use a distinct pool per thread, which means we only need the thread safety for execution contexts that will share a single pool for a whole context.
The point is to avoid parallel enqueues while running the event loop, so we get better control to where and how the runnable fibers are enqueued; for example all at once instead of one by one (may not be as effective as it sounds). More importantly for Execution Contexts: it avoids parallel enqueues while the eventloop is running which sometimes leads to confusing behavior; for example when deciding to wake up a scheduler/thread we musn't interryupt the event loop (obviously). This is working correctly for the Polling (Epoll, Kqueue) and IOCP event loop implementations. I'm less confident with the libevent one where the external library executes arbitrary callbacks.
Co-authored-by: Johannes Müller <straightshoota@gmail.com>
We need this because we don't load crystal/scheduler anymore when execution contexts are enabled.
Open
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.
Integrates the skeleton as per RFC #0002.
ExecutionContext
module;ExecutionContext::Scheduler
module;execution_context
compile-time flag.When the
execution_context
flag is set:Crystal::Scheduler
;ExecutionContext
instead ofCrystal::Scheduler
inspawn
,Fiber
, ...This is only the skeleton: there are no implementations (yet). Trying to compile anything with
-Dexecution_context
will obviously fail until the follow up pull requests implementing at least the ST and/or MT context are merged.refs #15342