-
Notifications
You must be signed in to change notification settings - Fork 45
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
"Next task" optimization #64
Comments
An important issue about this slot is that it's unstealable from other workers, which can cause issues in scenarios where correctness directly depends on stealing. The most obvious example is something like this: block_on(spawn(async { block_on(spawn(async{1}))})) Here, if This admittedly pathological scenario only makes progress if some other thread can come in and steal away the inner task. |
This commit attempts to re-introduce the thread-local optimization. It stores the local queues in a multiplex hash map keyed by the thread ID that it started in. It also sets it up so the thread can be woken up by a unique runner ID. cc #64 Signed-off-by: John Nunley <[email protected]>
This commit attempts to re-introduce the thread-local optimization. It stores the local queues in a multiplex hash map keyed by the thread ID that it started in. It also sets it up so the thread can be woken up by a unique runner ID. cc #64 Signed-off-by: John Nunley <[email protected]>
In many actor systems (most notable Erlang), executors are optimized by having a "next task" slot in each executor queue. Whenever a new
Runnable
is scheduled, the future is first pushed to a slot separate from the normal queue. If aRunnable
is already in this slot, it is pushed to the back of the queue. When it comes time to read from this queue, the slot is checked and popped from before the normal queue is.This is optimal because if a task wakes another task to be immediately executed, the second task will be queued up immediately, which can emulate sequential computations very well.
The text was updated successfully, but these errors were encountered: