This stands out to me as an easy thing to improve. You’re returning two values (which is fine), but you’re returning them by constructing an
Array to hold those two elements. Constructing a new
Array is rather expensive (if you do it a million times, at least), and that’s one of your sources of frequent allocations.
Instead, you can return a
Tuple, which is basically free to construct. That would look like:
return vec, dOmega
(vec, dOmega) because the parentheses are optional here