Skip to main content

PoolPlan

Struct PoolPlan 

Source
pub struct PoolPlan {
    pub num_slots: usize,
    pub slot_size: usize,
    pub slice_size: usize,
}
Expand description

The geometry of one pass’s slot pool: how many slots, how big each is, and — the load-bearing part — the slice_size at which the reader cuts files.

§Why slice_size is planned separately from slot_size

slice_size is an output-affecting quantity: it is the big/small partition threshold in compress_dir AND the chunk length a big file is cut into, so it lands in chunk_seq / fdata_offset / every chunk checksum. Change it and the archive changes.

slot_size and num_slots are not output-affecting. They decide only how many slices coalesce into one buffer and how many buffers are in flight — the reader publishes and claims a fresh slot whenever the next slice does not fit (Clip::remaining), and the compress sink writes in producer order regardless. So the pool’s memory footprint can be shrunk to fit the input or a memory budget while the bytes on disk stay identical.

That is exactly what PoolPlan::plan does: slice_size is pinned to DEFAULT_SLOT_SIZE / num_workers — the value the old hardcoded pool implied — and only the reservation moves.

Fields§

§num_slots: usize§slot_size: usize§slice_size: usize

Implementations§

Source§

impl PoolPlan

Source

pub fn bytes(&self) -> u64

Bytes this plan will allocate up front.

Source

pub fn default_for(num_workers: usize) -> Self

The unshrunk geometry: DEFAULT_NUM_SLOTS × DEFAULT_SLOT_SIZE (1.6 GiB).

Source

pub fn slice_size_for(num_workers: usize) -> usize

The output-affecting cut length. Depends ONLY on num_workers, never on how much of the pool we could afford — that invariant is what keeps a memory-shrunk run byte-identical to a fat-box run on the same host.

Source

pub fn plan(input_bytes: u64, num_workers: usize, budget_bytes: u64) -> Self

Plan a pool that is no larger than it needs to be.

The reservation is the smallest of three bounds:

  • the old defaultDEFAULT_NUM_SLOTS × DEFAULT_SLOT_SIZE; this function never reserves more than the code did before,
  • the input — a pass that will read input_bytes can never keep more than ceil(input_bytes / slice_size) slices in flight, so slots beyond that are pure waste (a 5 MiB staging tree no longer reserves 1.6 GiB),
  • the budgetbudget_bytes from the caller (see common_config::slot_pool_budget_bytes, which reads the cgroup limit), so a constrained pod shrinks instead of being OOM-killed.

The floor is one slot of one slice: the pipeline must be able to hold the largest cut it can produce, so it always makes progress no matter how small the budget claims to be.

Trait Implementations§

Source§

impl Clone for PoolPlan

Source§

fn clone(&self) -> PoolPlan

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PoolPlan

Source§

impl Debug for PoolPlan

Source§

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

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

impl Eq for PoolPlan

Source§

impl PartialEq for PoolPlan

Source§

fn eq(&self, other: &PoolPlan) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PoolPlan

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.