SlideShare a Scribd company logo
1 of 22
Data-Oriented Design @Neku42 max.klyga@gmail.com
Unreasoned OOD
PROGRAM DATA DATA
Good code follows good data, not the other way around.
class Bot { Vector3 position; … float mod; … float aimDirection; … voidUpdateAim(Vector3 target)     {         aimDirection = Vector3.DotProduct(position, target) * mod;     } }
class Bot { Vector3 position; … float mod; … float aimDirection; … voidUpdateAim(Vector3 target)     {         aimDirection = Vector3.DotProduct(position, target) * mod;     } } Icache-miss
class Bot { Vector3 position; … float mod; … float aimDirection; … voidUpdateAim(Vector3 target)     {         aimDirection = Vector3.DotProduct(position, target) * mod;     } } Icache-miss data-miss
class Bot { Vector3 position; … float mod; … float aimDirection; … voidUpdateAim(Vector3 target)     {         aimDirection = Vector3.DotProduct(position, target) * mod;     } } U N U S E D Icache-miss data-miss
… … … … … …
Array of Structures Structure of Arrays class Bot { Vector3 position; … float mod; … float aimDirection; … } List<Bot> bots; class Bots { List<Vector3> positions; … List<float> mods; … List<float> aimDirections; … }
class Bot { …	 voidUpdateAim(Vector3 target)     {         aimDirection = Vector3.DotProduct(position, target) * mod;     } } class Bots { …	     staticvoidUpdateAims(List<float> aimDirections, List<Vector3> positions, List<float> mods, List<Vector3> targets)     {         for (uint i = 0; i < aimDirections.Count; ++i) aimDirections[i] = Vector3.DotProduct(positions[i], targets[i]) * mods[i];     } }
Know the data!Think! Think! Think!
It’s all about memory Optimize for data not code
It’s all about memory Optimize for data not code Most code is mostly bound to memory access
It’s all about memory Optimize for data not code Most code is mostly bound to memory access Not everything needs to be an object
Data-Oriented Design: Better performance
Data-Oriented Design: Better performance Often simpler code
Data-Oriented Design: Better performance Often simpler code More parallelizable code
Questions?
http://slidesha.re/hKF9er

More Related Content

What's hot

Lec 6 14_aug [compatibility mode]
Lec 6 14_aug [compatibility mode]Lec 6 14_aug [compatibility mode]
Lec 6 14_aug [compatibility mode]
Palak Sanghani
 
04. constructor & destructor
04. constructor & destructor04. constructor & destructor
04. constructor & destructor
Haresh Jaiswal
 
Dotnet unit 4
Dotnet unit 4Dotnet unit 4
Dotnet unit 4
007laksh
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
Kamal Acharya
 

What's hot (20)

Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
C++ Constructor destructor
C++ Constructor destructorC++ Constructor destructor
C++ Constructor destructor
 
Java Foundations: Objects and Classes
Java Foundations: Objects and ClassesJava Foundations: Objects and Classes
Java Foundations: Objects and Classes
 
Concept of constructors
Concept of constructorsConcept of constructors
Concept of constructors
 
Op ps
Op psOp ps
Op ps
 
Core Java
Core JavaCore Java
Core Java
 
Constructor&method
Constructor&methodConstructor&method
Constructor&method
 
Constructor and Types of Constructors
Constructor and Types of ConstructorsConstructor and Types of Constructors
Constructor and Types of Constructors
 
Lec 6 14_aug [compatibility mode]
Lec 6 14_aug [compatibility mode]Lec 6 14_aug [compatibility mode]
Lec 6 14_aug [compatibility mode]
 
Constructor & Destructor
Constructor & DestructorConstructor & Destructor
Constructor & Destructor
 
OOP
OOPOOP
OOP
 
constructors in java ppt
constructors in java pptconstructors in java ppt
constructors in java ppt
 
04. constructor & destructor
04. constructor & destructor04. constructor & destructor
04. constructor & destructor
 
Dotnet unit 4
Dotnet unit 4Dotnet unit 4
Dotnet unit 4
 
Constructor
ConstructorConstructor
Constructor
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
 
vb.net Constructor and destructor
vb.net Constructor and destructorvb.net Constructor and destructor
vb.net Constructor and destructor
 
Constructor and Destructor PPT
Constructor and Destructor PPTConstructor and Destructor PPT
Constructor and Destructor PPT
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
Constructor and destructor
Constructor and destructorConstructor and destructor
Constructor and destructor
 

Viewers also liked (6)

Intro to data oriented design
Intro to data oriented designIntro to data oriented design
Intro to data oriented design
 
Introduction to Data-Oriented Design
Introduction to Data-Oriented DesignIntroduction to Data-Oriented Design
Introduction to Data-Oriented Design
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++
 
