pub struct SharedTopologyMap { /* private fields */ }Implementations§
pub fn create( path: impl AsRef<Path>, n_nodes: usize, ) -> Result<Self, TopologyError>
pub fn create_with_thresholds( path: impl AsRef<Path>, n_nodes: usize, fan_out_threshold: u32, fan_in_threshold: u32, ) -> Result<Self, TopologyError>
pub fn open( path: impl AsRef<Path>, expected_n_nodes: usize, ) -> Result<Self, TopologyError>
pub fn n_nodes(&self) -> usize
Sourcepub fn record_send(&self, src: u32, dst: u32) -> Result<u64, TopologyError>
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.
Sourcepub fn fan_out(&self, src: u32) -> u32
pub fn fan_out(&self, src: u32) -> u32
Fan-out for src: count of destinations with non-zero edge.
Sourcepub fn max_fan_out(&self) -> (u32, u32)
pub fn max_fan_out(&self) -> (u32, u32)
Max fan-out across all sources, plus the source index.
Sourcepub fn max_fan_in(&self) -> (u32, u32)
pub fn max_fan_in(&self) -> (u32, u32)
Max fan-in across all destinations, plus the dst index.
Sourcepub fn recommend(&self) -> TopologyKind
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.
Sourcepub fn publish_recommendation(&self) -> TopologyKind
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.
Sourcepub fn read_recommendation(&self) -> TopologyKind
pub fn read_recommendation(&self) -> TopologyKind
Read the most-recently-published recommendation. O(1).
Sourcepub fn broadcast_root(&self) -> u32
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.
Sourcepub fn recommendation_epoch(&self) -> u64
pub fn recommendation_epoch(&self) -> u64
Returns the recommendation epoch counter (bumped every
publish_recommendation). Observers can subscribe to
changes by comparing successive reads.
Sourcepub fn total_msgs(&self) -> u64
pub fn total_msgs(&self) -> u64
Read total messages observed across all edges.
Sourcepub fn stats(&self) -> TopologyStats
pub fn stats(&self) -> TopologyStats
Snapshot all stats in one O(N²) pass.
Sourcepub fn reset_observations(&self)
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).
Sourcepub fn set_thresholds(&self, fan_out: u32, fan_in: u32)
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.
pub fn flush(&self) -> Result<(), TopologyError>
Sourcepub fn flush_async(&self) -> Result<(), TopologyError>
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).