Skip to main content

ResourceMonitor

Struct ResourceMonitor 

Source
pub struct ResourceMonitor<T: Float + Debug + Send + Sync + 'static> { /* private fields */ }
Expand description

Resource monitor for tracking and managing system resources

Implementations§

Source§

impl<T> ResourceMonitor<T>
where T: From<f64> + Display + Float + Debug + Send + Sync + 'static,

Source

pub fn new(constraints: ResourceConstraints<T>) -> Self

Create a new resource monitor

Source

pub fn start_monitoring(&mut self) -> Result<()>

Start resource monitoring

Source

pub fn stop_monitoring(&mut self) -> Result<()>

Stop resource monitoring

Source

pub fn update_usage(&self) -> Result<()>

Sample every tracker and record a snapshot (F12).

This is called once per generation from NeuralArchitectureSearch::check_resource_constraints; before that wiring it was never called at all, so current_usage stayed at ResourceUsage::default() forever and check_resource_violations could never fire.

The snapshot’s derived fields are all measured or absent: active_processes, memory_pressure, cpu_load_average and gpu_utilization used to be hard-coded to 1 / Low / 0.6 / 0.8.

The clock is read once and reused for the timestamp and the retention cutoff, so a snapshot cannot be pruned by an Instant::now() taken microseconds later.

Source

pub fn check_violations(&self) -> Result<Vec<ResourceViolation<T>>>

Check for resource violations

Source

pub fn optimize_resources(&self) -> Result<Vec<OptimizationAction<T>>>

Optimize resource usage

Source

pub fn get_current_usage(&self) -> ResourceUsage<T>

Get current resource usage.

Recovers from a poisoned mutex instead of panicking (F22): the guarded data is a plain snapshot with no invariants that a panicking writer could have broken, so one panic elsewhere must not make this getter panic forever.

Source

pub fn get_usage_history(&self) -> Vec<ResourceSnapshot<T>>

Get usage history. Poison-recovering, for the same reason as ResourceMonitor::get_current_usage.

Source

pub fn get_monitoring_state(&self) -> MonitoringState

Get monitoring state

Source

pub fn set_trackers(&mut self, monitors: Vec<Box<dyn ResourceTracker<T>>>)

Replace the resource trackers. This is the injection point for real telemetry: hand in a SystemResourceTracker::with_telemetry built over a source that can measure what the default cannot (F12).

Source

pub fn set_alert_handlers(&mut self, handlers: Vec<Box<dyn AlertHandler<T>>>)

Replace the alert handlers.

Source

pub fn set_optimization_strategies( &mut self, strategies: Vec<Box<dyn ResourceOptimizer<T>>>, )

Replace the optimization strategies.

Source

pub fn telemetry_source_names(&self) -> Vec<&str>

Names of the telemetry sources currently backing this monitor.

Source

pub fn update_constraints(&mut self, constraints: ResourceConstraints<T>)

Update constraints

Source

pub fn generate_report(&self) -> ResourceReport<T>

Generate resource report

Source

pub fn check_resource_violations(&self) -> Result<Vec<ResourceViolation<T>>>

Check for resource constraint violations

Source

pub fn get_usage_summary(&self) -> ResourceUsageSummary<T>

Get a summary of resource usage

Trait Implementations§

Source§

impl<T: Float + Debug + Send + Sync + 'static> Debug for ResourceMonitor<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ResourceMonitor<T>

§

impl<T> !UnwindSafe for ResourceMonitor<T>

§

impl<T> Freeze for ResourceMonitor<T>

§

impl<T> Send for ResourceMonitor<T>

§

impl<T> Sync for ResourceMonitor<T>

§

impl<T> Unpin for ResourceMonitor<T>

§

impl<T> UnsafeUnpin for ResourceMonitor<T>

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V