Julia Plots package takes a lot of time to load

Viewed 390

I am learning to use the Plots package in Julia. But it takes literally 2 to 3 minutes for it to load and the same is the case with my first plot. All the later ones are fine.

Is there any issue with my package installation or something?

I did have a lot of artifacts downloading errors while installing the Plots package, could that be the reason?

I couldn't find any issue raised regarding the same on Github either. Can anyone help me with this?

1 Answers

The fact that the Plots package took "forever" to load / precompile in julia was really to my dismay and deterred me from trying out julia more.

As pointed out in the comments, there is a long thread here where this is discussed, and alternative packages for plotting (e.g. Gnuplot.jl) are suggested. It is also pointed out that this has improved in the newer releases.

When I compare 1.4.2 and 1.6.1 (the latest stable as of July 2021) on my machine I typically get for 1.4.2

julia> @time using Plots
22.288406 seconds (17.85 M allocations: 979.523 MiB, 2.84% gc time)

julia> @time using Plots
  1.782150 seconds (1.74 M allocations: 81.678 MiB, 8.05% gc time)

julia> @time using Plots
  0.000238 seconds (486 allocations: 25.547 KiB)

julia> @time using Plots
  0.000212 seconds (486 allocations: 25.547 KiB)

(where the time for the first using varies between 18 and 23 seconds), whereas 1.6.1 is significantly faster and uses only half the memory:

julia> @time using Plots
  4.860129 seconds (6.87 M allocations: 502.634 MiB, 7.64% gc time, 0.14% compilation time)

julia> @time using Plots
  0.000099 seconds (81 allocations: 5.969 KiB)

julia> @time using Plots
  0.000094 seconds (81 allocations: 5.969 KiB)

with the time for the first using varying between 4 and 6 seconds (and already the second using is as fast as the third; I'll leave it to more experienced people to comment on this). This is definitely an improvement.

Related