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.