pub struct Governor { /* private fields */ }Expand description
PSI-based system stress governor with background monitoring thread.
Implementations§
Source§impl Governor
impl Governor
Sourcepub fn new(
max_load: f64,
hydration_delay_ms: u64,
psi_io_limit: f64,
psi_cpu_limit: f64,
) -> Self
pub fn new( max_load: f64, hydration_delay_ms: u64, psi_io_limit: f64, psi_cpu_limit: f64, ) -> Self
Create a new governor with the given stress thresholds.
Sourcepub fn current_stress_score(&self) -> f64
pub fn current_stress_score(&self) -> f64
Lock-free stress score read with failure-rate boost. Called ~320 times/second across all workers – must be contention-free.
Sourcepub fn is_system_stressed(&self) -> bool
pub fn is_system_stressed(&self) -> bool
Return true if the system is under enough stress to throttle.
Sourcepub fn current_memory_usage_pct(&self) -> f64
pub fn current_memory_usage_pct(&self) -> f64
Lock-free memory usage read.
Sourcepub fn pace_hydration(&self)
pub fn pace_hydration(&self)
Sleep proportionally to system stress before hydration work.
Sourcepub async fn pace_hydration_async(&self)
pub async fn pace_hydration_async(&self)
Async variant of [pace_hydration] for callers running on the tokio executor.
Uses tokio::time::sleep instead of std::thread::sleep to avoid blocking
a tokio worker thread. Use this from async fn contexts (e.g., process_hydration_job).
For sync callers on dedicated std::threads (e.g., full_scan, execute_frontier_scan),
use the sync [pace_hydration] instead.
Auto Trait Implementations§
impl !Freeze for Governor
impl RefUnwindSafe for Governor
impl Send for Governor
impl Sync for Governor
impl Unpin for Governor
impl UnsafeUnpin for Governor
impl UnwindSafe for Governor
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more