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
impl Admission
pub fn new(min_gain_frac: f64, max_conns: usize) -> Self
Sourcepub fn observe_at(&mut self, level: usize, goodput: f64) -> Admit
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.
Sourcepub fn clamp_max(&mut self, max: usize)
pub fn clamp_max(&mut self, max: usize)
Lower the ceiling the search may reach.
Raising it is deliberately not possible: the caller lowers this when the ORIGIN has refused a request, and a ceiling learned from a refusal must not be undone by the search that provoked it. Recovery from a momentary limit is the transfer loop’s business, not the controller’s.
Sourcepub fn observe(&mut self, goodput: f64) -> Admit
pub fn observe(&mut self, goodput: f64) -> Admit
Back-compatible entry point for callers that admit one connection at a time.
Sourcepub fn best_goodput(&self) -> f64
pub fn best_goodput(&self) -> f64
Best goodput seen, for reporting.