pyphi.parallel.sampling#

Cost-sampling chunksize calculation for the Scheduler Protocol.

Samples up to four items spread across the iterable (positions 0, N/4, N/2, 3N/4 for known-length sequences; first four for unknown-length generators), times them inline, and computes a target chunksize that aims for roughly target_seconds of wall time per chunk. The sampled results are returned with their positions so callers can reuse them instead of computing the sampled items a second time.

Functions

compute_chunksize(items, *[, ...])

Return (chunksize, items_iterator, sampled) for a workload.

plan_workload(fn, items, more_items, *, ...)

Cost-sample a known-length workload and fold the results into a plan.

Classes

WorkloadPlan(chunksize, ...)

A cost-sampled workload, ready for chunked dispatch.