Skip to main content

Vegas

Struct Vegas 

Source
pub struct Vegas { /* private fields */ }
Available on crate feature adaptive only.
Expand description

Latency-based adaptation, after TCP Vegas.

From the round-trip time it estimates the queue depth at the downstream — limit * (rtt - min_rtt) / rtt, where min_rtt is the best (no-load) latency seen so far. A small estimated queue means there is headroom, so the limit grows; a large one means a queue is forming, so it shrinks. Failures halve the limit outright.

§Examples

use throttle_net::{AdaptiveLimiter, Vegas};

// Grow while the estimated queue is below 3, shrink above 6.
let limiter = AdaptiveLimiter::builder()
    .floor(2)
    .ceiling(100)
    .build(Vegas::new(3, 6));

Implementations§

Source§

impl Vegas

Source

pub fn new(alpha: u32, beta: u32) -> Self

Grow while the estimated queue is below alpha, shrink above beta. beta is raised to at least alpha to keep a stable band between them.

Trait Implementations§

Source§

impl AdaptiveStrategy for Vegas

Source§

fn adjust(&self, current: u32, _in_flight: u32, outcome: Outcome) -> u32

Returns the proposed new limit given the current limit, the in_flight count at the time of the observation (including the just-finished request), and the outcome.
Source§

impl Debug for Vegas

Source§

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

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

impl Default for Vegas

Source§

fn default() -> Self

Grow below an estimated queue of 3, shrink above 6.

Auto Trait Implementations§

§

impl !Freeze for Vegas

§

impl RefUnwindSafe for Vegas

§

impl Send for Vegas

§

impl Sync for Vegas

§

impl Unpin for Vegas

§

impl UnsafeUnpin for Vegas

§

impl UnwindSafe for Vegas

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<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> 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, 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.
Source§

impl<E> WithErrorCode<E> for E

Source§

fn with_code(self, code: impl Into<String>) -> CodedError<E>

Attach an error code to an error
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