pub struct RuntimeConfig {
pub fuel: u64,
pub max_wasm_stack: usize,
pub memory_reservation: u64,
pub memory_guard_size: u64,
pub memory_reservation_for_growth: u64,
pub max_store_bytes: u64,
pub timeout: Option<Duration>,
pub async_yield_fuel: Option<u64>,
}Fields§
§fuel: u64§max_wasm_stack: usize§memory_reservation: u64§memory_guard_size: u64§memory_reservation_for_growth: u64§max_store_bytes: u64§timeout: Option<Duration>§async_yield_fuel: Option<u64>Implementations§
Source§impl RuntimeConfig
impl RuntimeConfig
Sourcepub fn native_stack_size(&self) -> usize
pub fn native_stack_size(&self) -> usize
The native stack a thread running programs under this config needs.
max_wasm_stack is an interpreter budget, but a host call that re-enters
Wasm (a callback passed to map, say) nests interpreter frames on the
thread’s own stack. The engine charges each crossing 4 KiB of the budget;
this bounds re-entry depth, not the thread’s available native stack. Debug
builds have measured about 64 KiB per crossing, so this reservation allows
128 KiB per crossing, with an 8 MiB minimum for setup and shallow calls.
Embedders must provide this stack on every thread that polls execution, including after an async task migrates between workers. The runners do not create a thread or inspect remaining stack space. Poll them near the root of the thread, rather than underneath deep native recursion. Undersized stacks can overflow and abort the process instead of returning a trap. Custom host functions must also bound their own native recursion.
Set a Tokio runtime’s thread_stack_size for worker threads. Its
block_on caller runs on the calling thread, so size that thread separately
(also for a current-thread runtime or pollster::block_on). Compilation
separately requires crate::compiler_limits::COMPILER_STACK_BYTES; use
the larger requirement when a thread performs both operations.
pub fn engine(&self) -> Result<Engine>
Sourcepub fn engine_async(&self) -> Result<Engine>
pub fn engine_async(&self) -> Result<Engine>
Same as engine. Config::async_support is a no-op in
wasmtime 44+; this entry point exists so async embedders have a distinct
call site to evolve independently.
pub fn wasmtime_config(&self) -> Config
pub fn store<T>(&self, engine: &Engine, data: T) -> Result<Store<T>>
pub fn store_async<T>(&self, engine: &Engine, data: T) -> Result<Store<T>>
Sourcepub fn arm_timeout(&self, engine: &Engine) -> Result<Option<Watchdog>>
pub fn arm_timeout(&self, engine: &Engine) -> Result<Option<Watchdog>>
Arm the configured timeout, failing setup if its thread cannot be created. Keep the returned guard alive until guest execution finishes.
Sourcepub async fn run(&self, wasm_bytes: &[u8]) -> Result<RunResult>
pub async fn run(&self, wasm_bytes: &[u8]) -> Result<RunResult>
One-shot runner: load compiled Wasm, instantiate, call main, return typed result
and captured console. Async like the rest of the runtime — a caller that
isn’t on a runtime bridges it itself (pollster::block_on for
compute/fs-only programs, a tokio runtime when http is involved). For
live console streaming, build a custom Store<StoreData> and call
dispatch_main_async directly.
§Native stack
Every thread polling this future must meet Self::native_stack_size’s
caller contract. This method does not provision a stack. Compilation
separately requires crate::compiler_limits::COMPILER_STACK_BYTES.
Sourcepub async fn run_compiled(&self, compiled: &CompiledScript) -> Result<RunResult>
pub async fn run_compiled(&self, compiled: &CompiledScript) -> Result<RunResult>
Runs a compiled script with its result type information and captured console.
§Native stack
Every thread polling this future must meet Self::native_stack_size’s
caller contract, just as for Self::run. Compiling the script separately
requires crate::compiler_limits::COMPILER_STACK_BYTES.