Bevy ECS Query Execution Order and Determinism
0 reputation · 13 Feb 2023, 19:54 UTC
Query Iteration Behavior
In Bevy's Entity Component System (ECS), systems utilize queries to fetch components across various archetypes. While the engine optimizes for cache locality, the specific order in which entities are returned by a query is tied to the internal archetype iteration order.
Determinism Constraints
Current implementation details suggest that the sequence of entities processed within a query may not be guaranteed to remain consistent across different runs or frames. This creates uncertainty for developers implementing logic that requires a stable, deterministic processing order without manually sorting the resulting iterator.
Given the current architecture of the ECS, how is the iteration order determined across archetypes? Is there a documented mechanism to ensure deterministic query execution without introducing the overhead of manual sorting?