Skip to main content

AdaptiveScheduler

Struct AdaptiveScheduler 

Source
pub struct AdaptiveScheduler { /* private fields */ }
Expand description

Adaptive GC scheduler.

Tracks allocation rates and collection history to decide when and what type of collection to perform. The scheduler is updated after each allocation (via record_allocation) and after each collection (via record_young_gc / record_old_gc).

Implementations§

Source§

impl AdaptiveScheduler

Source

pub fn new() -> Self

Create a new scheduler with default thresholds.

Source

pub fn with_config( young_utilization_threshold: f64, headroom_factor: f64, ) -> Self

Create a scheduler with custom thresholds.

Source

pub fn should_collect(&self, metrics: &HeapMetrics) -> CollectionType

Determine what collection should happen based on current heap metrics.

Source

pub fn record_young_gc(&mut self, pause_duration: Duration)

Record that a young GC happened. Resets the per-young-cycle counters.

Source

pub fn record_old_gc(&mut self, pause_duration: Duration)

Record that an old GC happened.

Source

pub fn record_full_gc(&mut self, pause_duration: Duration)

Record a full GC (resets both generation counters).

Source

pub fn record_allocation(&mut self, bytes: usize)

Record an allocation of bytes bytes.

Source

pub fn young_gc_count(&self) -> u32

Number of young GCs recorded by this scheduler.

Source

pub fn old_gc_count(&self) -> u32

Number of old GCs recorded by this scheduler.

Source

pub fn young_alloc_bytes(&self) -> usize

Total bytes allocated since last young GC.

Source

pub fn total_alloc_bytes(&self) -> u64

Total bytes allocated since scheduler creation.

Source

pub fn young_utilization_threshold(&self) -> f64

Young-gen utilization threshold.

Source

pub fn headroom_factor(&self) -> f64

Headroom factor for old-gen prediction.

Source

pub fn young_pause_avg(&self) -> Duration

Average young GC pause duration (EMA).

Source

pub fn old_pause_avg(&self) -> Duration

Average old GC pause duration (EMA).

Source

pub fn allocation_rate(&self) -> f64

Current allocation rate (bytes/sec) since the last old GC. Returns 0.0 if no time has elapsed.

Trait Implementations§

Source§

impl Default for AdaptiveScheduler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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