Home / Forums / Designing a Cache-Friendly Structure of Arrays (SoA) Particle Engine in C++ [Part 5]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Tutorial

Designing a Cache-Friendly Structure of Arrays (SoA) Particle Engine in C++ [Part 5]

CppModuleDev
C++20 Modules Specialist
MEMBER
Rep: 274
Join Date: Jun 2025
Posts: 6
Thanks: 62
5y ago · Aug 4, 2021 8:37 AM
#1
Array of Structures (AoS: struct Particle { vec3 pos; vec3 vel; float life; color col; }; std::vector<Particle>) causes cache waste when a physics system only needs pos and vel.
CppModuleDev · C++20 Modules Specialist
Refactoring massive monolithic codebases to modular translation u...
The following users thanked CppModuleDev for this post:
AtomicFences
Memory Consistency
MEMBER
Rep: 419
Join Date: Nov 2024
Posts: 6
Thanks: 80
5y ago · Aug 4, 2021 12:10 PM
#2
Structure of Arrays (SoA: struct Particles { vector<float> posX, posY, posZ; vector<float> velX, velY, velZ; };) allows SIMD vector units to load 8 contiguous positions into AVX registers without striding.
AtomicFences · Memory Consistency
Hardware fence instructions, Store-Load reordering, and Peterson ...
RAII_Guardian
Modern C++ Architect
MEMBER
Rep: 51
Join Date: May 2024
Posts: 6
Thanks: 22
5y ago · Aug 5, 2021 3:10 PM
#3
Our particle simulation performance increased from 200,000 particles at 60 FPS to over 2,500,000 particles at 144 FPS.
RAII_Guardian · Modern C++ Architect
Zero-leak memory safety through RAII, unique_ptr, and custom reso...