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: usizeImplementations§
Source§impl PoolPlan
impl PoolPlan
Sourcepub fn default_for(num_workers: usize) -> Self
pub fn default_for(num_workers: usize) -> Self
The unshrunk geometry: DEFAULT_NUM_SLOTS × DEFAULT_SLOT_SIZE (1.6 GiB).
Sourcepub fn slice_size_for(num_workers: usize) -> usize
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.
Sourcepub fn plan(input_bytes: u64, num_workers: usize, budget_bytes: u64) -> Self
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 default —
DEFAULT_NUM_SLOTS × DEFAULT_SLOT_SIZE; this function never reserves more than the code did before, - the input — a pass that will read
input_bytescan never keep more thanceil(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 budget —
budget_bytesfrom the caller (seecommon_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§
impl Copy for PoolPlan
impl Eq for PoolPlan
impl StructuralPartialEq for PoolPlan
Auto Trait Implementations§
impl Freeze for PoolPlan
impl RefUnwindSafe for PoolPlan
impl Send for PoolPlan
impl Sync for PoolPlan
impl Unpin for PoolPlan
impl UnsafeUnpin for PoolPlan
impl UnwindSafe for PoolPlan
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.