Package loading time increases dramatically when changing Julia DEPOT_PATH

Viewed 108

I'm new to Julia and, after a suggestion, I started using nightly build 1.6.0-DEV.1371 due to the high loading time of packages in Julia 1.5.2.

So I tried to change the default directory of DEPOT_PATH and copied all files from ~/.julia to /opt/julia (owned by my user). Now, if I start Julia using the default directory and run the code below, it takes about 4 seconds. However, when I start julia in the new directory (JULIA_DEPOT_PATH=/opt/julia julia), the same code takes incredible 83 seconds. The same happens with Julia 1.5.2 (17s in the default directory, 200s in the new directory).

This is the code I'm using to measure the time.

t = time(); using Plots; time() - t

Is there some explanation about this strange (and annoying) behavior?


My Platform Info:

Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)

And I'm using a SSD.

1 Answers

There is a good chance that now you are having files from your previous Julia installation with the new Julia's JULIA_DEPOT_PATH. The normal approach is to set JULIA_DEPOT_PATH to an empty folder and then install them there.

Regarding startup times there are the following things you can do:

  1. Precompile package (this is also happening when you use a new version of the package for the first time)
using Pkg
pkg"precompile"

Once Plots is precompiled it still takes around 10s to load each time.

  1. If the above time is unacceptable build-in your Plots into Julia system image.
using PackageCompiler
create_sysimage(:Plots, sysimage_path="sys_plots.so", precompile_execution_file="precompile_plots.jl")

For the precompile_plots.jl you could use commands that you use regularly or perhaps test sets from Plots.jl.

Once done you will be starting Julia with the following comand:

julia --sysimage sys_plots.so

Building the system image takes long, however once done, loading Plots.jl will be a matter of milliseconds.

More information can be found here:

Related