Skip to main content

TierManager

Struct TierManager 

Source
pub struct TierManager<const MAX_REGIONS: usize> { /* private fields */ }
Expand description

Manages tier placement for a fixed set of memory regions.

MAX_REGIONS is the compile-time upper bound on tracked regions. This avoids heap allocation and is suitable for no_std environments.

Implementations§

Source§

impl<const MAX_REGIONS: usize> TierManager<MAX_REGIONS>

Source

pub const fn new() -> Self

Create a new TierManager with default DC-1 thresholds.

Source

pub const fn with_thresholds(thresholds: TierThresholds) -> Self

Create a new TierManager with custom thresholds.

Source

pub const fn count(&self) -> usize

Return the number of tracked regions.

Source

pub const fn current_epoch(&self) -> u32

Return the current epoch.

Source

pub fn advance_epoch(&mut self)

Advance the epoch counter. Call this once per scheduler epoch.

Source

pub fn register( &mut self, region_id: OwnedRegionId, initial_tier: Tier, ) -> RvmResult<()>

Register a new region in the tier manager at the given initial tier.

§Errors

Returns RvmError::ResourceLimitExceeded if the manager is at capacity. Returns RvmError::MemoryOverlap if the region is already registered.

Source

pub fn unregister(&mut self, region_id: OwnedRegionId) -> RvmResult<()>

Unregister a region from the tier manager.

§Errors

Returns RvmError::PartitionNotFound if the region is not tracked.

Source

pub fn record_access(&mut self, region_id: OwnedRegionId) -> RvmResult<()>

Record an access to the given region, updating its recency score.

§Errors

Returns RvmError::PartitionNotFound if the region is not tracked.

Source

pub fn update_cut_value( &mut self, region_id: OwnedRegionId, cut_value: u16, ) -> RvmResult<()>

Update the cut value for a region (from the coherence engine).

§Errors

Returns RvmError::PartitionNotFound if the region is not tracked.

Source

pub fn promote( &mut self, region_id: OwnedRegionId, target_tier: Tier, ) -> RvmResult<Tier>

Promote a region to a higher (lower-numbered) tier.

Returns the previous tier on success.

§Errors

Returns RvmError::PartitionNotFound if the region is not tracked. Returns RvmError::InvalidTierTransition if the target tier is not higher than the current tier, or if promoting from Cold. Returns RvmError::CoherenceBelowThreshold if the residency score does not meet the promotion threshold.

Source

pub fn demote( &mut self, region_id: OwnedRegionId, target_tier: Tier, ) -> RvmResult<Tier>

Demote a region to a lower (higher-numbered) tier.

Returns the previous tier on success.

§Errors

Returns RvmError::PartitionNotFound if the region is not tracked. Returns RvmError::InvalidTierTransition if the target tier is not lower than the current tier.

Source

pub fn get(&self, region_id: OwnedRegionId) -> Option<&RegionTierState>

Return the current tier state for a region, if tracked.

Source

pub fn decay_recency(&mut self, decay_amount: u16)

Decay recency scores for all tracked regions by the given amount (in basis points). Call this once per epoch to age out stale regions.

Source

pub fn find_demotion_candidates( &self, out: &mut [(OwnedRegionId, Tier)], ) -> usize

Identify regions that should be demoted based on current thresholds.

Returns (region_id, recommended_target_tier) pairs. Caller is responsible for acting on recommendations (e.g., triggering compression for Dormant demotion).

out is a caller-provided buffer; returns the number of entries written.

Trait Implementations§

Source§

impl<const MAX_REGIONS: usize> Default for TierManager<MAX_REGIONS>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<const MAX_REGIONS: usize> Freeze for TierManager<MAX_REGIONS>

§

impl<const MAX_REGIONS: usize> RefUnwindSafe for TierManager<MAX_REGIONS>

§

impl<const MAX_REGIONS: usize> Send for TierManager<MAX_REGIONS>

§

impl<const MAX_REGIONS: usize> Sync for TierManager<MAX_REGIONS>

§

impl<const MAX_REGIONS: usize> Unpin for TierManager<MAX_REGIONS>

§

impl<const MAX_REGIONS: usize> UnsafeUnpin for TierManager<MAX_REGIONS>

§

impl<const MAX_REGIONS: usize> UnwindSafe for TierManager<MAX_REGIONS>

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.