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
impl AdaptiveScheduler
Sourcepub fn with_config(
young_utilization_threshold: f64,
headroom_factor: f64,
) -> Self
pub fn with_config( young_utilization_threshold: f64, headroom_factor: f64, ) -> Self
Create a scheduler with custom thresholds.
Sourcepub fn should_collect(&self, metrics: &HeapMetrics) -> CollectionType
pub fn should_collect(&self, metrics: &HeapMetrics) -> CollectionType
Determine what collection should happen based on current heap metrics.
Sourcepub fn record_young_gc(&mut self, pause_duration: Duration)
pub fn record_young_gc(&mut self, pause_duration: Duration)
Record that a young GC happened. Resets the per-young-cycle counters.
Sourcepub fn record_old_gc(&mut self, pause_duration: Duration)
pub fn record_old_gc(&mut self, pause_duration: Duration)
Record that an old GC happened.
Sourcepub fn record_full_gc(&mut self, pause_duration: Duration)
pub fn record_full_gc(&mut self, pause_duration: Duration)
Record a full GC (resets both generation counters).
Sourcepub fn record_allocation(&mut self, bytes: usize)
pub fn record_allocation(&mut self, bytes: usize)
Record an allocation of bytes bytes.
Sourcepub fn young_gc_count(&self) -> u32
pub fn young_gc_count(&self) -> u32
Number of young GCs recorded by this scheduler.
Sourcepub fn old_gc_count(&self) -> u32
pub fn old_gc_count(&self) -> u32
Number of old GCs recorded by this scheduler.
Sourcepub fn young_alloc_bytes(&self) -> usize
pub fn young_alloc_bytes(&self) -> usize
Total bytes allocated since last young GC.
Sourcepub fn total_alloc_bytes(&self) -> u64
pub fn total_alloc_bytes(&self) -> u64
Total bytes allocated since scheduler creation.
Sourcepub fn young_utilization_threshold(&self) -> f64
pub fn young_utilization_threshold(&self) -> f64
Young-gen utilization threshold.
Sourcepub fn headroom_factor(&self) -> f64
pub fn headroom_factor(&self) -> f64
Headroom factor for old-gen prediction.
Sourcepub fn young_pause_avg(&self) -> Duration
pub fn young_pause_avg(&self) -> Duration
Average young GC pause duration (EMA).
Sourcepub fn old_pause_avg(&self) -> Duration
pub fn old_pause_avg(&self) -> Duration
Average old GC pause duration (EMA).
Sourcepub fn allocation_rate(&self) -> f64
pub fn allocation_rate(&self) -> f64
Current allocation rate (bytes/sec) since the last old GC. Returns 0.0 if no time has elapsed.