Hello Bevy community. This is my first time using bevy for a serious project so I apologize if I'm lacking some basic knowledge to a potentially simple question.
I've been stress testing my game and found some reproducible strange behavior. I start the game and spawn about 80,000 entities linearly over 4 seconds. I don't see any frame rate drops until I have around 70,000 entities. Those all despawn over the next 4 seconds and I know have less than 10 entities alive. I immediatly start spawning entities via the same process again but now my frames drop aggressively when there are only 10,000-20,000 entities in the game. There are zero changes and new systems running between the trials. One simply happens after the other. This is reproducible 100% of the time.
I have attached a flamegraph. The weapons::update::update_projectile time taken is expected, but the majority of time is spent in bevy_ecs::entity::Entities::alloc_at_without_replacement. I'm not sure if this is expected or what is going on? I did some googling and was unable to find anything and I lack the knowledge on the internals of Bevy to understand when this method should be running.
I'm happy to provide any more information that may be useful! Thank you for taking the time to read this!