Enum glommio::PoolPlacement
source · 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 LocalExecutor
s to a set of CPUs via
preconfigured policies designed to address a variety of use cases.
§Example
Some PoolPlacement
s 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
LocalExecutor
s 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 CpuSet
s specified by
Custom
. The number of CpuSet
s 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
impl PoolPlacement
sourcepub fn executor_count(&self) -> usize
pub fn executor_count(&self) -> usize
Return the number of executor to create according to this placement policy
sourcepub fn generate_cpu_set(self) -> Result<CpuSetGenerator, ()>
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
impl Clone for PoolPlacement
source§fn clone(&self) -> PoolPlacement
fn clone(&self) -> PoolPlacement
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PoolPlacement
impl Debug for PoolPlacement
source§impl From<Placement> for PoolPlacement
impl From<Placement> for PoolPlacement
source§impl Hash for PoolPlacement
impl Hash for PoolPlacement
source§impl PartialEq for PoolPlacement
impl PartialEq for PoolPlacement
source§fn eq(&self, other: &PoolPlacement) -> bool
fn eq(&self, other: &PoolPlacement) -> bool
self
and other
values to be equal, and is used
by ==
.