# Why StaticArrays are not recommended for large Arrays?

**URL:** <https://discourse.julialang.org/t/why-staticarrays-are-not-recommended-for-large-arrays/31041>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 13, 2019, 1:43pm UTC](https://discourse.julialang.org/t/why-staticarrays-are-not-recommended-for-large-arrays/31041 "2019-11-13T13:43:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [November 13, 2019, 1:43pm UTC](https://discourse.julialang.org/t/why-staticarrays-are-not-recommended-for-large-arrays/31041/1 "2019-11-13T13:43:39Z")

</div>

There is a warning that one should not use `StaticArray` for very large arrays:

> Note that in the current implementation, working with large `StaticArray` s puts a lot of stress on the compiler, and becomes slower than `Base.Array` as the size increases. A very rough rule of thumb is that you should consider using a normal `Array` for arrays larger than 100 elements.

Why so? What is the intrinsic limitation that hurts the performance of large `StaticArray`?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [November 13, 2019, 3:44pm UTC](https://discourse.julialang.org/t/why-staticarrays-are-not-recommended-for-large-arrays/31041/2 "2019-11-13T15:44:20Z")

</div>

AFAIK there are two reasons:

1. each dimension & type combination is its own type, which entails a compilation cost

2. loops start to dominate unrolled calculations

For actual code, it is always best to just benchmark.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [November 13, 2019, 3:46pm UTC](https://discourse.julialang.org/t/why-staticarrays-are-not-recommended-for-large-arrays/31041/3 "2019-11-13T15:46:21Z")

</div>

> [@e3c6](#):
>
> Why so? What is the intrinsic limitation that hurts the performance of large `StaticArray` ?

A `NTuple{N, T}` is treated the same as `Tuple{T, T, T, T, T, ...}`. Type computations then become very expensive as `N` becomes large. [WIP: Give NTuple{N, T} a layout by Keno · Pull Request #31681 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/31681) is some WIP to handle that (AFAIU).
