Skip to main content

Admission

Struct Admission 

Source
pub struct Admission { /* private fields */ }
Expand description

Per-source incremental admission controller.

Feed it the aggregate goodput observed at each concurrency level. It compares the marginal gain against min_gain_frac of the goodput achieved by the first connection — a scale-free threshold, so it behaves identically on a 1 MB/s and a 1 GB/s path.

Implementations§

Source§

impl Admission

Source

pub fn new(min_gain_frac: f64, max_conns: usize) -> Self

Source

pub fn observe_at(&mut self, level: usize, goodput: f64) -> Admit

Record the aggregate goodput (bytes/s) observed with self.level() + 1 connections, and decide whether to admit another. Record the goodput measured while level connections were active.

§Why the level is a parameter and not the sample count

This originally inferred the level from samples.len(), which is correct only if callers admit one connection per observation. The in-band ramp doubles (1, 2, 4, 8) because incrementing takes max - 1 windows and costs more clock than the concurrency saves. Under doubling the third sample describes FOUR connections, so returning samples.len() - 1 returned a sample index dressed as a connection count.

HISTORICAL MEASUREMENT (pre-fix implementation; retained to document why this design exists, not as a current result). 11 MB object, five repetitions: settled counts came back [2, 8, 8, 8, 8] on a path a single stream already saturates. The 2 is the index bug reporting sample 3 as “2”; the four 8s are the ceiling arm firing because the sample-count test n >= max_conns needs eight samples and doubling only ever takes four. The search could not settle anywhere sensible, and the mode was no faster than hard-coding the ceiling (0.99x, p = 0.63) while a single connection was 1.97x faster than both.

Source

pub fn observe(&mut self, goodput: f64) -> Admit

Back-compatible entry point for callers that admit one connection at a time.

Source

pub fn level(&self) -> usize

Connections currently probed.

Source

pub fn settled(&self) -> Option<usize>

The settled allocation, once probing has stopped.

Source

pub fn best_goodput(&self) -> f64

Best goodput seen, for reporting.

Trait Implementations§

Source§

impl Clone for Admission

Source§

fn clone(&self) -> Admission

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 Debug for Admission

Source§

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

Formats the value using the given formatter. Read more

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, 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.