Slower with threads

  1. You want static arrays wherever you create lots of them in a loop. They won’t incur allocations because their size is known so they’re put on the stack.
  2. You can’t modify static arrays, but usually you can store a completely new static array where some values are different than in the previous version, and this is usually fast because, again, no allocation is needed. The compiler is pretty smart about making such things fast. You could look at GitHub - JuliaObjects/Accessors.jl: Update immutable data for example which helps with that.
  3. Sparse arrays are something very different. There the optimization is that most elements are zero, so only the non-zero elements are saved with their positions in the array.
  4. MMatrix is slower than SMatrix, the mutability prohibits some performance optimizations.