Description
StaticArrays (together with ArraysInterface) seems to be a driving factor in package load times nowadays. For example, the load time of FiniteDiff, FiniteDifferences and ForwardDiff (common direct/indirect dependencies themselves) themselves is mainly due to StaticArrays (and ArrayInterface):
julia> @time_imports using FiniteDiff
3.3 ms ┌ Compat
0.5 ms ┌ Requires
548.3 ms ┌ StaticArrays
0.2 ms ┌ IfElse
33.7 ms ┌ Static
737.6 ms ┌ ArrayInterface
1312.8 ms FiniteDiff
julia> @time_imports using FiniteDifferences
3.6 ms ┌ Compat
0.4 ms ┌ Richardson
539.9 ms ┌ StaticArrays
62.7 ms ┌ ChainRulesCore
617.1 ms FiniteDifferences
julia> @time_imports using ForwardDiff
538.5 ms ┌ StaticArrays
548.4 ms ┌ DiffResults
4.1 ms ┌ Compat
0.4 ms ┌ NaNMath
60.8 ms ┌ ChainRulesCore
62.0 ms ┌ ChangesOfVariables
0.7 ms ┌ OpenLibm_jll
3.0 ms ┌ DocStringExtensions
4.6 ms ┌ IrrationalConstants
0.6 ms ┌ CompilerSupportLibraries_jll
1.4 ms ┌ LogExpFunctions
18.9 ms ┌ Preferences
19.8 ms ┌ JLLWrappers
23.9 ms ┌ OpenSpecFun_jll
37.6 ms ┌ SpecialFunctions
10.3 ms ┌ MacroTools
11.0 ms ┌ CommonSubexpressions
0.8 ms ┌ DiffRules
845.2 ms ForwardDiff
Even the load time of a "large" package like Optim is completely dominated by StaticArrays and ArrayInterface (indirectly, via FiniteDiff and ForwardDiff):
julia> @time using StaticArrays
0.565813 seconds (2.21 M allocations: 175.407 MiB, 0.51% compilation time)
julia> @time using ArrayInterface
0.786209 seconds (697.28 k allocations: 38.650 MiB, 4.49% gc time, 89.27% compilation time)
julia> @time using FiniteDiff
0.037383 seconds (46.28 k allocations: 2.584 MiB, 77.77% compilation time)
julia> @time using ForwardDiff
0.199031 seconds (543.28 k allocations: 35.849 MiB, 2.18% compilation time)
julia> @time using Optim
0.302545 seconds (730.67 k allocations: 53.416 MiB)
There's currently and effort to make ArrayInterface more lightweight by splitting it up (JuliaArrays/ArrayInterface.jl#211) - I wonder if the same would be possible for StaticArrays? Would something like an AbstractStaticArrays be enough for packages like the above? I think at least some of them only "support" static arrays but don't use them for their core functionality (I may be wrong).