-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
What problem does this solve or what need does it fill?
Right now, CommandQueue is built on top of a Vec<MaybeUninit<u8>> as an arbitrary heterogeneous byte buffer that is cleared on application, but never deallocated until the CommandQueue is dropped. This isn't the greatest allocation strategy as the entire Vec needs to be reallocated each time the capacity is exceeded, and the CommandQueue always keeps an allocation matching it's peak, not it's current or average usage.
What solution would you like?
The append-only use of CommandQueue is very close to that of a bump allocator, and bumpalo is already in the bevy_ecs dependency tree. Either use bumpalo to allocate commands or create a similar allocation strategy. Drop all allocated chunks upon the queue being flushed.
This may also allow us to properly align all incoming commands to avoid unaligned reads in command implementations (avoiding the need for #20593).
What alternative(s) have you considered?
Leave it as is. The approach used is already very efficient.