Skip to main content

LimitBand

Struct LimitBand 

Source
pub struct LimitBand {
    pub min: usize,
    pub max: usize,
}
Expand description

The range the governed limit is clamped to.

Spelled as a type rather than two constants because it has to be narrowed by an operator’s configured ceiling: a server told --max-concurrent-transfers 4 must serve 4, not the design’s floor of 10. See LimitBand::for_ceiling.

Fields§

§min: usize

The smallest the controller may shrink to.

§max: usize

The largest it may grow to, and where it starts.

Implementations§

Source§

impl LimitBand

Source

pub const DEFAULT: LimitBand

The design’s band: [10, 100].

Source

pub fn for_ceiling(ceiling: usize) -> LimitBand

The band for a server whose operator pinned a hard ceiling.

The operator’s number is the ceiling, and the FLOOR is clamped under it: pinning 4 gives [4, 4], a governor that cannot move, which is exactly what “I told you 4” should mean. A configured ceiling below MIN_LIMIT must not be silently RAISED — a gate admitting more than it was told to is the one failure mode a limit may not have.

The ceiling is NOT capped at MAX_LIMIT, and that was a bug. The first form did MAX_LIMIT.min(ceiling), so a server configured with the shipped default of 256 got a band of [10, 100] and quietly served 100. Lowering an operator’s explicit number is the same defect as raising it, in the other direction: both mean the configured value is not the value. MAX_LIMIT is the design’s default for a server that has NOT been told a number — it is not an opinion that outranks one that has.

Source

pub fn for_budget(budget: usize) -> LimitBand

The band for a server whose ceiling is a declared, measured budget rather than a round number an operator typed.

§Why the floor moves with the ceiling — MEASURED

LimitBand::for_ceiling pins the floor at MIN_LIMIT = 10. With the shipped ceiling of 256 that is a band of [10, 256], and the controller walks the whole of it: multiplicative decrease is limit -= limit/8, so 256 → 224 → 196 → … → 24 → 21 → 19 → 17 … On the appliance under a 64-client push storm every 100 ms window stands, and the measurement took the gate refusing by name at exactly that — already serving its limit of 19, 268 of 1000 push-creates admitted. 19 was not a constant anybody chose; it is a point on a descent.

The descent does not stop because shedding does not fix what the controller is measuring. The sojourn it reads was the gap between admission and the spawned task’s first line — the tokio ready queue and the blocking-pool handoff — and that gap is set by how many clients are connected and doing crypto, not by how many transfers are admitted. A refused client reconnects, so a refusal makes the input worse. A controller with no authority over its own input runs to its floor.

Both halves are fixed here. The controller’s input is now the admission wait — the queue this gate actually owns (DEFAULT_ADMISSION_WAIT) — and its floor is a share of the budget rather than a constant: below BUDGET_FLOOR_DENOMINATOR⁻¹ of a number derived from cores, descriptors and MemAvailable, the box is provably not the bottleneck and refusing costs more than serving.

Trait Implementations§

Source§

impl Clone for LimitBand

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 LimitBand

Source§

impl Debug for LimitBand

Source§

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

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

impl Eq for LimitBand

Source§

impl PartialEq for LimitBand

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 LimitBand

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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