Skip to main content

EngagementPolicy

Struct EngagementPolicy 

Source
pub struct EngagementPolicy {
    pub min_threads_per_stream: usize,
}
Expand description

Whether engaging a parallel producer can pay for the threads it takes.

§The economics this encodes

A consumer that decodes its own input inline — each worker inflating under its own stream’s lock, then processing what it produced — is work-conserving: it is never idle, because a thread with less decode work simply does more consuming, rebalancing at batch granularity with no coordination. It gives streams concurrent decoders for free, where streams is the number of independent input streams.

A parallel producer gives d decoders but takes d threads away from consuming, and those threads can only decode. So it pays exactly when d > streams — when it can supply more concurrency than the consumer already gets for nothing.

§Why a threshold rather than that rule

d is what the broker converges to, so it is unknown when the decision has to be made. This is the budget-side proxy: with budget threads and streams inputs, the producer can only plausibly exceed streams decoders if the budget is several times the stream count.

§Provenance of the default

Measured on a single-cell Flex library (150 bp pairs, human index) and a bulk SE library (gencode), sweeping budget over {8, 32, 64} and streams over {1..16} — 16 cells. Inline decoding won every cell where d <= streams by 8–28%, and the parallel producer won every cell where d > streams by up to 4.2x. budget >= 8 * streams reproduces all 16 verdicts except one boundary cell that costs ~8%.

The default is calibrated on the most decode-bound workload available, so it errs toward inline decoding for anything less decode-heavy — the direction that protects a consumer-bound baseline. The asymmetry is deliberate: missing a parallel win costs up to 4.2x, taking one wrongly costs ~25%, but the wrongly-taken case is the one a user notices as a regression against not having the feature at all.

Override it when your workload’s decode-to-consume ratio is known to differ.

Fields§

§min_threads_per_stream: usize

Budget threads required per independent input stream before a parallel producer is engaged at all.

0 always engages; a very large value never does.

Implementations§

Source§

impl EngagementPolicy

Source

pub const fn engages(&self, budget: usize, streams: usize) -> bool

Engage a parallel producer for streams inputs under budget threads?

streams == 0 never engages: there is nothing for a parallel producer to do, so it could only cost threads.

Source

pub const fn always() -> Self

Always engage, leaving the decision entirely to the broker.

There is deliberately no never() counterpart. This type expresses a threshold, and no threshold declines every budget — usize::MAX still engages at a usize::MAX budget, so such a constructor would be a lie in exactly the case someone would reach for it to be safe. A caller that wants the producer off should not construct it at all; piscem exposes that as --decoder serial.

Trait Implementations§

Source§

impl Clone for EngagementPolicy

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 EngagementPolicy

Source§

impl Debug for EngagementPolicy

Source§

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

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

impl Default for EngagementPolicy

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for EngagementPolicy

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for EngagementPolicy

Source§

impl PartialEq for EngagementPolicy

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 Serialize for EngagementPolicy

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for EngagementPolicy

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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