Skip to main content

Module spill

Module spill 

Source
Expand description

Spill strategies and policies for MergeQueue entries under memory pressure.

Three traits compose here:

  • SpillPolicy decides whether and how a queue should be reshaped at each extend. It is handed the raw VecDeque<QueueEntry> under the queue’s mutex and may replace entries freely.
  • BytesSpill decides where bytes go when a policy chooses to spill. Pluggable: file, object store, mlock pool, in-memory mock for tests.
  • BytesFetch is the handle returned by a BytesSpill; it reads the spilled bytes back, consuming itself in the process.

The shipped threshold::Threshold pairs a BytesSpill strategy with threshold/reserve/budget knobs and encodes the “spill the middle of the queue when resident bytes get too large” heuristic. Other policies can make entirely different decisions (memory-pressure-driven, periodic, manual trigger, adaptive) using the same strategies.

Modules§

prefetch
Reader-side policy: materializes Paged entries near the front.
threshold
Writer-side spill policy: threshold-based, spills the middle of the queue.

Structs§

PrefetchPolicy
A reader-side SpillPolicy that materializes Paged entries near the front of the queue up to a byte budget. The writer-side dual of super::threshold::Threshold: the writer pages data out, the reader pages data back in — both through SpillPolicy::apply.
Threshold
A threshold-based SpillPolicy: when a queue’s resident-byte count exceeds head_reserve_bytes + threshold_bytes, spill all entries past the head reserve (except the last entry, which stays as the try_merge target).

Traits§

BytesFetch
A consume-once handle to bytes previously written via a BytesSpill.
BytesSpill
A type that can convert runs of bytes into runs of boxed bytes retrieval.
SpillPolicy
Inspects and optionally rewrites a MergeQueue’s entries.

Type Aliases§

SpillPolicyFn
A function that produces pairs of writer and reader SpillPolicys.