Skip to main content

SharedTopologyMap

Struct SharedTopologyMap 

Source
pub struct SharedTopologyMap { /* private fields */ }

Implementations§

Source§

impl SharedTopologyMap

Source

pub fn create( path: impl AsRef<Path>, n_nodes: usize, ) -> Result<Self, TopologyError>

Source

pub fn create_with_thresholds( path: impl AsRef<Path>, n_nodes: usize, fan_out_threshold: u32, fan_in_threshold: u32, ) -> Result<Self, TopologyError>

Source

pub fn open( path: impl AsRef<Path>, expected_n_nodes: usize, ) -> Result<Self, TopologyError>

Source

pub fn n_nodes(&self) -> usize

Source

pub fn record_send(&self, src: u32, dst: u32) -> Result<u64, TopologyError>

Record one message from src to dst. Increments the edge counter and the total. Returns the new edge count.

Source

pub fn fan_out(&self, src: u32) -> u32

Fan-out for src: count of destinations with non-zero edge.

Source

pub fn fan_in(&self, dst: u32) -> u32

Fan-in for dst: count of sources with non-zero edge.

Source

pub fn max_fan_out(&self) -> (u32, u32)

Max fan-out across all sources, plus the source index.

Source

pub fn max_fan_in(&self) -> (u32, u32)

Max fan-in across all destinations, plus the dst index.

Source

pub fn recommend(&self) -> TopologyKind

Compute the recommended topology from observed stats. Pure function over the current edge-count snapshot; does NOT mutate the published recommendation. Use publish_recommendation to cache it for O(1) reads.

Source

pub fn publish_recommendation(&self) -> TopologyKind

Compute the recommendation AND publish it to the header so other processes can read it at O(1) via read_recommendation. Bumps recommendation_epoch. Returns the published recommendation.

Source

pub fn read_recommendation(&self) -> TopologyKind

Read the most-recently-published recommendation. O(1).

Source

pub fn broadcast_root(&self) -> u32

Read the recommended broadcast root (the highest-fan-out source at the most recent publish_recommendation). Only meaningful when read_recommendation == BroadcastTree.

Source

pub fn recommendation_epoch(&self) -> u64

Returns the recommendation epoch counter (bumped every publish_recommendation). Observers can subscribe to changes by comparing successive reads.

Source

pub fn total_msgs(&self) -> u64

Read total messages observed across all edges.

Source

pub fn stats(&self) -> TopologyStats

Snapshot all stats in one O(N²) pass.

Source

pub fn reset_observations(&self)

Reset all edge counters to zero (new observation window). Total_msgs is also reset. The recommendation cell is left untouched (use publish_recommendation to refresh after a new observation epoch).

Source

pub fn set_thresholds(&self, fan_out: u32, fan_in: u32)

Update the policy thresholds. Useful for tuning per workload without re-creating the map.

Source

pub fn flush(&self) -> Result<(), TopologyError>

Source

pub fn flush_async(&self) -> Result<(), TopologyError>

Non-blocking flush: schedules a writeback via the OS. Note: Windows is only partially async (sync to page cache, not to disk).

Trait Implementations§

Source§

impl AdaptiveInstance for SharedTopologyMap

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.
Source§

impl Send for SharedTopologyMap

Source§

impl Sync for SharedTopologyMap

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.