PAD102 UiTM Assignment : Government Agencies
PAD102 UiTM Assignment : Government Agencies PAD102 UiTM Assignment : Government Agencies
PAD102 UiTM Assignment : Government Agencies
 
Introduction to Data-Oriented Design
Introduction to Data-Oriented DesignIntroduction to Data-Oriented Design
Introduction to Data-Oriented Design
 
Introduction to Data Oriented Design
Introduction to Data Oriented DesignIntroduction to Data Oriented Design
Introduction to Data Oriented Design
 

Similar to Data oriented design

! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
MARRY7
 

Similar to Data oriented design (8)

Lean React - Patterns for High Performance [ploneconf2017]
Lean React - Patterns for High Performance [ploneconf2017]Lean React - Patterns for High Performance [ploneconf2017]
Lean React - Patterns for High Performance [ploneconf2017]
 
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
 
Green dao
Green daoGreen dao
Green dao
 
Demystifying The Solid Works Api
Demystifying The Solid Works ApiDemystifying The Solid Works Api
Demystifying The Solid Works Api
 
D3.js - A picture is worth a thousand words
D3.js - A picture is worth a thousand wordsD3.js - A picture is worth a thousand words
D3.js - A picture is worth a thousand words
 
Wpf Workgroup 4
Wpf Workgroup 4Wpf Workgroup 4
Wpf Workgroup 4
 
Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...
Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...
Creating a Custom Tanimoto or Cosine Similarity Vector Operator for Lucene / ...
 
Sql server query collection
Sql server query collectionSql server query collection
Sql server query collection
 

More from Max Klyga (6)

Distributed tracing with OpenTracing and Jaeger @ getstream.io
Distributed tracing with OpenTracing and Jaeger @ getstream.ioDistributed tracing with OpenTracing and Jaeger @ getstream.io
Distributed tracing with OpenTracing and Jaeger @ getstream.io
 
Change #Health - Dutch Open Hackathon 2015
Change #Health - Dutch Open Hackathon 2015Change #Health - Dutch Open Hackathon 2015
Change #Health - Dutch Open Hackathon 2015
 
Scala for the doubters
Scala for the doubtersScala for the doubters
Scala for the doubters
 
Practical resource management for mobile devices: Pooling is magic
Practical resource management for mobile devices: Pooling is magicPractical resource management for mobile devices: Pooling is magic
Practical resource management for mobile devices: Pooling is magic
 
Marmalade: bittersweet experience
Marmalade: bittersweet experienceMarmalade: bittersweet experience
Marmalade: bittersweet experience
 
Cpp
CppCpp
Cpp
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Data oriented design

  • 1. Data-Oriented Design @Neku42 max.klyga@gmail.com
  • 2.
  • 4.
  • 6. Good code follows good data, not the other way around.
  • 7. class Bot { Vector3 position; … float mod; … float aimDirection; … voidUpdateAim(Vector3 target) { aimDirection = Vector3.DotProduct(position, target) * mod; } }
  • 8. class Bot { Vector3 position; … float mod; … float aimDirection; … voidUpdateAim(Vector3 target) { aimDirection = Vector3.DotProduct(position, target) * mod; } } Icache-miss
  • 9. class Bot { Vector3 position; … float mod; … float aimDirection; … voidUpdateAim(Vector3 target) { aimDirection = Vector3.DotProduct(position, target) * mod; } } Icache-miss data-miss
  • 10. class Bot { Vector3 position; … float mod; … float aimDirection; … voidUpdateAim(Vector3 target) { aimDirection = Vector3.DotProduct(position, target) * mod; } } U N U S E D Icache-miss data-miss
  • 11. … … … … … …
  • 12. Array of Structures Structure of Arrays class Bot { Vector3 position; … float mod; … float aimDirection; … } List<Bot> bots; class Bots { List<Vector3> positions; … List<float> mods; … List<float> aimDirections; … }
  • 13. class Bot { … voidUpdateAim(Vector3 target) { aimDirection = Vector3.DotProduct(position, target) * mod; } } class Bots { … staticvoidUpdateAims(List<float> aimDirections, List<Vector3> positions, List<float> mods, List<Vector3> targets) { for (uint i = 0; i < aimDirections.Count; ++i) aimDirections[i] = Vector3.DotProduct(positions[i], targets[i]) * mods[i]; } }
  • 14. Know the data!Think! Think! Think!
  • 15. It’s all about memory Optimize for data not code
  • 16. It’s all about memory Optimize for data not code Most code is mostly bound to memory access
  • 17. It’s all about memory Optimize for data not code Most code is mostly bound to memory access Not everything needs to be an object
  • 19. Data-Oriented Design: Better performance Often simpler code
  • 20. Data-Oriented Design: Better performance Often simpler code More parallelizable code