pub struct Pool(Arc<PoolInner>);pool only.Expand description
A buffer pool over compressed extents, backed by swap or by files per its
ExtentBackend. Cheap to clone. All clones share one budget and one
backing store.
Tuple Fields§
§0: Arc<PoolInner>Implementations§
Source§impl Pool
impl Pool
Sourcepub fn new() -> Result<Pool>
pub fn new() -> Result<Pool>
Creates a pool over swap-backed extents, reserving one virtual
region per size class. The pool starts with an unlimited budget, so
nothing is evicted until Pool::set_budget tunes it.
Sourcepub fn with_backend(backend: ExtentBackend) -> Result<Pool>
pub fn with_backend(backend: ExtentBackend) -> Result<Pool>
As Pool::new, over backend. A file backend that cannot open
returns the error, and the caller decides whether to fall back.
Sourcepub fn backend_kind(&self) -> BackendKind
pub fn backend_kind(&self) -> BackendKind
The store the pool runs on.
Sourcefn with_backend_and_class_capacity(
backend: ExtentBackend,
class_capacity_bytes: usize,
) -> Result<Pool>
fn with_backend_and_class_capacity( backend: ExtentBackend, class_capacity_bytes: usize, ) -> Result<Pool>
As Pool::with_backend, with a caller-chosen virtual reservation
per size class.
Sourcepub fn insert_with(
&self,
len: usize,
hints: ChunkHints,
codec: &'static dyn ExtentCodec,
fill: impl FnOnce(&mut [u64]),
) -> ChunkHandle
pub fn insert_with( &self, len: usize, hints: ChunkHints, codec: &'static dyn ExtentCodec, fill: impl FnOnce(&mut [u64]), ) -> ChunkHandle
Allocates a chunk of len words and fills it in place: fill
receives len words of unspecified contents and must overwrite all
of them, so serialization writes its single copy straight into pool
memory. The returned handle starts UnbackedResident, or Evicted
when resident admission is full even after enforcement, in which case
the payload is compressed to an extent on the calling thread before
this returns. A zero len returns a length-0 handle
holding no slot; payloads beyond the largest size class fall back to
a plain heap allocation, always resident, a prototype limitation.
hints steer eviction and write-behind policy; callers without
placement knowledge pass the default. codec is the chunk’s
ExtentCodec, fixed for its lifetime: the pool invokes it whenever
the chunk moves across the extent boundary, and takes no interest in
the stored form it produces.
Relies on abort-on-panic: a panic in fill that was caught would
leak the slot and its resident-bytes accounting. All hosting
binaries abort via mz_ore::panic::install_enhanced_handler, and
pool consumers are dataflow operators, never code hosted under a
catch_unwind boundary the way the optimizer is.
Sourcepub fn insert_typed(
&self,
body: Box<dyn TypedBody>,
hints: ChunkHints,
codec: &'static dyn ExtentCodec,
) -> ChunkHandle
pub fn insert_typed( &self, body: Box<dyn TypedBody>, hints: ChunkHints, codec: &'static dyn ExtentCodec, ) -> ChunkHandle
Inserts a chunk in its owner’s in-memory form (see TypedBody),
charged against the budget at its serialized length. Admission
follows Pool::insert_with: a chunk the budget denies even after
enforcement is serialized and compressed on the calling thread, and a
body with no size class to evict into is serialized onto the heap.
Sourcefn insert_extent(
&self,
len: usize,
class: Option<usize>,
hints: ChunkHints,
codec: &'static dyn ExtentCodec,
fill: impl FnOnce(&mut [u64]),
) -> ChunkHandle
fn insert_extent( &self, len: usize, class: Option<usize>, hints: ChunkHints, codec: &'static dyn ExtentCodec, fill: impl FnOnce(&mut [u64]), ) -> ChunkHandle
Inserts a chunk directly as a compressed extent, with no resident slot.
The fallback when the budget denies an insertion even after
enforcement. The payload is filled into a temporary buffer and
compressed on the calling thread, and the chunk starts evicted, so a
denied insertion adds no resident bytes while the enforcer is busy.
The temporary buffer, up to one size class, is heap memory outside the
pool’s accounting. A chunk inserted here pays for compression even if
it dies young, so under sustained pressure writes_elided undercounts
the writes a resident insertion would have avoided.
Sourcepub fn set_spill_threads(&self, threads: usize)
pub fn set_spill_threads(&self, threads: usize)
Enables or disables off-worker eviction I/O. The first call with
threads > 0 spawns that many spill threads (spawn-once: later calls
only toggle participation); threads == 0 falls back to inline
eviction on the caller for subsequent victims, letting any queued
work drain.
Sourcepub fn set_eager_backing(&self, eager: bool)
pub fn set_eager_backing(&self, eager: bool)
Enables or disables eager backing: when on, idle spill threads
compress unbacked chunks to BackedResident ahead of pressure, so
budget-driven eviction becomes a pure page release. Costs CPU on
chunks that die before eviction would have reached them; pays at
every pressure event. Only meaningful with spill threads spawned.
Sourcepub fn set_file_release(&self, interval: Duration, bytes_per_class: u64)
pub fn set_file_release(&self, interval: Duration, bytes_per_class: u64)
Retunes the file store’s warm-slot release: every interval, a spill
thread punches up to bytes_per_class of each extent class’s free
slots that still hold blocks, so the store’s disk usage follows its
live extents. A zero interval or zero bytes disables the release. No
effect on a swap-backed pool or one without spill threads.
The store’s capacity follows the volume’s free space independently of
the release, re-derived by the spill threads every second. Without
spill threads it changes only when the store hits ENOSPC.
Sourcepub fn set_budget(&self, budget_bytes: usize)
pub fn set_budget(&self, budget_bytes: usize)
Retunes the resident-bytes budget in place and enforces it. Live
handles share the new value immediately through their Arc<PoolInner>;
a shrink takes effect by evicting on this call, a grow simply leaves
more headroom for future inserts.
Sourcepub fn set_rss_target(&self, target_bytes: usize)
pub fn set_rss_target(&self, target_bytes: usize)
Retunes the ceiling on the pool’s total RSS — slots plus warm slots plus compressed-resident extents. The compressed tier’s capacity is the gap above the budget and warm cap; zero (the default) collapses the tier, paging extents out as soon as they are written. A shrink starts paging out the oldest extents on this call.
Sourcepub fn compressed_cap(&self) -> u64
pub fn compressed_cap(&self) -> u64
The capacity of the compressed tier in bytes: the RSS target less the budget, the insert slack in use, and the warm-slot cap.
Sourcepub fn compressed_tier_above_cap(&self) -> bool
pub fn compressed_tier_above_cap(&self) -> bool
Whether the compressed tier is above Pool::compressed_cap, counted
as the backend’s enforcement counts it. False once enforcement and
the spill threads have caught up.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Pool
impl RefUnwindSafe for Pool
impl Send for Pool
impl Sync for Pool
impl Unpin for Pool
impl UnsafeUnpin for Pool
impl UnwindSafe for Pool
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
Source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign, for types that do not implement AddAssign.