pub enum PoolPlacement {
    Unbound(usize),
    Fenced(usize, CpuSet),
    MaxSpread(usize, Option<CpuSet>),
    MaxPack(usize, Option<CpuSet>),
    Custom(Vec<CpuSet>),
}
Expand description

Specifies a policy by which LocalExecutorPoolBuilder selects CPUs.

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

§Example

Some PoolPlacements 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.

Note that if four CPUs are not available, the call to LocalExecutorPoolBuilder::on_all_shards would return an Err when using MaxSpread.

use glommio::{CpuSet, LocalExecutorPoolBuilder, PoolPlacement};

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

let handles = LocalExecutorPoolBuilder::new(PoolPlacement::MaxSpread(4, Some(cpus)))
    .on_all_shards(|| async move {
        // ... important stuff ...
    })
    .unwrap();

handles.join_all();

Variants§

§

Unbound(usize)

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

§

Fenced(usize, CpuSet)

The Fenced variant binds each LocalExecutor to create 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 executors to run on the newly available CPUs. The Fenced variant allows the number of shards specified in LocalExecutorPoolBuilder::new to be greater than the number of CPUs as long as at least one CPU is included in CpuSet.

§Errors

If the provided CpuSet contains no CPUs, a call to LocalExecutorPoolBuilder::on_all_shards will return Result:: Err.

§

MaxSpread(usize, Option<CpuSet>)

Each LocalExecutor to create is pinned to a particular CpuLocation such that the set of all CPUs selected has a high degree of separation. The selection proceeds from all CPUs that are online in a non-deterministic manner. The Option<CpuSet> parameter may be used to restrict the CpuSet from which CPUs are selected; specifying None is equivalent to using Some(CpuSet::online()?).

§Errors

If the number of shards is greater than the number of CPUs available, then a call to LocalExecutorPoolBuilder::on_all_shards will return Result:: Err.

§

MaxPack(usize, Option<CpuSet>)

Each LocalExecutor to create is pinned to a particular CpuLocation such that the set of all CPUs selected has a low degree of separation. The selection proceeds from all CPUs that are online in a non-deterministic manner. The Option<CpuSet> parameter may be used to restrict the CpuSet from which CPUs are selected; specifying None is equivalent to using Some(CpuSet::online()?).

§Errors

If the number of shards is greater than the number of CPUs available, then a call to LocalExecutorPoolBuilder::on_all_shards will return Result:: Err.

§

Custom(Vec<CpuSet>)

One LocalExecutor is bound to each of the CpuSets specified by Custom. The number of CpuSets in the Vec should match the number of shards requested from the pool builder.

§Errors

LocalExecutorPoolBuilder::on_all_shards will return Result::Err if any of the provided CpuSet is empty.

Implementations§

source§

impl PoolPlacement

source

pub fn executor_count(&self) -> usize

Return the number of executor to create according to this placement policy

source

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

Probe the topology of the system and materialize this PoolPlacement into a set of CpuSet

Trait Implementations§

source§

impl Clone for PoolPlacement

source§

fn clone(&self) -> PoolPlacement

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 PoolPlacement

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 PoolPlacement

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 PoolPlacement

source§

fn eq(&self, other: &PoolPlacement) -> 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 PoolPlacement

source§

impl StructuralPartialEq for PoolPlacement

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