pub struct AdaptiveController { /* private fields */ }Expand description
The adaptive control brain.
PURE and deterministic: it never calls std::time::Instant::now or the
snapdir_core::resources samplers. All time and metrics are injected via
tick; per-op feedback via
record_op. Given the same inputs it always
produces the same Decisions.
Implementations§
Source§impl AdaptiveController
impl AdaptiveController
Sourcepub fn new(policy: AdaptivePolicy) -> Self
pub fn new(policy: AdaptivePolicy) -> Self
Builds a controller from a policy. The limit starts at 2 (slow-start
seed), clamped to the policy ceiling.
Sourcepub fn current_limit(&self) -> usize
pub fn current_limit(&self) -> usize
The current concurrency limit (clamped to [1, ceiling]).
Sourcepub fn record_op(&mut self, sample: OpSample)
pub fn record_op(&mut self, sample: OpSample)
Records one completed (or failed) operation, updating the running EWMAs
and the congestion marker. Call between ticks; the accumulated samples
are folded into the goodput/rtt estimates at the next
tick.
Sourcepub fn tick(
&mut self,
now: MonoTime,
cpu_pct: Option<f64>,
_rss: Option<u64>,
p95_obj_size: u64,
) -> Decision
pub fn tick( &mut self, now: MonoTime, cpu_pct: Option<f64>, _rss: Option<u64>, p95_obj_size: u64, ) -> Decision
Applies the control law for one interval and returns the next
Decision. now is the injected monotonic time, cpu_pct/rss are
best-effort system samples (None ⇒ unknown ⇒ that guardrail is
skipped), and p95_obj_size is the recent 95th-percentile object size
used by the memory-budget guardrail.
The controller never reads a real clock or sampler; all of these are supplied by the (later) wiring gate.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AdaptiveController
impl RefUnwindSafe for AdaptiveController
impl Send for AdaptiveController
impl Sync for AdaptiveController
impl Unpin for AdaptiveController
impl UnsafeUnpin for AdaptiveController
impl UnwindSafe for AdaptiveController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request