pub struct ChunkPolicy {
pub target: Duration,
pub min_samples: u32,
pub max_samples: u32,
pub calibration_samples: u32,
}Expand description
How chunks are sized for a crate::LanePool run.
Fields§
§target: DurationTarget wall-clock duration of one chunk. Long enough that per-request overhead (handshake, upload, the final transfer) is negligible against it; short enough that a slow lane never holds the tail of the image hostage while every other lane idles.
min_samples: u32Floor for a rate-sized chunk: a zero, tiny or non-finite rate must not collapse the chunk to something overhead dominates.
max_samples: u32Ceiling for any chunk (DEFAULT_MAX_CHUNK_SAMPLES for remote workers).
calibration_samples: u32Size of an uncalibrated lane’s first chunk (see the module doc).
Implementations§
Source§impl ChunkPolicy
impl ChunkPolicy
Sourcepub const EXPORT: Self
pub const EXPORT: Self
The still export and tilt video: about 22 s per chunk, a 32-sample floor (below that a remote round trip costs more than it saves), an 8-sample calibration probe – the desktop export’s existing numbers.
Sourcepub const INTERACTIVE: Self
pub const INTERACTIVE: Self
Interactive (live-view) requests: about 1.5 s per chunk so progress arrives often, single-sample floor and calibration.
Sourcepub const fn fixed(samples: u32) -> Self
pub const fn fixed(samples: u32) -> Self
Every chunk (calibration included) is exactly samples long, whatever the rate.
The chunk partition of a run is then independent of timing (see
crate::Merger’s determinism notes). 0 is treated as 1.
Sourcepub fn samples_for_rate(&self, rate: f64) -> u32
pub fn samples_for_rate(&self, rate: f64) -> u32
The chunk size for a lane measured at rate samples per second: rate * target, rounded, clamped to [min_samples, max_samples]; min_samples for a
non-finite or non-positive rate. Never 0.
Sourcepub fn first_chunk_samples(&self) -> u32
pub fn first_chunk_samples(&self) -> u32
The first chunk of an uncalibrated lane, clamped to [1, max_samples].
Sourcepub fn tail_aware_samples(
&self,
rate: f64,
remaining: u32,
sum_rates: f64,
) -> u32
pub fn tail_aware_samples( &self, rate: f64, remaining: u32, sum_rates: f64, ) -> u32
Tail-aware, share-aware chunk size for a lane measured at rate, given the
run’s whole outstanding sample count remaining (every lane, not just this one)
and sum_rates, the sum of every lane’s current rate (guess or estimate):
want = min(rate * target_secs, ceil(remaining * rate / sum_rates))clamped to [min_samples, max_samples] exactly like Self::samples_for_rate.
The first term is the plain target-duration chunk; the second is this lane’s
proportional share of what is left. Taking the smaller keeps ordinary chunk
sizing unchanged while samples are plentiful (the share term is then far
larger than the target term) and only shrinks the LAST few chunks of a run, so a
slow lane can no longer claim a disproportionate slice of a small tail and force
a fast lane sitting idle in [crate::pool::epoch::Epoch::claim] to wait out that
whole oversized chunk.
Falls back to plain Self::samples_for_rate when remaining is 0 or
sum_rates is non-finite/non-positive (a single lane’s sum_rates is its own
rate, so this only ever changes anything once remaining gets small relative
to that lane’s own target-duration chunk – exactly the run’s tail).