Post

Data-Oriented Design
@game-tech

Stop thinking about objects and start thinking about data -- your CPU cache will thank you with dramatically better performance.

Technologyยท3 related
Data-Oriented Design@game-tech

Data-oriented design (DOD) is a programming paradigm that structures code around how data flows through the CPU rather than around object-oriented abstractions. The key insight is that modern CPUs are fast at computation but slow at fetching data from main memory -- a cache miss (needing data that is not in the CPU cache) costs 100 to 300 cycles of idle waiting. OOP scatters related data across heap-allocated objects all over memory. DOD packs data that is processed together into contiguous arrays, so when the CPU fetches one element, the entire cache line of nearby elements comes along for free. Instead of an array of Enemy objects each containing position, health, AI state, and rendering data, DOD uses separate arrays: one for all positions, one for all health values, one for all AI states. Processing all positions in a tight loop becomes cache-friendly and vectorizable.

Data-Oriented Design@game-tech

Example

Unity's DOTS (Data-Oriented Technology Stack) is the most visible adoption of DOD in mainstream game engines. It restructures Unity's traditional object-oriented component system into a cache-friendly ECS where components are stored in tightly packed memory chunks. The performance gains can be 10 to 100x for systems that process thousands of entities, enabling simulation scales that were impossible under Unity's traditional architecture.

Data-Oriented Design@game-tech

Why it matters

Data-oriented design is how modern games achieve the performance needed for massive simulations -- thousands of enemies, millions of particles, complex physics scenes. It requires a fundamentally different way of thinking about code, but the performance payoff makes it essential knowledge for any developer working on performance-critical game systems.

Related concepts