pub struct BatchingStrategy {
pub batch_size_limits: Range<usize>,
pub batches_per_thread: usize,
}
Expand description
Dictates how a parallel operation chunks up large quantities during iteration.
A parallel query will chunk up large tables and archetypes into chunks of at most a certain batch size. Similarly, a parallel event reader will chunk up the remaining events.
By default, this batch size is automatically determined by dividing the size of the largest matched archetype by the number of threads (rounded up). This attempts to minimize the overhead of scheduling tasks onto multiple threads, but assumes each entity has roughly the same amount of work to be done, which may not hold true in every workload.
See Query::par_iter
, EventReader::par_read
for more information.
Fields§
§batch_size_limits: Range<usize>
The upper and lower limits for a batch of entities.
Setting the bounds to the same value will result in a fixed batch size.
Defaults to [1, usize::MAX]
.
batches_per_thread: usize
The number of batches per thread in the ComputeTaskPool
.
Increasing this value will decrease the batch size, which may
increase the scheduling overhead for the iteration.
Defaults to 1.
Implementations§
Source§impl BatchingStrategy
impl BatchingStrategy
Sourcepub const fn fixed(batch_size: usize) -> Self
pub const fn fixed(batch_size: usize) -> Self
Declares a batching strategy with a fixed batch size.
Sourcepub const fn min_batch_size(self, batch_size: usize) -> Self
pub const fn min_batch_size(self, batch_size: usize) -> Self
Configures the minimum allowed batch size of this instance.
Sourcepub const fn max_batch_size(self, batch_size: usize) -> Self
pub const fn max_batch_size(self, batch_size: usize) -> Self
Configures the maximum allowed batch size of this instance.
Sourcepub fn batches_per_thread(self, batches_per_thread: usize) -> Self
pub fn batches_per_thread(self, batches_per_thread: usize) -> Self
Configures the number of batches to assign to each thread for this instance.
Sourcepub fn calc_batch_size(
&self,
max_items: impl FnOnce() -> usize,
thread_count: usize,
) -> usize
pub fn calc_batch_size( &self, max_items: impl FnOnce() -> usize, thread_count: usize, ) -> usize
Calculate the batch size according to the given thread count and max item count. The count is provided as a closure so that it can be calculated only if needed.
§Panics
Panics if thread_count
is 0.
Trait Implementations§
Source§impl Clone for BatchingStrategy
impl Clone for BatchingStrategy
Source§fn clone(&self) -> BatchingStrategy
fn clone(&self) -> BatchingStrategy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for BatchingStrategy
impl Debug for BatchingStrategy
Auto Trait Implementations§
impl Freeze for BatchingStrategy
impl RefUnwindSafe for BatchingStrategy
impl Send for BatchingStrategy
impl Sync for BatchingStrategy
impl Unpin for BatchingStrategy
impl UnwindSafe for BatchingStrategy
Blanket Implementations§
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,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using default()
.