Array of Structs vs Structs of Arrays

Hi, I have a question about data storing.

I am developing numerical simulator and need to store variables (temporarily) for each iterations. Those variables change in each iterations.

But I am not sure what kind of storing method I should use to have faster processing.

(If I use Array of Structs, Sturcts should be mutable type of structs)

I would love to get some advices about that.

Thank you.

AFAIK, for most cases, a struct of arrays is the most performant, because it will be easier for the compiler to do SIMD.
While one sometimes has arrays of structs as the result of some calculation, it can be useful to convert this datastructure. For this there is the package StructArrays

Note that if you have an array of mutable structs, this is very likely to be slow in particular, because it might be that each element of this array will live at a different location in memory.

A post was split to a new topic: What’s the best way to create a struct of arrays?