Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Establish benchmarks for waves of entity spawning as discussed in #18054. This does not include (for now) wave insertions, as mere insertions don't affect entity allocation.
Solution
Add benchmarks for permutations of entity count, wave count, component size, and batch spawning function.
The benchmarks do not show much difference in the component size variance, so I would be happy to remove that and decrease complexity if desired.
Showcase
Yikes! Here are the results on M2 MAX:
(Ignore the regressions and improvements. That's from testing the benches.)
Here, I only ran the
EmptyComponent
benches.With only one wave,
spawn_batch
andinsert_or_spawn_batch
both run in roughly 3ms because there are no shenanigans inEntities
regarding allocation.So if one wave takes 3ms, 2 waves should take 6ms, right? Nope!
spawn_batch
on 2 waves takes 6ms, butinsert_or_spawn_batch
with the infamousalloc_at_without_replacement
takes 760ms!!. That's a little more than 6.Running 16 waves was taking too long, but I'll leave it running for a bit so we can get a number. I would estimate ~11 seconds (700ms per wave on average) for
insert_or_spawn_batch
. This implies that the relationship isn't quite linear since the above 2 waves was also 700ms. But this could be memory allocator shenanigans too.EDIT: It did end up being ~11.5 seconds.