coyote-ecs
coyote-ecs copied to clipboard
Optimize component creation with batch processing
The current implementation for creating components has high overhead due to:
- Creating individual entities and components in a loop, resulting in many small allocations
- Performing verification on each component (checking
attached) - Potentially unnecessary debug logging logic in the inner loop
Recommended optimizations:
- Add batch creation methods to the ECS system to create multiple entities and components at once
- Replace the individual component verification with a bulk validation or optional sampling
- Move the debug logging outside the hot loop or replace with a more efficient logging approach that buffers output
- Consider reserving memory upfront in the ECS system for the expected number of entities/components
These changes would significantly reduce allocation overhead and improve test performance, especially for the large-scale tests being conducted (1M+ entities). The batch implementation could also be useful for real application scenarios where many similar entities need to be created at once.