pub struct ParallelWriters { /* private fields */ }Expand description
Parallel, pipelined writer pool.
The producer (parser thread) stages per-table bytes and ships ~256KB chunks
over bounded channels to N writer threads, each owning a disjoint shard of
tables (sharded by name hash). This overlaps parsing with writing (a
pipeline / double-buffer) and keeps several writes in flight so a single
synchronous thread doesn’t bottleneck a fast SSD (queue depth > 1). Batching
into large chunks keeps per-statement channel overhead negligible.
Output is byte-identical to a single-threaded writer: each table’s
file is written by exactly one thread, in input order. A table’s shard is
assigned once (on first ship) and never changes, so growing the pool
mid-run (grow_to) preserves per-table ordering by
construction: already-seen tables keep their owner, only tables first seen
after the growth hash across the new shard count.
Implementations§
Source§impl ParallelWriters
impl ParallelWriters
Sourcepub fn new(
output_dir: PathBuf,
num_writers: usize,
capacity: usize,
format: Compression,
values: Arc<ProfileValues>,
) -> Result<Self>
pub fn new( output_dir: PathBuf, num_writers: usize, capacity: usize, format: Compression, values: Arc<ProfileValues>, ) -> Result<Self>
Spawn num_writers writer threads targeting output_dir, compressing
each per-table file with format. capacity is the per-shard channel
depth (chunks in flight); values carries the active profile’s
staging/buffer sizes and may be retuned mid-run by the controller.
Sourcepub fn writer_count(&self) -> usize
pub fn writer_count(&self) -> usize
Number of writer threads currently running.
Sourcepub fn grow_to(&mut self, n: usize)
pub fn grow_to(&mut self, n: usize)
Grow the pool to n writer threads (never shrinks — a table’s owner
thread must not change mid-run, see the type-level docs). Used by the
adaptive controller’s deferred writer spawn: auto mode opens at W=1
and only pays for parallelism once the device has proven fast.
Sourcepub fn stats(&self) -> WriterStats
pub fn stats(&self) -> WriterStats
Snapshot the pipeline’s instrumentation counters (monotonic since construction). Cheap enough to call at every epoch boundary.
Sourcepub fn errored(&self) -> bool
pub fn errored(&self) -> bool
True once any writer thread has hit an I/O error, so the producer can
stop early; the actual error surfaces from finish.
Auto Trait Implementations§
impl !RefUnwindSafe for ParallelWriters
impl !UnwindSafe for ParallelWriters
impl Freeze for ParallelWriters
impl Send for ParallelWriters
impl Sync for ParallelWriters
impl Unpin for ParallelWriters
impl UnsafeUnpin for ParallelWriters
Blanket Implementations§
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
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 more