-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Never create more than one Tokio runtime. Remove tokio_util::block_on #2960
Comments
Is the issue we should be using .await instead block_on (and rewrite higher up the stack in terms of futures), or is there something fundamental I'm missing ? |
@hayd No - it's more complicated than that... I'll try to write up something later. But it has to do with how Isolate::poll is designed. |
This maybe a naive question, but why didn't we use EDIT: Nevermind... |
Update: in #3043 the major bottleneck to removing tokio_util::block_on was eliminated by reorganizing how the TS compiler works. There are still many usages:
but I suspect these should be easily removable now... |
@ry most of those usages are for test. I'll look into it |
Update: with #3059 and #3080 landed, we're left with a single call to |
This PR removes tokio_util::block_on - refactored compiler and file fetcher slightly so that we can safely block there - that's because only blocking path consist of only synchronous operations. Additionally I removed excessive use of tokio_util::panic_on_error and tokio_util::run_in_task and moved both functions to cli/worker.rs, to tests module. Closes #2960
This PR removes tokio_util::block_on - refactored compiler and file fetcher slightly so that we can safely block there - that's because only blocking path consist of only synchronous operations. Additionally I removed excessive use of tokio_util::panic_on_error and tokio_util::run_in_task and moved both functions to cli/worker.rs, to tests module. Closes denoland#2960
There is a hack we've introduced called tokio_util::block_on, which can execute a future in a new Tokio runtime. Not only is this blocking, but it creates many extra threads. We use it in the module loader to avoid certain deadlocks - fundamentally the things we are blocking on are simple network connections which could be done on a single thread.
Recently we parallelized some module loading, which caused a visible explosion in the number of threads.
This
tokio_util::block_on
is a problem of our own creation (indeed, it's my design mistake). There is no fundamental reason for it to exist. We should be able to load and execute complex code on a single thread. It may be some of our fundamental abstractions are causing this even, and need to be reconsidered. Namely the idea that an Isolate is a Future and that all of its ops are polled manually from that future.This is a v1.0 blocker.
The text was updated successfully, but these errors were encountered: