Use a bounded channel in the multithreaded executor (#7829)
# Objective This is a follow-up to #7745. An unbounded `async_channel` occasionally allocates whenever it exceeds the capacity of the current buffer in it's internal linked list. This is avoidable. This also used to be a bounded channel before stageless, which was introduced in #4919. ## Solution Use a bounded channel to avoid allocations on system completion. This shouldn't conflict with #7745, as it's impossible for the scheduler to exceed the channel capacity, even if somehow every system completed at the same time.
This commit is contained in:
parent
3d3444b981
commit
107cdc10bc
@ -121,6 +121,10 @@ impl SystemExecutor for MultiThreadedExecutor {
|
|||||||
let sys_count = schedule.system_ids.len();
|
let sys_count = schedule.system_ids.len();
|
||||||
let set_count = schedule.set_ids.len();
|
let set_count = schedule.set_ids.len();
|
||||||
|
|
||||||
|
let (tx, rx) = async_channel::bounded(sys_count.max(1));
|
||||||
|
|
||||||
|
self.sender = tx;
|
||||||
|
self.receiver = rx;
|
||||||
self.evaluated_sets = FixedBitSet::with_capacity(set_count);
|
self.evaluated_sets = FixedBitSet::with_capacity(set_count);
|
||||||
self.ready_systems = FixedBitSet::with_capacity(sys_count);
|
self.ready_systems = FixedBitSet::with_capacity(sys_count);
|
||||||
self.ready_systems_copy = FixedBitSet::with_capacity(sys_count);
|
self.ready_systems_copy = FixedBitSet::with_capacity(sys_count);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user