The Entity-Component-System (ECS) model has become the industry standard for game engine design. However, most ECS implementations rely heavily on query-based systems to retrieve relevant entities every frame — an approach that introduces unnecessary overhead and runtime cost.
That's why I propose an alternative architecture: the Reactive ECS.
Instead of querying entities each frame, systems subscribe once to specific combinations of components. A centralized ECSManager
then conditionally dispatches the relevant entities to each system, based on these subscriptions. In other words, the only "query" is done up-front, at subscription time.
🚀 Benefits of this approach:
- Zero per-frame query cost: Systems receive only what they need, when they need it.
- Modular and dynamic: Entities and systems can be added or removed at runtime; the subscription logic handles everything.
- Scalable and performant: 1 million entities dispatched to 3 systems in just 980 ns, on a dual-thread CPU.
- Better memory locality: Archetype grouping makes processing cache-friendly.
- Naturally parallelizable: Systems are decoupled and only receive their relevant data.
You can check the full implementation and architecture (written in Julia) here:
👉 https://github.com/Gesee-y/RECS.jl
Feedback and contributions are welcome!