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

Use a multi-threaded Tokio runtime as a fallback #8229

Merged

Conversation

alexcrichton
Copy link
Member

This commit fixes a bug that was introduced in #8190 and brought up on Zulip. In #8190 there was a subtle change in how Tokio and the CLI are managed, namely that a Tokio runtime is installed at the start of the CLI to avoid entering/exiting the runtime on each blocking call. This had a small performance improvement relative to entering/exiting on each blocking call. This meant, though, that calls previously blocked with Runtime::block_on and now block with Handle::block_on. The documentation of Handle::block_on has a clause that says that for single-threaded runtimes I/O and timers won't work.

To fix this issue I've switch the fallback runtime to a multi-threaded runtime to ensure that I/O and timers continue to work.

This commit fixes a bug that was introduced in bytecodealliance#8190 and brought up on
[Zulip]. In bytecodealliance#8190 there was a subtle change in how Tokio and the CLI are
managed, namely that a Tokio runtime is installed at the start of the
CLI to avoid entering/exiting the runtime on each blocking call. This
had a small performance improvement relative to entering/exiting on each
blocking call. This meant, though, that calls previously blocked with
`Runtime::block_on` and now block with `Handle::block_on`. The
[documentation of `Handle::block_on`][doc] has a clause that says that
for single-threaded runtimes I/O and timers won't work.

To fix this issue I've switch the fallback runtime to a multi-threaded
runtime to ensure that I/O and timers continue to work.

[Zulip]: https://bytecodealliance.zulipchat.com/#narrow/stream/219900-wasi/topic/Wasi-http.20requests.20hang/near/429187256
[doc]: https://docs.rs/tokio/latest/tokio/runtime/struct.Handle.html#method.block_on
@alexcrichton alexcrichton requested a review from a team as a code owner March 24, 2024 18:53
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team March 24, 2024 18:53
@github-actions github-actions bot added the wasi Issues pertaining to WASI label Mar 24, 2024
@alexcrichton alexcrichton added this pull request to the merge queue Mar 25, 2024
Merged via the queue into bytecodealliance:main with commit 28d2990 Mar 25, 2024
19 checks passed
@alexcrichton alexcrichton deleted the fix-blocking-io-and-timers branch March 25, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi Issues pertaining to WASI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants