pub struct DirectorPool<I: IndexLike = u32, const TRACK: bool = true, const PROOFS: bool = false> { /* private fields */ }Expand description
Semi-persistent spill pool for oversized director matrices.
Each entry is length-prefixed:
pool[start] = bit_length (as PoolDirector)
pool[start+1..] = matrix data, ceil(bit_length / 63) words
The working pool is a VecI<PoolDirector, I, TRACK> — supports in-place
mutation (for re-canonization during rebuild) with capture tracking.
When PROOFS = true, a separate append-only proof pool snapshots
spilled matrices at copy-on-first-recanonicalization time. The proof
pool is never truncated during working rollback.
§Index width
I is the pool’s index word. It was hard-coded to u32, capping the pool at 4 G
words (32 GB) whatever id family the session configured — a ceiling a 63-bit
configuration can reach. The word is also what the capture journal stores per
touched entry, so it should be the narrowest type that spans the pool, not usize.
A tighter bound applies from the other side: a Director<W> names an entry in
W::BITS - 1 bits (see Director::new_spilled), so an I wider than that buys
nothing.
Implementations§
Source§impl<I: IndexLike, const TRACK: bool, const PROOFS: bool> DirectorPool<I, TRACK, PROOFS>
impl<I: IndexLike, const TRACK: bool, const PROOFS: bool> DirectorPool<I, TRACK, PROOFS>
pub fn new() -> Self
Sourcepub fn append(&mut self, bit_length: u32, data: &[PoolDirector]) -> I
pub fn append(&mut self, bit_length: u32, data: &[PoolDirector]) -> I
Append a spilled matrix to the working pool. Returns the start index.
Growth past I’s range is caught by the container’s overflow protocol: push
carries no check of its own, and the next len() read — the one this method
starts with — traps.
Sourcepub fn bit_length(&self, start: I) -> u32
pub fn bit_length(&self, start: I) -> u32
Read bit_length from a working pool entry.
Sourcepub fn get(&self, idx: I) -> PoolDirector
pub fn get(&self, idx: I) -> PoolDirector
Get a single working pool word by index.
Sourcepub fn set(&mut self, idx: I, val: PoolDirector)
pub fn set(&mut self, idx: I, val: PoolDirector)
Mutate a working pool word in place (for re-canonization).
Sourcepub fn read(&self, start: I) -> (u32, Vec<PoolDirector>)
pub fn read(&self, start: I) -> (u32, Vec<PoolDirector>)
Read a spilled matrix from the working pool.
pub fn is_empty(&self) -> bool
Sourcepub fn mark(&mut self, shrink: ShrinkPolicy) -> VecToken
pub fn mark(&mut self, shrink: ShrinkPolicy) -> VecToken
Mark for semi-persistent checkpoint.
Sourcepub fn snapshot_to_proof(&mut self, work_start: I) -> I
pub fn snapshot_to_proof(&mut self, work_start: I) -> I
Snapshot a spilled matrix into the proof pool (copy-on-first-recanon). Returns the start index in the proof pool.
The proof pool shares the working pool’s index word: both address the same
spilled matrices, one live and one archived, so a start index that fits I in
the working pool fits I here.
Sourcepub fn read_proof(&self, start: I) -> (u32, Vec<PoolDirector>)
pub fn read_proof(&self, start: I) -> (u32, Vec<PoolDirector>)
Read a spilled matrix from the proof pool.