Skip to main content

WarmPool

Struct WarmPool 

Source
pub struct WarmPool<P: VmProvider + VmQuery + 'static> { /* private fields */ }
Expand description

Warm pool of pre-restored microVMs.

Construct with WarmPool::start; register snapshots to keep warm with WarmPool::register; check out entries with WarmPool::acquire.

The pool is Send + Sync; clone the inner Arc if you need to pass it across thread boundaries.

Implementations§

Source§

impl<P: VmProvider + VmQuery + Clone + 'static> WarmPool<P>

Source

pub fn start( provider: P, config: WarmPoolConfig, validator: Arc<dyn EntryValidator>, ) -> Self

Start a pool with a fresh refill thread.

The pool holds a clone of provider; another clone runs inside the refill thread. Providers from microvm-runtime are cheap to clone (Arc-backed).

Source

pub fn register(&self, stack: StackKey, source_snapshot: SnapshotRef)

Tell the pool which snapshot to keep warm for stack. The refill thread will bring this bucket up to min_depth on its next tick.

Calling register again for the same key replaces the snapshot but keeps existing entries — they continue to be served until evicted by age or validation. Operators wanting hard-cutover should pair this with unregister.

Source

pub fn unregister(&self, stack: &StackKey)

Stop tracking stack. Existing entries are destroyed immediately (best-effort) so the pool doesn’t keep paying for them.

Source

pub fn acquire(&self, stack: &StackKey) -> Option<WarmPoolHandle>

Hand off a pre-restored VM. Pops an entry from stack’s bucket and validates it; on Healthy, returns a WarmPoolHandle. On Unhealthy, the entry is destroyed (validation_failures counter increments) and the next entry is tried. Returns None if the bucket is empty or every remaining entry failed validation.

The returned WarmPoolHandle::source_snapshot is what the caller passes back to VmProvider::create_vm_with_spec after applying its own SnapshotRef::network_overrides.

Source

pub fn metrics(&self) -> WarmPoolMetrics

Snapshot of counters for observability scraping.

Source

pub fn shutdown(&mut self)

Stop the refill thread and best-effort destroy all live entries.

Idempotent. Drop also calls this.

Trait Implementations§

Source§

impl<P: VmProvider + VmQuery + 'static> Debug for WarmPool<P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: VmProvider + VmQuery + 'static> Drop for WarmPool<P>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<P> !RefUnwindSafe for WarmPool<P>

§

impl<P> !UnwindSafe for WarmPool<P>

§

impl<P> Freeze for WarmPool<P>
where P: Freeze,

§

impl<P> Send for WarmPool<P>

§

impl<P> Sync for WarmPool<P>

§

impl<P> Unpin for WarmPool<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for WarmPool<P>
where P: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.