I am confused by this. Why would Statistics (or its dependency SparseArrays), a package in the standard library, have such a bad time to import? Anything I can do about this in my package that depends on Statistics? I have been trying to lower its TTFX and this has become a bottleneck. Other standard libraries do not seem to have these issues?
Version 1.9.0-DEV.874 (2022-06-30)
julia> @time_imports using Statistics
2242.3 ms ┌ SparseArrays 5.37% compilation time
2265.5 ms Statistics 6.25% compilation time
Version 1.7.0 (2021-11-30)
julia> @time @eval using Statistics
0.002965 seconds (1.20 k allocations: 85.719 KiB, 92.20% compilation time)
Version 1.8.0-beta3 (2022-03-29)
julia> @time @eval using Statistics
0.002675 seconds (1.16 k allocations: 81.145 KiB, 86.59% compilation time)
This is due to the removal of SparseArrays, Statistics and a few more stdlibs from the sysimage for 1.9. The increase in import time is expected, but understandably frustrating.
One of the most cited reasons is that it allows for faster updating: when they are stdlibs they can only release an update whenever julia publishes a release. More points are explained here, where Viral B. Shah said:
Allow broader participation in these packages from contributors
Faster bugfixing and upgrades without having to wait for whole Julia release cycles
Make them less special and allow for alternatives to evolve, or become more flexible (e.g. we want to support many new sparse data types and solvers in a first class way)
Consolidate capabilities in certain ecosystems (e.g. basic stats is spread out across too many packages like Statistics.jl, StatsBase.jl etc., and it is complex for new users to navigate - not to mention it is difficult to maintain)