Skip to content
API REFERENCEUsage guides →

cellpack::loader::LoaderConfig ​

struct

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(())
}
OUTPUTExpected result
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 accesses

Fields and variants ​

workers ​

workers: usize

Loader worker threads; the default is 16.

backend ​

backend: IoBackend

How 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: usize

Positions a worker keeps in flight, reading, waiting or decoding; default 64.

claim_batch ​

claim_batch: usize

Accesses 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: u64

Positions per output slot (default 256); every schema of a position shares it.

window ​

window: Option<u64>

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 ​

profile: Option<SiteMask>

Profiled sites (crate::prof); none runs the untimed instance.

cpus ​

cpus: Vec<usize>

Pins worker i to cpus[i % len]; empty leaves placement to the OS.

Implemented traits ​

Contract 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.

Definition