Appearance
cellpack::loader::LoaderConfig
Module contract · All interfaces
At a glance
pub struct LoaderConfig {
pub workers: usize,
pub backend: IoBackend,
pub max_inflight_per_worker: usize,
pub claim_batch: usize,
pub slot_cells: u64,
pub window: Option<u64>,
pub profile: Option<SiteMask>,
pub cpus: Vec<usize>,
}How a loader’s runs execute: threads, I/O backend, windowing and profiling.
The window and the in-flight depth bound how far a worker may run ahead of the oldest unfinished access; both matter to plans, which reserve frames a whole reuse gap ahead.
For small portable examples use Pread, a few workers, and tiny slots. Defaults target a different workload and should not be read as tuning advice.
Try it
FIXED EXAMPLE RUST / CPU
Deliver ordered batches
Two output schemas share each requested position. Missing dimensions use the schema default; present sparse zeros stay zero.
mod common;
use std::error::Error;
use std::sync::Arc;
use cellpack::loader::{
DataSourceBuilder, Dtype, IoBackend, Loader, LoaderConfig,
OutputSchema, Planning, Replicate, Ring,
};
fn main() -> Result<(), Box<dyn Error>> {
let mut builder = DataSourceBuilder::new(5, 4096)?.direct_io(false);
builder.add_cpk(common::fixture()?, &[0, 1, 2, 3])?;
let source = Arc::new(builder.build()?);
let schemas = vec![
OutputSchema::dense(1, vec![3, 1, 4], Dtype::F32)?.with_default(f64::NAN),
OutputSchema::dense(2, vec![0, 2], Dtype::F64)?,
];
let loader = Loader::new(source, schemas, LoaderConfig {
workers: 2, backend: IoBackend::Pread, slot_cells: 2,
..LoaderConfig::default()
})?;
let cells = [3u32, 0, 2, 3, 1];
let accesses = Replicate::new(cells, 2)?;
let ring = Arc::new(Ring::allocate(loader.ring_layout(2, 1))?);
let run = loader.prepare(&accesses, ring, Planning::None)?;
let stats = run.for_each_batch(|batch| {
let panel: Vec<f32> = batch.region(0).chunks_exact(4)
.map(|v| f32::from_ne_bytes(v.try_into().unwrap())).collect();
println!("positions {}..{}: panel {panel:?}",
batch.first_position(), batch.first_position() + batch.rows() as u64);
Ok(())
})?;
println!("delivered: {} positions, {} accesses", cells.len(), stats.counters.accesses);
Ok(())
}
positions 0..2: panel [0.0, 8.0, NaN, 1.0, 2.0, NaN]
positions 2..4: panel [6.0, 0.0, NaN, 0.0, 8.0, NaN]
positions 4..5: panel [0.0, 0.0, NaN]
delivered: 5 positions, 10 accessesFields and variants
workers
workers: usizeLoader worker threads; the default is 16.
backend
backend: IoBackendHow reads are issued (default Uring); Uring registers the input files with the ring when the kernel permits and otherwise passes a descriptor with each read.
max_inflight_per_worker
max_inflight_per_worker: usizePositions a worker keeps in flight, reading, waiting or decoding; default 64.
claim_batch
claim_batch: usizeAccesses per claim (default 8), rounded up to whole positions; bounded by one slot’s accesses and, at execution, by the in-flight depth.
slot_cells
slot_cells: u64Positions per output slot (default 256); every schema of a position shares it.
window
The execution window, in slots: a claim starts at most this far past the oldest unfinished access. It must not exceed a plan’s reuse gap; unset, it is the plan’s gap, or enough slots for the in-flight accesses without a plan.
profile
Profiled sites (crate::prof); none runs the untimed instance.
cpus
Pins worker i to cpus[i % len]; empty leaves placement to the OS.
Implemented traits
impl Clone for LoaderConfigimpl Debug for LoaderConfigimpl Default for LoaderConfigContract reference
See the module reference for semantic input/output rules, units, allocation, mutation, failure behavior, and lifetime requirements. Declarations and documented members are synchronized from the crate source.