Enum glommio::Placement

source ·
pub enum Placement {
    Unbound,
    Fenced(CpuSet),
    Fixed(usize),
}
Expand description

Specifies a policy by which LocalExecutorBuilder selects CPUs.

Placement is used to bind LocalExecutors to a set of CPUs via preconfigured policies designed to address a variety of use cases.

§Example

Some Placements allow manually filtering available CPUs via a CpuSet, such as MaxSpread. The following would place shards on four CPUs (a.k.a. hyper-threads) that are on NUMA node 0 and have an even numbered package ID according to their CpuLocation. The selection aims to achieve a high degree of separation between the CPUs in terms of machine topology. Each LocalExecutor would be bound to a single CPU.

use glommio::{CpuSet, LocalExecutorBuilder, Placement};

let cpus = CpuSet::online()
    .expect("Err: please file an issue with glommio")
    .filter(|l| l.numa_node == 0)
    .filter(|l| l.package % 2 == 0);

LocalExecutorBuilder::new(Placement::Fenced(cpus))
    .spawn(|| async move {
        // ... important stuff ...
    })
    .unwrap()
    .join();

Variants§

§

Unbound

The Unbound variant creates a LocalExecutors that are not bound to any CPU.

§

Fenced(CpuSet)

The Fenced variant binds the LocalExecutor to the set of CPUs specified by CpuSet. With an unfiltered CPU set returned by CpuSet::online, this is similar to using Unbound with the distinction that bringing additional CPUs online will not allow the executor to run on the newly available CPUs.

§Errors

If the provided CpuSet contains no CPUs, the builder will fail.

§

Fixed(usize)

The LocalExecutor is bound to the CPU specified by Fixed.

§Errors

LocalExecutorBuilder will return Result::Err if the CPU doesn’t exist.

Implementations§

source§

impl Placement

source

pub fn generate_cpu_set(self) -> Result<CpuSetGenerator, ()>

Probe the topology of the system and materialize this Placement into a CpuSet

Trait Implementations§

source§

impl Clone for Placement

source§

fn clone(&self) -> Placement

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Placement

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Placement> for PoolPlacement

source§

fn from(placement: Placement) -> Self

Converts to this type from the input type.
source§

impl Hash for Placement

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for Placement

source§

fn eq(&self, other: &Placement) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Placement

source§

impl StructuralPartialEq for Placement

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> CallHasher for T
where T: Hash + ?Sized,

source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more