coyote-ecs icon indicating copy to clipboard operation
coyote-ecs copied to clipboard

Optimize component creation with batch processing

Open linuxy opened this issue 11 months ago • 0 comments

The current implementation for creating components has high overhead due to:

  1. Creating individual entities and components in a loop, resulting in many small allocations
  2. Performing verification on each component (checking attached)
  3. Potentially unnecessary debug logging logic in the inner loop

Recommended optimizations:

  1. Add batch creation methods to the ECS system to create multiple entities and components at once
  2. Replace the individual component verification with a bulk validation or optional sampling
  3. Move the debug logging outside the hot loop or replace with a more efficient logging approach that buffers output
  4. 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.

linuxy avatar May 04 '25 20:05 linuxy