Data-oriented design: Difference between revisions

Content deleted Content added
Inkeliz (talk | contribs)
update refs
Citation bot (talk | contribs)
Alter: title. Add: s2cid, doi, pages, volume, date. Removed proxy/dead URL that duplicated identifier. Removed parameters. | Use this bot. Report bugs. | Suggested by AManWithNoPlan | Category:CS1 maint: url-status | #UCB_Category 37/960
Line 3:
{{Distinguish|Data-oriented programming}}
{{More citations needed|date=July 2020}}
In [[computing]], '''data-oriented design''' is a [[program optimization]] approach motivated by efficient usage of the [[CPU cache]], used in [[video game]] development.<ref>{{cite web|url=http://gamesfromwithin.com/data-oriented-design|title=Data-oriented design|last=Llopis|first=Noel|date=December 4, 2009|website=Data-Oriented Design (Or Why You Might Be Shooting Yourself in The Foot With OOP)|url-status=live|archive-url=|archive-date=|access-date=April 17, 2020}}</ref> The approach is to focus on the data layout, separating and sorting [[field (computing)|fields]] according to when they are needed, and to think about transformations of data. Proponents include Mike Acton,<ref>{{cite web|title=CppCon 2014: Mike Acton "Data-Oriented Design and C++"|website = [[YouTube]]|url=https://www.youtube.com/watch?v=rX0ItVEVjHc}}</ref> [[Scott Meyers]],<ref>{{cite web|title=code::dive conference 2014 - Scott Meyers: Cpu Caches and Why You Care|website = [[YouTube]]|url=https://www.youtube.com/watch?v=WDIkqP4JbkE}}</ref> and [[Jonathan Blow]].
 
The [[parallel array]] (or [[structure of arrays]]) is the main example of data-oriented design. It is contrasted with the ''array of structures'' typical of object-oriented designs.
 
The definition of data-oriented design as a [[programming paradigm]] can be seen as contentious as many believe that it can be used side by side with another paradigm<ref>https://www.dataorienteddesign.com/dodmain/node3.html</ref>, but due to the emphasis on data layout, it is also incompatible with most paradigm. <ref>{{cite web|url=http://gamesfromwithin.com/data-oriented-design|title=Data-oriented design|last=Llopis|first=Noel|date=December 4, 2009|website=Data-Oriented Design (Or Why You Might Be Shooting Yourself in The Foot With OOP)|url-status=live|archive-url=|archive-date=|access-date=April 17, 2020}}</ref>.
 
== Motives ==
Line 15:
{{Original research section|date=September 2021}}
The claim is that traditional [[object-oriented programming]] (OOP) design principles result in poor data locality <ref>{{cite web
| title = INTEL ® HPC DEVELOPER CONFERENCE FUEL YOUR INSIGHT IMPROVE VECTORIZATION EFFICIENCY USING INTEL SIMD DATA LAYOUT TEMPLATE (INTEL SDLT),
| url = https://www.intel.com/content/dam/www/public/us/en/documents/presentation/improving-vectorization-efficiency.pdf
}}</ref><ref>{{cite journal
| title = SoAx: A generic C++ Structure of Arrays for handling particles in HPC codes
| url = https://arxiv.org/pdf/1710.03462.pdf
| author1 = Holger Homann
| author2 = Francois Laenen
| journal = Computer Physics Communications
| date = 2018
| volume = 224
| pages = 325–332
| doi = 10.1016/j.cpc.2017.11.015
| arxiv = 1710.03462
| s2cid = 2878169
| language = English
}}</ref>, more so if runtime polymorphism ([[dynamic dispatch]]) is used (which is especially problematic on some processors).<ref>{{cite web|title=What's wrong with Object-Oriented Design? Where's the harm in it?|url=http://www.dataorienteddesign.com/dodmain/node17.html}}describes the problems with virtual function calls, e.g., i-cache misses</ref><ref>{{cite web|title=Data-oriented design - why you might be shooting yourself in the foot with OOP|url=http://gamesfromwithin.com/data-oriented-design}}</ref> Although OOP appears to "organise code around data", it actually organises [[source code]] around [[data type]]s rather than physically grouping individual fields and arrays in an efficient format for access by specific functions. Moreover, it often hides layout details under [[abstraction layer]]s, while a data-oriented programmer wants to consider this first and foremost.