Modern game engines increasingly adopt the Entity Component System (ECS) paradigm as a data-oriented alternative to traditional object-oriented architecture. While ECS promotes modularity and performance through the separation of data and behavior, its practical efficiency depends heavily on the underlying data layout. Despite widespread adoption in frameworks, such as Unity DOTS, Bevy, and Flecs, the semantics of the archetype ECS remain informal and implementation-dependent, limiting rigorous reasoning about determinism, system scheduling, and structural mutations. This work formalizes and experimentally evaluates the archetype ECS. The formal model captures entity creation, component composition, system execution, and archetype migration as compositional state transitions, establishing the core invariants of archetype organization. Using a Tower Defense simulation, we compare the archetype ECS with alternative designs under identical conditions. Results show that the archetype ECS achieves higher frame rate and better frame stability than alternative designs, due to improved cache efficiency and consistent entity access. By uniting formal semantics with empirical validation, this study shows that the archetype ECS outperforms traditional architectures and provides a solid foundation for reasoning about correctness and parallelism.
翻译:现代游戏引擎越来越多地采用实体组件系统(Entity Component System, ECS)范式,作为传统面向对象架构的数据驱动替代方案。虽然ECS通过分离数据与行为来促进模块化与性能,但其实际效率高度依赖于底层数据布局。尽管ECS已被广泛采用于Unity DOTS、Bevy和Flecs等框架中,原型ECS(archetype ECS)的语义仍是非形式化的且依赖于具体实现,这限制了对确定性、系统调度及结构变更的严格推理。本文对原型ECS进行了形式化建模与实验评估。该形式化模型将实体创建、组件组合、系统执行及原型迁移刻画为组合式状态转换,确立了原型组织的核心不变性。通过塔防仿真实验,我们在相同条件下比较了原型ECS与其他设计方案的性能。结果表明,原型ECS凭借优化的缓存效率与一致的实体访问,实现了比替代设计更高的帧率与更优的帧稳定性。通过将形式语义与经验验证相结合,本研究表明原型ECS优于传统架构,并为正确性与并行性推理提供了坚实基础。