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

Add a note about host calls to epoch_interruption #9189

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions crates/wasmtime/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,24 @@ impl Config {
/// [`Store::set_epoch_deadline`](crate::Store::set_epoch_deadline). If this
/// deadline is not configured then wasm will immediately trap.
///
/// ## Interaction with blocking host calls
///
/// Epochs (and fuel) do not assist in handling WebAssembly code blocked in
/// a call to the host. For example if the WebAssembly function calls
/// `wasi:io/poll/poll` to sleep epochs will not assist in waking this up or
/// timing it out. Epochs intentionally only affect running WebAssembly code
/// itself and it's left to the embedder to determine how best to wake up
/// indefinitely blocking code in the host.
///
/// The typical solution for this, however, is to use
/// [`Config::async_support(true)`](Config::async_support) and the `async`
/// variant of WASI host functions. This models computation as a Rust
/// `Future` which means that when blocking happens the future is only
/// suspended and control yields back to the main event loop. This gives the
/// embedder the opportunity to use `tokio::time::timeout` for example on a
/// wasm computation and have the desired effect of cancelling a blocking
/// operation when a timeout expires.
///
/// ## When to use fuel vs. epochs
///
/// In general, epoch-based interruption results in faster
Expand Down