pub struct NumaTopology { /* private fields */ }Expand description
NUMA topology information for the system.
Provides information about NUMA nodes, which CPUs belong to each node, and memory available per node.
Implementations§
Source§impl NumaTopology
impl NumaTopology
Sourcepub fn detect() -> Self
pub fn detect() -> Self
Detect the system’s NUMA topology.
Uses the best available method for the platform:
- Linux: Reads from sysfs (
/sys/devices/system/node/) - Other: Returns a single-node topology
This method never fails - it falls back to a single-node topology if detection fails.
Sourcepub fn cpus_for_node(&self, node: usize) -> &[usize]
pub fn cpus_for_node(&self, node: usize) -> &[usize]
Returns the CPUs belonging to a specific NUMA node.
Returns an empty slice if the node ID is invalid.
Sourcepub fn node_for_cpu(&self, cpu: usize) -> usize
pub fn node_for_cpu(&self, cpu: usize) -> usize
Returns the NUMA node for a given CPU.
Returns 0 if the CPU ID is invalid.
Sourcepub fn current_node(&self) -> usize
pub fn current_node(&self) -> usize
Returns the NUMA node for the current CPU.
Sourcepub fn bind_local_memory(&self) -> Result<(), NumaError>
pub fn bind_local_memory(&self) -> Result<(), NumaError>
Bind the current thread’s memory allocations to its local NUMA node.
This should be called AFTER set_cpu_affinity() so that current_node()
returns the correct node.
§Errors
Returns NumaError::BindFailed if the set_mempolicy syscall fails.
Sourcepub fn current_cpu() -> usize
pub fn current_cpu() -> usize
Returns the current CPU ID.
Trait Implementations§
Source§impl Clone for NumaTopology
impl Clone for NumaTopology
Source§fn clone(&self) -> NumaTopology
fn clone(&self) -> NumaTopology
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NumaTopology
impl RefUnwindSafe for NumaTopology
impl Send for NumaTopology
impl Sync for NumaTopology
impl Unpin for NumaTopology
impl UnsafeUnpin for NumaTopology
impl UnwindSafe for NumaTopology
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more