JuliaGraphics / ColorTypes.jl

Basic color definitions and traits
Other
77 stars 35 forks source link

Excessive precompilation causes long package load time #269

Closed KristofferC closed 2 years ago

KristofferC commented 2 years ago

This package does an almost combinatorial amount of precompilation. This causes the package to be slow enough to load that one has to think a second time if it is worth adding it as a dependency. At the same time, this package is described as "minimalistic" which doesn't really jive with a 0.3 second load time:

julia> @time using ColorTypes
  0.297764 seconds (672.76 k allocations: 51.498 MiB, 7.03% gc time, 4.14% compilation time)

Removing the precompilation takes it down quite a bit:

julia> @time using ColorTypes
  0.128889 seconds (277.90 k allocations: 17.985 MiB, 6.22% gc time, 8.33% compilation time)

As a reference, we can compare this to loading the whole package manager (of course not using the one in the sysimage):

julia> @time using Pkg
  0.154056 seconds (258.31 k allocations: 17.384 MiB, 6.85% gc time, 51.36% compilation time)

So the minimalistic package for holding some color types takes twice the time to load as the Julia package manager.

This is unfortunate because I presume a lot of people (like me) want to use the package just to hold values of some type but don't really do any computations with them.

Could the amount of precompilation be reduced, or alternatively, could there be an actual minimalistic ColorTypes package that is very quick to load?

johnnychen94 commented 2 years ago

Sounds reasonable enough for me, I'd like to hear what @timholy and @kimikage (if he is still around) think.

The conversions, operations, and traits could be possibly moved to Colors.jl for people who want to do additional computation; then we can make this package only serve for dispatching purposes.

timholy commented 2 years ago

Sure, we can do this. Once https://github.com/JuliaLang/julia/pull/42016 works, it won't be necessary to stash these in this package.

johnnychen94 commented 2 years ago

JuliaHub shows that this package has ~20K downloads per month while Colors has ~10K. This is a large user base, I guess >50% Julia users?

Thus I believe it's worth considering reducing the latency by moving most functionalities to Colors and making ColorTypes a real interface package.

KristofferC commented 2 years ago

I don't think this package needs much explicit precompilation. In 1.8 people should get the methods they use (transitively) anyway from their own precompilation scripts.