Skip to main content

Module pool

Module pool 

Source
Expand description

Generic pre-warmed instance pool for wasm-backed plugins.

One pool per loaded plugin. Holds a fixed-size queue of warm instances; acquire is a wait-free pop in steady state. Cold first-call latency (10–100 ms wasmtime instantiation) amortizes to pool-size O(1) cost once the pool is primed.

Per the M6.shared lift, the pool is generic over both:

  • T — the pooled instance type (extism::Plugin, wasmtime::component::Instance, or a dummy in tests).
  • E — the loader-specific error type. The factory returns Result<T, E>; acquire constructs E from a resource-exhaustion message via PoolResourceLimit.

Each loader supplies a one-line impl PoolResourceLimit for ItsError so the pool can raise its capacity errors without knowing the loader’s error shape.

Structs§

InstancePool
A pool of pre-warmed instances for one plugin.
PoolConfig
Per-pool configuration.
PoolMetrics
Pool metrics surface — read by host.metric_counter host imports.
PooledInstance
RAII wrapper acquired from an InstancePool: holds the instance and returns it to the pool on drop.

Traits§

PoolResourceLimit
Loader-error trait used by InstancePool::acquire to construct the “pool at capacity” error.