An introduction to Data Oriented Design with Rust
source : An introduction to Data Oriented Design with Rust - Statistically Insignificant
tags : [[Rust]]
Notes
[[Data-oriented design]] is a programming paradigm whereby the layout of data structures is strongly considered for performance reasons.
In a [[object-oriented]] approach, the code for a player might look like this:
pub struct Player {
name: String,
health: f64,
location: (f64, f64),
velocity: (f64, f64),
acceleration: (f64, f64),
}
whereas in DOD, it would look like this:
pub struct DOPlayers {
names: Vec<String>,
health: Vec<f64>,
locations: Vec<(f64, f64)>,
velocities: Vec<(f64, f64)>,
acceleration: Vec<(f64, f64)>,
}
This would increase performance dramatically because weβre better using the CPU cache. The article has some good statistics on this.
Loading context... (requires JavaScript)
ποΈ Stoas for [[20210721220318 an_introduction_to_data_oriented_design_with_rust]]
π Open document (Hedgedoc) at https://doc.anagora.org/20210721220318-an_introduction_to_data_oriented_design_with_rust
π Open document (Etherpad) at https://stoa.anagora.org/p/20210721220318-an_introduction_to_data_oriented_design_with_rust
π Full text search for [[20210721220318 an_introduction_to_data_oriented_design_with_rust]]