Skip to main content

ProducerPressure

Enum ProducerPressure 

Source
pub enum ProducerPressure {
    Starved,
    Satisfied,
    SourceBound,
    Inelastic,
}
Expand description

Whether more producer concurrency would buy anything.

§This guards direction; it does not size the split

Self::SourceBound and Self::Inelastic may cap how far the producer grows. Self::Starved has one bounded exception: it may retain the current limit when the cost model asks to shrink a producer that is demonstrably using its present capacity. It cannot choose or increase the target, so the cost-share model remains the only sizing mechanism. Self::Satisfied is diagnostic. This one-sided restriction is deliberate and hard-won.

Every variant here is a saturating signal, and an earlier version of this crate sized the split from one. It does not work, and the reason is structural rather than a matter of tuning.

Let starve(d) be the fraction of consumer time blocked on an empty buffer. It falls as d rises and reaches zero at the balance point — and then stays zero for every larger d. So {d : starve(d) = 0} is a half-line, not a point, and a controller driving starve -> 0 has no restoring force anywhere on it. Any bias walks it to the boundary while the error stays genuinely near zero the whole way. Measured: it ran to 47 producer / 17 consumer where 32/32 was optimal, 44% slower, “converging” throughout.

DS2 (Kalavri et al., OSDI’18, section 2) classifies exactly that controller – threshold policies over utilisation, queue depth or observed rates – and gives the consequence as “incorrect provisioning, oscillations, and long convergence times”.

Variants§

§

Starved

Work is queued behind the limit: more slots would be used.

This variant carried a wanted count while the split was grown one decision at a time. Nothing reads it now — the split is solved, not stepped — and a demand estimate is a poor thing to keep alive with no consumer to keep it honest.

May veto removal of an occupied current slot when allocation-dependent producer work makes the low-allocation cost estimate incomplete. The controller counts that event and requires persistent evidence; this variant never requests growth.

§

Satisfied

Keeping up with the consumer. More slots would idle.

§

SourceBound

Idle, but not because of the limit — the source is the constraint.

Distinct from Self::Satisfied because the consumer may simultaneously be starving, and that combination is the one case where a starved consumer must not cause the producer to grow: the threads would sit waiting on storage. Without this variant a broker spends its whole budget on decode for an I/O-bound run and gains nothing.

§

Inelastic

Cannot use more concurrency at any price.

For a stream the decompressor can only process serially. Such an input reports total consumer starvation forever and can never be helped, so without this the broker would spend every thread chasing it.

Trait Implementations§

Source§

impl Clone for ProducerPressure

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 ProducerPressure

Source§

impl Debug for ProducerPressure

Source§

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

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

impl Eq for ProducerPressure

Source§

impl PartialEq for ProducerPressure

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 ProducerPressure

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