microvm-warm-pool
Pre-restored Firecracker microVM pool harness for fast warm handoff.
A pure-Rust primitive that sits on top of microvm-runtime and turns a
snapshot-restore-then-boot flow into a hashmap lookup. Acquire wallclock drops
from ~150 ms (cold) to ~10 ms (warm). The pool itself never speaks the
Firecracker API directly — every state change is delegated to a VmProvider
implementation.
Why this exists
Every Tangle blueprint that needs sub-second tenant handoff (sandbox blueprint, microvm blueprint, future cloud-style blueprints) wants the same pool harness. This crate is that harness, extracted into a single primitive so it can be hardened in one place and consumed as a Cargo dependency.
Status
0.1.0-alpha.1 — extracted from the TypeScript warm-pool that ships in the
sandbox host-agent. Supports:
- Per-
StackKeybuckets (stack_name,version,vcpu_count,mem_size_mib) - Single background refill thread, low/high-water marks
- Age-based eviction
- Per-acquire
EntryValidatorhealth probe with eviction-on-unhealthy - Atomic counters exposed via
WarmPool::metrics()(Prometheus-friendly) - Idempotent shutdown with 200 ms join budget + best-effort destroy of all remaining entries
Not yet:
- Adaptive depth from observed acquire EWMA (today: fixed
[min, max]) - Per-bucket refill coalescing across multiple pools
- Cross-thread metric labelling hook (today: counters only)
Usage
use Arc;
use Duration;
use ;
use ;
;
let provider = default;
let pool = start;
let stack = StackKey ;
pool.register;
// Caller pops a warm entry, then brings up a per-tenant VM by restoring the
// pool's snapshot with their own network override (FC 1.10+ feature).
if let Some = pool.acquire
Host requirements
The pool itself is platform-agnostic and tests pass on any host that runs Rust 1.91. The Firecracker provider it consumes requires:
- Linux with KVM (
/dev/kvmaccessible to the running user) - Firecracker 1.10 or newer for the warm-handoff path —
SnapshotRef::network_overridesis rejected by older versions - A snapshot template (a VM that has been booted, configured, and snapshotted by the operator out-of-band)
API surface
| Type | Purpose |
|---|---|
WarmPool<P> |
Owns the bucket map, refill thread, and validator |
WarmPoolConfig |
min_depth, max_depth, refill_interval, entry_max_age |
WarmPoolHandle |
Returned from acquire: source_vm_id, stack, source_snapshot |
WarmPoolMetrics |
Counter snapshot for Prometheus / observability |
EntryValidator |
Per-entry health probe trait |
ValidationResult |
Healthy or Unhealthy(reason) |
StackKey |
Bucket identifier (stack/version + machine shape) |
Cargo features
default = []— no providers pulled infirecracker— forwardsmicrovm-runtime/firecracker, enabling the in-process Firecracker driver alongside the warm-pool harness
License
Unlicense — public domain.