pub struct RealTimeOptimizer { /* private fields */ }Expand description
Real-time performance optimizer.
Drives a single discrete knob — RTOptimizationState::optimization_level
— from measured latency behaviour: it escalates while the observed
deadline-miss rate is too high, relaxes while there is ample headroom, and
reports the improvement it can actually attribute to its last move by
comparing the current measured average against the average recorded at the
moment that move was made.
Implementations§
Source§impl RealTimeOptimizer
impl RealTimeOptimizer
pub fn new(config: RealTimeConfig) -> Result<Self>
Sourcepub fn observe_latency(&mut self, latency: Duration)
pub fn observe_latency(&mut self, latency: Duration)
Record one real end-to-end processing latency.
This is what turns the optimizer from a constructed-and-forgotten
object into a controller: without observations it has nothing to
optimize, and Self::optimize_realtime honestly reports “nothing
applied, nothing measured”.
Sourcepub fn observe_utilization(
&mut self,
cpu_utilization: f64,
memory_pressure: f64,
)
pub fn observe_utilization( &mut self, cpu_utilization: f64, memory_pressure: f64, )
Record the real resource utilisation observed by the caller.
Sourcepub fn performance_metrics(&self) -> &RealTimeMetrics
pub fn performance_metrics(&self) -> &RealTimeMetrics
Measured real-time metrics.
Sourcepub fn optimization_state(&self) -> &RTOptimizationState
pub fn optimization_state(&self) -> &RTOptimizationState
Current optimization state.
Sourcepub fn observation_count(&self) -> usize
pub fn observation_count(&self) -> usize
Number of latency observations recorded so far.
Sourcepub fn optimize_realtime(
&mut self,
latency_budget: Duration,
) -> Result<RTOptimizationResult>
pub fn optimize_realtime( &mut self, latency_budget: Duration, ) -> Result<RTOptimizationResult>
Re-evaluate the real-time optimization level against latency_budget.
The returned figures are measurements, not estimates:
optimization_appliedis true only when this call actually changed the optimization level.performance_gainisbaseline_avg / current_avg, where the baseline is the measured average at the moment the current level was entered — exactly 1.0 while nothing has been changed yet.latency_reduction_msis the corresponding measured difference, and is negative if the last change made things worse.
Auto Trait Implementations§
impl Freeze for RealTimeOptimizer
impl RefUnwindSafe for RealTimeOptimizer
impl Send for RealTimeOptimizer
impl Sync for RealTimeOptimizer
impl Unpin for RealTimeOptimizer
impl UnsafeUnpin for RealTimeOptimizer
impl UnwindSafe for RealTimeOptimizer
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> 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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.