Skip to main content

ChunkPolicy

Struct ChunkPolicy 

Source
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: Duration

Target 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: u32

Floor for a rate-sized chunk: a zero, tiny or non-finite rate must not collapse the chunk to something overhead dominates.

§max_samples: u32

Ceiling for any chunk (DEFAULT_MAX_CHUNK_SAMPLES for remote workers).

§calibration_samples: u32

Size of an uncalibrated lane’s first chunk (see the module doc).

Implementations§

Source§

impl ChunkPolicy

Source

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.

Source

pub const INTERACTIVE: Self

Interactive (live-view) requests: about 1.5 s per chunk so progress arrives often, single-sample floor and calibration.

Source

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.

Source

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.

Source

pub fn first_chunk_samples(&self) -> u32

The first chunk of an uncalibrated lane, clamped to [1, max_samples].

Source

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

Trait Implementations§

Source§

impl Clone for ChunkPolicy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ChunkPolicy

Source§

impl Debug for ChunkPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ChunkPolicy

Source§

impl PartialEq for ChunkPolicy

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ChunkPolicy

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more