Data-oriented design

This is an old revision of this page, as edited by Fmadd (talk | contribs) at 03:08, 19 June 2016 (Motivation). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computing, Data oriented design (not to be confused with data-driven design) is a software optimisation approach motivated by cache coherency, used in video game development (usually in the C or C++ programming languages). [1] The approach is to focus on the data layout, separating and sorting fields according to when they are needed, and to think about transformations of data. Proponents include Mike Acton. [2]

Motivation

These techniques became especially popular during the PS3 and xbox 360 console generation when the hazards of cache misses became especially pronounced, due to their use of in-order processors with high clock speeds and deep pipelines (some of the software issues were similar to those encountered on the itanium, requiring unrolling for upfront scheduling). In modern systems (even with out of order execution), main memory is as many as hundreds of clock cycles away from the processing elements; consequently locality of reference issues dominate performance, requiring improvement of memory access patterns to fix.

Contrast with OOP

The claim is that traditional object-oriented design principles result in poor data locality, especially if runtime polymorphism is used (which itself is especially problematic on certain processors [3] ). [4] Although OOP does superficially seem to 'organise code around data', the practice is quite different. OOP is actually about organising source code around data types, rather than physically grouping individual fields and arrays in a manner that is efficient for access by specific functions. It also frequently hides layout details under abstraction layers, whilst a data-oriented programmer wants to think about this first and foremost.

Other languages

The experimental JAI programming language being developed by Jonathan Blow has explicit support for data oriented design, whilst eschewing the traditional OOP paradigm. This is facilitated by being able to transparently move fields between records without extensive source code changes to functions using them (or without extensive boilerplate to enable this), and by adding direct support for SoA data layout. [5]

See also

References

  1. ^ "data oriented design" (PDF).
  2. ^ "CppCon 2014: Mike Acton "Data-Oriented Design and C++"".
  3. ^ "What's wrong with Object-Oriented Design? Where's the harm in it?".describes the problems with virtual function calls,e.g. i-cache misses
  4. ^ "data oriented design - why you might be shooting yourself in the foot with OOP".
  5. ^ "Data oriented demo:SOA,composition".Demonstration of data-oriented and SOA features in the JAI language, also explaining the motivation