SoA Data Layout
Structure of Arrays (SoA) is a data layout pattern that separates fields of the same kind into individual contiguous arrays rather than bundling all fields together in a single object. Where AoS (Array of Structures) creates an "array of particle objects" like `Particle[]`, SoA creates a "bundle of per-attribute arrays" like `x[]`, `y[]`, `vx[]`, `vy[]`.
Β· Practice memo Β· 23 min read Β· Hard
SoA (Structure of Arrays) is a data layout pattern that separates fields of the same kind into individual contiguous arrays rather than bundling all fields into a single object. Where AoS (Array of Structures) creates an "array of particle objects" like Particle[], SoA creates a "bundle of per-field arrays" like x[], y[], vx[], vy[].
The pattern exists to separate the domain model from the execution model: the domain model has to stay easy for a person to read, while the execution model has to be something the CPU can sweep through fast. In an object model, putting x, y, vx, vy, color, debugName and renderHandle all into one Particle is comfortable to read, but the position-update pass only really needs x, y, vx, vy.
SoA is fast not merely because it "reduces cache misses": once fields of the same kind sit in contiguous arrays, the CPU and the compiler find SIMD β vector work that processes several values at once β easier to apply. AoS interleaves the data as x1, y1, vx1, vy1, x2, y2, vx2, vy2, while in SoA x1, x2, x3, x4 run consecutively, and that difference shows up in instruction throughput as well as in cache locality.
SoA is powerful, but the reverse holds if you edit individual objects often, keep the data count small, sit on an I/O bottleneck, or read nearly every field of an object in one pass: the traditional AoS can be simpler and fast enough. Plenty of people read SoA as "throw object orientation away", when it really means "on the hot path, lay the data out in the order the pass actually reads the fields".
Core formula:
SoA = laying out the same fields together in contiguous arrays
Cache Locality = loading only the data you need into cache
SIMD Friendliness = making it easy to apply the same operation across contiguous data
Dense Pass = a linear traversal over the range 0..count with no branches
Swap-remove = making deletion close to O(1) when order doesn't matter1. When should you use it?
Say you update the positions of 100,000 particles every frame.
x = x + vx * dt
y = y + vy * dtThe pass needs neither the particle's name, its color, the render handle nor the debug tag β all it needs is x, y, vx, vy.
An AoS version usually looks like this.
particles = [
{ x, y, vx, vy, color, debugName, renderHandle },
{ x, y, vx, vy, color, debugName, renderHandle },
...
]The same data, laid out as SoA:
positionsX[]
positionsY[]
velocitiesX[]
velocitiesY[]In SoA the position-update pass just sweeps the arrays it needs and is done.
positionsX[i] += velocitiesX[i] * dt
positionsY[i] += velocitiesY[i] * dtShifting focus from "what an object is" to "what a pass reads" is more than learning a memory trick β it is the philosophical turning point that reformats a programmer's mental model from 'Human-centric' to 'Hardware-centric'.
Object-oriented programming (OOP) sees the world as nouns: it groups it into conceptual units such as 'Particle', 'Player', 'Enemy'. That is why bundling them into a single class or struct in memory feels natural, and why people say such a unit has semantic cohesion. The CPU does not think that way; it just runs.
AoS (object-centric): when the position-update pass reads
particle1.x, the cache line dragsparticle1's garbage (color, render handle, and so on) along with it. In object-array or pointer-based layouts the next particle sits somewhere else on the heap and the prefetcher cannot follow; even in a contiguous struct array the cold fields outnumber the hot ones, so cache bandwidth is wasted.SoA (pass-centric): once a pass reads only
x[]andvx[]linearly, the prefetcher does its job properly: while the CPU computes, the next few dozen elements are already being delivered into L1 cache in the background, so perceived memory latency is close to the floor.
Note that even AoS splits into two cases. Objects stored inline and contiguous, as in a C/Rust/C# struct array, differ from an AoS that follows references, as in a JavaScript object array or a C# class array. The former has a regular stride so the prefetcher keeps up to a point, but hot and cold fields still share a cache line; the latter tends to scatter objects across the heap, which is worse on both locality and prefetch. In practice you do not need to know the layout to that level of detail β knowing where to compromise is a skill too. People usually come to SoA through game examples such as a small Rust engine or Unity's ECS, so the examples here are game-flavored as well.
2. Core expressions
The example is the same everywhere: store particle positions and velocities in SoA, run one frame of position update, and only the language changes.
C#
using System;
using System.Numerics;
public sealed class ParticleSoa
{
private readonly float[] positionsX;
private readonly float[] positionsY;
private readonly float[] velocitiesX;
private readonly float[] velocitiesY;
private int count;
public ParticleSoa(int capacity)
{
if (capacity <= 0)
{
throw new ArgumentOutOfRangeException(nameof(capacity));
}
this.positionsX = new float[capacity];
this.positionsY = new float[capacity];
this.velocitiesX = new float[capacity];
this.velocitiesY = new float[capacity];
this.count = 0;
}
public int GetCount()
{
return this.count;
}
public int Add(float x, float y, float vx, float vy)
{
if (this.count >= this.positionsX.Length)
{
throw new InvalidOperationException("Insufficient particle storage capacity.");
}
int index = this.count;
this.positionsX[index] = x;
this.positionsY[index] = y;
this.velocitiesX[index] = vx;
this.velocitiesY[index] = vy;
this.count += 1;
return index;
}
public void Update(float deltaTime)
{
Span<float> x = this.positionsX.AsSpan(0, this.count);
Span<float> y = this.positionsY.AsSpan(0, this.count);
ReadOnlySpan<float> vx = this.velocitiesX.AsSpan(0, this.count);
ReadOnlySpan<float> vy = this.velocitiesY.AsSpan(0, this.count);
int width = Vector<float>.Count;
Vector<float> dt = new(deltaTime);
int index = 0;
for (; index <= this.count - width; index += width)
{
Vector<float> xVector = new(x.Slice(index, width));
Vector<float> yVector = new(y.Slice(index, width));
Vector<float> vxVector = new(vx.Slice(index, width));
Vector<float> vyVector = new(vy.Slice(index, width));
(xVector + vxVector * dt).CopyTo(x.Slice(index, width));
(yVector + vyVector * dt).CopyTo(y.Slice(index, width));
}
for (; index < this.count; index += 1)
{
x[index] += vx[index] * deltaTime;
y[index] += vy[index] * deltaTime;
}
}
public (float X, float Y) GetPosition(int index)
{
this.EnsureValidIndex(index);
return (this.positionsX[index], this.positionsY[index]);
}
private void EnsureValidIndex(int index)
{
if ((uint)index >= (uint)this.count)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
}
}In C# you can make SIMD intent explicit with Vector<float>, though the actual vector width depends on the runtime and the CPU. On a numeric hot path, look at System.Numerics, Span<T>, ArrayPool<T> or lower-level intrinsics.
TypeScript
export class ParticleSoa
{
readonly #positionsX: Float32Array;
readonly #positionsY: Float32Array;
readonly #velocitiesX: Float32Array;
readonly #velocitiesY: Float32Array;
#count: number;
public constructor(capacity: number)
{
if (!Number.isInteger(capacity) || capacity <= 0) {
throw new RangeError("`capacity` must be a positive integer (β₯ 1).");
}
this.#positionsX = new Float32Array(capacity);
this.#positionsY = new Float32Array(capacity);
this.#velocitiesX = new Float32Array(capacity);
this.#velocitiesY = new Float32Array(capacity);
this.#count = 0;
}
public getCount(): number
{
return this.#count;
}
public add(x: number, y: number, vx: number, vy: number): number
{
if (this.#count >= this.#positionsX.length) {
throw new RangeError("Insufficient particle storage capacity.");
}
const index = this.#count;
this.#positionsX[index] = x;
this.#positionsY[index] = y;
this.#velocitiesX[index] = vx;
this.#velocitiesY[index] = vy;
this.#count += 1;
return index;
}
public update(deltaTime: number): void
{
for (let index = 0; index < this.#count; index += 1) {
this.#positionsX[index] += this.#velocitiesX[index] * deltaTime;
this.#positionsY[index] += this.#velocitiesY[index] * deltaTime;
}
}
public getPosition(index: number): readonly [number, number]
{
this.#ensureValidIndex(index);
return [this.#positionsX[index], this.#positionsY[index]];
}
#ensureValidIndex(index: number): void
{
if (!Number.isInteger(index) || index < 0 || index >= this.#count) {
throw new RangeError("`index` is not valid.");
}
}
}In TypeScript, Float32Array expresses SoA intent well. What the JavaScript engine optimizes internally varies by runtime, so the first goal is a predictable typed-array layout rather than direct SIMD.
Python
from array import array
class ParticleSoa:
def __init__(self, capacity: int) -> None:
if capacity <= 0:
raise ValueError("capacity must be at least 1.")
self._positions_x = array("f", [0.0]) * capacity
self._positions_y = array("f", [0.0]) * capacity
self._velocities_x = array("f", [0.0]) * capacity
self._velocities_y = array("f", [0.0]) * capacity
self._count = 0
def get_count(self) -> int:
return self._count
def add(self, x: float, y: float, vx: float, vy: float) -> int:
if self._count >= len(self._positions_x):
raise OverflowError("The particle storage capacity is insufficient.")
index = self._count
self._positions_x[index] = x
self._positions_y[index] = y
self._velocities_x[index] = vx
self._velocities_y[index] = vy
self._count += 1
return index
def update(self, delta_time: float) -> None:
for index in range(self._count):
self._positions_x[index] += self._velocities_x[index] * delta_time
self._positions_y[index] += self._velocities_y[index] * delta_time
def get_position(self, index: int) -> tuple[float, float]:
self._ensure_valid_index(index)
return (self._positions_x[index], self._positions_y[index])
def _ensure_valid_index(self, index: int) -> None:
if index < 0 or index >= self._count:
raise IndexError("index is invalid.")With only the Python standard library, array gives you an SoA shape, but genuinely fast large-scale numerical work usually means reaching for NumPy, Numba, Cython or a Rust/C extension. Even with a better layout, a pure Python loop can stay interpreter-bound.
Rust
#[derive(Debug)]
pub struct ParticleSoa {
positions_x: Vec<f32>,
positions_y: Vec<f32>,
velocities_x: Vec<f32>,
velocities_y: Vec<f32>,
count: usize,
}
impl ParticleSoa {
pub fn new(capacity: usize) -> Self {
assert!(capacity > 0, "capacity must be 1 or greater.");
Self {
positions_x: vec![0.0; capacity],
positions_y: vec![0.0; capacity],
velocities_x: vec![0.0; capacity],
velocities_y: vec![0.0; capacity],
count: 0,
}
}
pub fn get_count(&self) -> usize {
self.count
}
pub fn add(&mut self, x: f32, y: f32, vx: f32, vy: f32) -> usize {
assert!(
self.count < self.positions_x.len(),
"Particle storage capacity is insufficient."
);
let index = self.count;
self.positions_x[index] = x;
self.positions_y[index] = y;
self.velocities_x[index] = vx;
self.velocities_y[index] = vy;
self.count += 1;
index
}
pub fn update(&mut self, delta_time: f32) {
let positions_x = &mut self.positions_x[..self.count];
let positions_y = &mut self.positions_y[..self.count];
let velocities_x = &self.velocities_x[..self.count];
let velocities_y = &self.velocities_y[..self.count];
for (((x, y), vx), vy) in positions_x
.iter_mut()
.zip(positions_y.iter_mut())
.zip(velocities_x.iter())
.zip(velocities_y.iter())
{
*x += *vx * delta_time;
*y += *vy * delta_time;
}
}
pub fn get_position(&self, index: usize) -> Option<(f32, f32)> {
if index >= self.count {
return None;
}
Some((self.positions_x[index], self.positions_y[index]))
}
}In Rust, reaching into several arrays by the same index is not automatically bad β LLVM may drop the bounds checks. In a hot loop, though, iterating with zip makes the length relationships easier for the compiler to see, which raises the odds of bounds-check elimination and vectorization; that difference matters most in loops that touch several slices at the same index.
3. Call site
The call site never touches the SoA's internal arrays; separation of concerns and information hiding is why, so creation policy, adding data, the update pass and result queries each keep their own responsibility.
type SpawnParticle = Readonly<{
x: number;
y: number;
vx: number;
vy: number;
}>;
type FramePolicy = Readonly<{
deltaTime: number;
maxParticles: number;
}>;
function createParticleStore(
particles: readonly SpawnParticle[],
policy: FramePolicy,
): ParticleSoa
{
if (particles.length > policy.maxParticles) {
throw new RangeError("The initial particle count exceeded `maxParticles`.");
}
const store = new ParticleSoa(policy.maxParticles);
for (const particle of particles) {
store.add(particle.x, particle.y, particle.vx, particle.vy);
}
return store;
}
function simulateOneFrame(
store: ParticleSoa,
policy: FramePolicy,
): void
{
store.update(policy.deltaTime);
}
const particles = createParticleStore(
[
{ x: 0, y: 0, vx: 10, vy: 0 },
{ x: 5, y: 5, vx: 0, vy: -2 },
],
{ deltaTime: 0.016, maxParticles: 1024 },
);
simulateOneFrame(particles, { deltaTime: 0.016, maxParticles: 1024 });
console.log(particles.getPosition(0));Separation of responsibilities:
SpawnParticle = External input DTO
FramePolicy = Per-frame execution policy
createParticleStore = Input validation and SoA initialization
ParticleSoa = Memory layout and update pass ownership
simulateOneFrame = Frame flow assembly4. Reading order
What fields does this pass actually read?
β Are the same fields grouped together in contiguous arrays?
β Does the loop traverse the 0..count range linearly?
β Are there branches remaining inside the hot loop?
β Is the shape amenable to SIMD or auto-vectorization?
β Does the external interface expose only safe methods instead of raw arrays?
β Do layout changes leak out to call sites?SoA code should be read around which arrays a single pass consumes, not around a single object.
5. Boundaries and misconceptions
SoA is a layout for bulk repeated computation: if you edit particles one at a time, if the domain logic leans hard on per-object invariants, or if the data count is small, AoS is worth a look. SoA is not encapsulation sacrificed for speed; it is a different kind of encapsulation β change the internal layout, keep the external API safe.
Lumping the benefits of SoA into one sentence hides them. Reading only the fields you need, contiguously, can improve cache locality, and running the same operation over contiguous arrays of the same type makes SIMD and auto-vectorization worth aiming at; drop that second half and the explanation of SoA is only half done.
Auto-vectorization is not a guarantee, though: branches, aliasing, bounds checks, function calls, unclear length relationships, the chance of exceptions, runtime type uncertainty β any one of those is enough to shut vectorization down. SoA is only the shape that makes vectorization possible, not a spell that guarantees SIMD on every compiler and runtime.
Keep what the domain can predict separate from what makes the system fall over. Exceeding capacity is a domain/policy problem; a failed large typed-array allocation, running out of memory, a runtime abort β those are infrastructure problems. SoA code usually sits on the hot path, so rather than paying for expensive exception handling or dynamic type checks on every iteration, finish validation at construction time and at the boundaries.
Production failure cases:
SoA internal arrays drift to different lengths, breaking the index invariant
Exposing raw arrays externally allows arbitrary modifications
During add/remove, only some arrays get updated, causing data misalignment
Even when most entries have `active=false`, the full capacity is iterated every frame
Too many branches inside the hot loop interfere with branch prediction and vectorization
In Rust, accessing multiple arrays by index may prevent bounds check elimination
Calling `getParticleObject()` in bulk inside a loop for debugging convenience
Replacing all data structures with SoA without any performance measurement6. Bad examples
type Particle = {
x: number;
y: number;
vx: number;
vy: number;
color: string;
debugName: string;
renderHandle: object;
active: boolean;
};
function updateParticlesBad(
particles: Particle[],
deltaTime: number,
): void
{
for (const particle of particles) {
if (!particle.active) {
continue;
}
particle.x += particle.vx * deltaTime;
particle.y += particle.vy * deltaTime;
}
}Why it's bad:
- `color`, `debugName`, and `renderHandle`, which the update pass never writes, are mixed into the same object.
- The loop only needs `x`/`y`/`vx`/`vy`, yet it accesses data object by object.
- With large datasets, the cost of per-object access and reference tracking can grow significantly.
- The active branch remains inside the hot loop.
- Because the data is interleaved, the layout is not SIMD-friendly for processing only `x` values in a contiguous sequence.
- Data with different lifetimes, such as render handles and debug names, are physically bundled together.As with any code, the right answer depends on the scale of the program, and the snippet above is perfectly good when the particle count is small and edits are frequent. The real damage happens on a specific hot path that physically binds data it never reads or writes β data with a different lifetime and purpose β to the data it does compute on, burning CPU cache bandwidth for nothing.
7. Production scaling
7.1 Active index pattern
Once active=false entries pile up, walking the whole array every time is wasted work too. In that case add one more array to the SoA β an active index array β and iterate only the indices you actually update.
export class ActiveIndexParticleSoa
{
readonly #positionsX: Float32Array;
readonly #positionsY: Float32Array;
readonly #velocitiesX: Float32Array;
readonly #velocitiesY: Float32Array;
readonly #activeIndexes: Uint32Array;
#count: number;
#activeCount: number;
public constructor(capacity: number)
{
if (!Number.isInteger(capacity) || capacity <= 0) {
throw new RangeError("capacity must be an integer greater than or equal to 1.");
}
this.#positionsX = new Float32Array(capacity);
this.#positionsY = new Float32Array(capacity);
this.#velocitiesX = new Float32Array(capacity);
this.#velocitiesY = new Float32Array(capacity);
this.#activeIndexes = new Uint32Array(capacity);
this.#count = 0;
this.#activeCount = 0;
}
public add(x: number, y: number, vx: number, vy: number): number
{
if (this.#count >= this.#positionsX.length) {
throw new RangeError("Insufficient particle storage capacity.");
}
const index = this.#count;
this.#positionsX[index] = x;
this.#positionsY[index] = y;
this.#velocitiesX[index] = vx;
this.#velocitiesY[index] = vy;
this.#activeIndexes[this.#activeCount] = index;
this.#count += 1;
this.#activeCount += 1;
return index;
}
public updateActive(deltaTime: number): void
{
for (let cursor = 0; cursor < this.#activeCount; cursor += 1) {
const index = this.#activeIndexes[cursor];
this.#positionsX[index] += this.#velocitiesX[index] * deltaTime;
this.#positionsY[index] += this.#velocitiesY[index] * deltaTime;
}
}
public getActiveCount(): number
{
return this.#activeCount;
}
}It is a win for skipping dead particles, but the indirect access through activeIndexes stays. That pays off while the active ratio is low; as it climbs, this can end up slower than a plain dense-array walk.
7.2 When order doesn't matter: swap-remove dense array
When order does not matter in a particle system, a stronger optimization opens up: instead of marking dead particles inactive, move the last live element into the deleted slot and decrement count, so the 0..count range always stays packed with live particles.
export class DenseParticleSoa
{
readonly #positionsX: Float32Array;
readonly #positionsY: Float32Array;
readonly #velocitiesX: Float32Array;
readonly #velocitiesY: Float32Array;
#count: number;
public constructor(capacity: number)
{
if (!Number.isInteger(capacity) || capacity <= 0) {
throw new RangeError("`capacity` must be a positive integer greater than or equal to 1.");
}
this.#positionsX = new Float32Array(capacity);
this.#positionsY = new Float32Array(capacity);
this.#velocitiesX = new Float32Array(capacity);
this.#velocitiesY = new Float32Array(capacity);
this.#count = 0;
}
public add(x: number, y: number, vx: number, vy: number): number
{
if (this.#count >= this.#positionsX.length) {
throw new RangeError("Insufficient capacity in the particle storage.");
}
const index = this.#count;
this.#positionsX[index] = x;
this.#positionsY[index] = y;
this.#velocitiesX[index] = vx;
this.#velocitiesY[index] = vy;
this.#count += 1;
return index;
}
public removeSwap(index: number): void
{
this.#ensureValidIndex(index);
const last = this.#count - 1;
this.#positionsX[index] = this.#positionsX[last];
this.#positionsY[index] = this.#positionsY[last];
this.#velocitiesX[index] = this.#velocitiesX[last];
this.#velocitiesY[index] = this.#velocitiesY[last];
this.#count -= 1;
}
public update(deltaTime: number): void
{
for (let index = 0; index < this.#count; index += 1) {
this.#positionsX[index] += this.#velocitiesX[index] * deltaTime;
this.#positionsY[index] += this.#velocitiesY[index] * deltaTime;
}
}
public getCount(): number
{
return this.#count;
}
#ensureValidIndex(index: number): void
{
if (!Number.isInteger(index) || index < 0 || index >= this.#count) {
throw new RangeError("`index` is invalid.");
}
}
}What this buys you:
- No `isActive` array needed.
- No indirect access through `activeIndexes` needed.
- The `0..count` range is always dense.
- No active branch inside the update loop.
- The layout becomes more amenable to SIMD and branch prediction.The trade-offs come with it:
The order changes on deletion.
If external code holds an index as a handle, it can become invalid.
If there is an `entityId` β `index` map, the map must also be updated when swapping.
This approach may be unsuitable for UI lists, replay logs, or deterministic serialization where stable ordering is required.Operational rules of thumb:
Order doesn't matter β swap-remove dense array
Order matters β stable compaction or activeIndexes
Deletions are rare β a simple isActive branch may suffice
Deletions are frequent and active entries are few β consider activeIndexes or dense compactionProduction metric setup:
particle.count
particle.capacity
particle.update.duration_ms
particle.items_per_ms
particle.remove.count
particle.swap_remove.count
particle.capacity_utilizationDo not apply SoA on gut feel. Programming by intuition is comfortable, but measuring as you go is the right way; adding complexity on purpose only to suffer in maintenance is a cost you pay yourself. Compare AoS, SoA, active index and swap-remove under the same input size, the same active ratio and the same runtime conditions.
8. Comparison notes: C# / TypeScript / Python / Rust
Language | Idiomatic expression | Caution |
|---|---|---|
C# |
| Do not expose internal arrays directly to the outside |
TypeScript |
| Do not assume SIMD is automatically guaranteed |
Python |
| Pure Python loops carry significant interpreter overhead |
Rust |
| In hot loops, check whether multi-index access on multiple arrays may fail to eliminate bounds checks |
- Language
C#
- Idiomatic expression
float[],Span<T>,Vector<T>,ArrayPool<T>- Caution
Do not expose internal arrays directly to the outside
- Language
TypeScript
- Idiomatic expression
Float32Array,Uint8Array,Uint32Array- Caution
Do not assume SIMD is automatically guaranteed
- Language
Python
- Idiomatic expression
array,memoryview, NumPy- Caution
Pure Python loops carry significant interpreter overhead
- Language
Rust
- Idiomatic expression
Vec<f32>, slice, iteratorzip- Caution
In hot loops, check whether multi-index access on multiple arrays may fail to eliminate bounds checks
In Rust, look hard at code that indexes several arrays at once with for index in 0..count. It is safe, but in a hot loop the bounds checks stay or vectorization gets blocked, so slicing to [..count] to match lengths and iterating with iter_mut().zip(...) is the better shape β the compiler reads the length relationships more easily.
In C#, Vector<T> makes SIMD intent explicit, but real performance depends on the CPU, the JIT, data alignment and loop shape. In TypeScript the point is stabilizing the memory layout with Float32Array, and in Python, if you genuinely need numerical speed, moving to a vectorization library like NumPy is usually the realistic answer.
Learning a language, as Alan Perlis put it, means taking that language's philosophy into yourself. Mimic a Rust-style ownership model in TypeScript, expect C-level speed from a plain Python loop, wrap everything in objects in C# and call it SoA β that is just a pattern diagrammed on paper, so go back and study it again.
That said, framing it this way makes it sound harder than it is. The only thing you really need to understand is that the domain model (Object) and the execution model (Pass) should be distinct. The Gather/Scatter pattern is commonly used to bridge these two models, but I won't cover it here. I'll write about it when I have time.
Personal note: in the end the essence of SoA is cutting the forced union of 'data for the machine (execution model)' and 'data for the human (domain model)'. Cramming everything into a single Object is violence β it imposes the structure of the human brain on the CPU.
9. Further questions to consider
Does this pass really need the whole object, or only a few specific field arrays?
Is the SoA win cache locality, the chance of SIMD, or branch removal?
When the active ratio drops, which fits best:
isActive[],activeIndexes[], or swap-remove?Is this data fine to reorder, or is stable order a domain requirement?
Have you compared the Rust index loop and the iterator zip in an actual benchmark?
What API gives you enough testing and debugging without handing out the internal SoA arrays?
Does this optimization shrink the real bottleneck, or only add code complexity?
10. Summary
SoA stores data per field in contiguous arrays, not per object.
The SoA win is not just cache locality; the SIMD/auto-vectorization potential comes with it.
In a hot loop, cutting branches, bounds checks, indirect access and allocation comes first.
In Rust, slice + iterator zip can optimize better than reaching into several arrays with one index.
For a particle system where order does not matter, keeping the array always dense with swap-remove is a strong option.
SoA is only an internal execution layout, so the external API still has to be encapsulated.
Quick reference:
Arrange data not by object, but in the order that each pass reads its fields, and where possible, push it through dense loops with no branches.