https://github.com/jamesmcm/data-oriented-example
Example of Data Oriented Design in Rust
https://github.com/jamesmcm/data-oriented-example
rust
Last synced: over 1 year ago
JSON representation
Example of Data Oriented Design in Rust
- Host: GitHub
- URL: https://github.com/jamesmcm/data-oriented-example
- Owner: jamesmcm
- Created: 2020-07-14T21:11:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-26T10:17:57.000Z (almost 6 years ago)
- Last Synced: 2024-10-13T13:27:01.636Z (over 1 year ago)
- Topics: rust
- Language: Rust
- Size: 9.77 KB
- Stars: 50
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# data-oriented-example
Experimenting with [Data Oriented Design](https://en.wikipedia.org/wiki/Data-oriented_design) in Rust.
Written for this blog post: http://jamesmcm.github.io/blog/2020/07/25/intro-dod/#en
Done:
* Benchmark of [Array of Structs vs. Struct of Arrays](https://en.wikipedia.org/wiki/AoS_and_SoA)
SoA gets unrolled by compiler, results in ~50% speed up.
Godbolt: https://godbolt.org/z/d8bjMb
* Benchmark of pattern matching inside hot loop vs. outside
Outside results in 50% speed up.
* Benchmark of Linked List iteration vs. contiguous Vector
Vector shows consistent 90% speed up vs. Linked List iteration
* Benchmark of dynamic dispatch vs. monomorphisation
Dynamic dispatch impedes vectorisation due to indirection, otherwise
cost of lookup in vtable is small