Struct bevy_ecs::batching::BatchingStrategy
source · 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.
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> 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
Self
using data from the given World
.