Browse Source
Add a note about host calls to epoch_interruption (#9189 )
Realized we don't actually talk about this in the documentation but it's
an important point, so make sure to document the interaction with
blocking host calls here.
pull/9185/merge
Alex Crichton
2 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
18 additions and
0 deletions
crates/wasmtime/src/config.rs
@ -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