Skip to content
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

Try waking up a WorkerThread before spawning a HelperThread #1928

Merged
merged 2 commits into from
May 8, 2021
Merged

Try waking up a WorkerThread before spawning a HelperThread #1928

merged 2 commits into from
May 8, 2021

Conversation

vasilmkd
Copy link
Member

At the moment, any scala.concurrent.blocking operation is handled too paranoiacally, with a HelperThread being spawned almost every time and the local queue of the blocked worker thread completely drained. This is not ideal for the situations where there are blocking operations which occur infrequently. In those situations, it is better to try to wake up another worker thread which would be able to steal the fibers of the blocked thread. That way, no new thread needs to be spawned, which is much faster and safer. If the blocking does propagate to other worker threads, or if a worker thread could not be woken up due to any reason, this degrades to the old implementation where a HelperThread is spawned in anticipation.

@vasilmkd vasilmkd marked this pull request as draft April 25, 2021 14:46
@vasilmkd vasilmkd marked this pull request as ready for review May 7, 2021 00:45
@djspiewak
Copy link
Member

This is really cool!

@djspiewak djspiewak merged commit 2356a96 into typelevel:series/3.x May 8, 2021
@vasilmkd vasilmkd deleted the blocking branch May 8, 2021 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants