Modern game engine architecture relies on Data-Oriented Design (DOD) and Entity-Component-System (ECS) models over traditional Object-Oriented Programming (OOP). Storing game entity data in contiguous array memory blocks eliminates L1/L2 cache misses, enabling game engines to update over 500,000 active entities at 60+ FPS on modern CPU hardware.
1. Entity Component System (ECS) Architecture
Traditional game architectures used object inheritance (`GameObject -> Actor -> Pawn -> Player`). This leads to cache thrashing and tight coupling. ECS replaces this with three decoupled primitives:
- Entities: Plain 32-bit or 64-bit integer IDs without methods or state.
- Components: Pure POD (Plain Old Data) structs containing numeric state (position, velocity, health).
- Systems: Stateless functions that execute transformation loops over contiguous arrays of components.
Entities carry no logic. Components carry no behavior. Systems carry no state. That separation is what lets millions of components live in flat, cache-friendly arrays instead of a scattered inheritance tree.
2. Data Locality & Memory Layout
CPU instruction pipelines fetch 64-byte cache lines. Sequential memory access provides maximum memory bandwidth:
// Contiguous Archetype Memory Pool in C++20
struct PositionComponent { float x, y, z; };
struct VelocityComponent { float vx, vy, vz; };
void MovementSystem(PositionComponent* pos, const VelocityComponent* vel, size_t count, float dt) {
for (size_t i = 0; i < count; ++i) {
pos[i].x += vel[i].vx * dt;
pos[i].y += vel[i].vy * dt;
pos[i].z += vel[i].vz * dt;
}
}
3. Multithreaded Job Architecture
Worker thread pools use lock-free ring buffers and work-stealing algorithms to distribute entity update tasks across all available CPU cores without thread locks or mutex contention.
4. Performance Benchmarks
| Pattern | Entities @ 60 FPS | L1 Cache Misses |
|---|---|---|
| Virtual Hierarchy OOP | 18,000 | 38.4% |
| Sparse Set ECS | 145,000 | 7.2% |
| Contiguous Archetype ECS | 520,000 | 1.4% |
