Skip to main content

Work

Struct Work 

Source
pub struct Work {
    pub busy_nanos: u64,
    pub items: u64,
}
Expand description

Cumulative work done by one stage.

§Busy time, never wall time

busy_nanos must be time a worker spent doing the work, with blocking excluded — a consumer must not count time waiting for input, a producer must not count time blocked on a full output queue or on the source.

This is the single most important contract in the crate, and the whole control law rests on it. Wall time contains blocking, and blocking is a function of the split being controlled, so a controller built on wall time feeds its own actuation back into its measurement. That endogeneity is what makes utilisation-style signals degenerate — see ProducerPressure.

Busy time has the opposite property: over a window in which the pipeline moved X items, the two stages spent X * s_producer and X * s_consumer thread-nanoseconds respectively, so their ratio is the ratio of per-item costs regardless of how many threads either side had. That is the quantity the split is solved from, and it is why no shared unit of work is needed: the X cancels.

§Items are a progress measure, not a shared currency

items is used only to compare throughput at one split against throughput at another — for ratifying a move and for noticing a regime change. It need only be consistent over time within a stage. The two stages may count entirely different things (records here, decompressed bytes there) without affecting the split, because the split never divides one by the other.

Fields§

§busy_nanos: u64

Nanoseconds of real work, summed over this stage’s workers.

§items: u64

Progress in whatever unit is natural for this stage.

Trait Implementations§

Source§

impl Clone for Work

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 Work

Source§

impl Debug for Work

Source§

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

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

impl Default for Work

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Work

Source§

impl PartialEq for Work

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 Work

Auto Trait Implementations§

§

impl Freeze for Work

§

impl RefUnwindSafe for Work

§

impl Send for Work

§

impl Sync for Work

§

impl Unpin for Work

§

impl UnsafeUnpin for Work

§

impl UnwindSafe for Work

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