Is it correct that it recompiles packages every time a new REPL is opened?

E.g. the first time you use plots.jl after opening a new REPL it has to recompile. I was thinking that since the code is unchanged, shouldn’t it just use the old compiled version? Is it going to always recompile, or is there something about the dependencies for plots.jl that it thinks the version it compiled 20 minutes ago is out of date? Is there some way I can have a chunk of code that doesn’t recompile with every new REPL I open, and only recompile the sub-module I’m currently developing?

There are two things going on that might give you a noticable lag:

  1. precompilation, which results in a lag when you just load packages (eg using Something). This is cached, with improvements in 1.3 (eg if you pkg> activate different environments).

  2. AOT compilation, when you call a function with given types for the first time. This information is lost every time you restart — there are workarounds, but they are work in progress.

Also, are you aware of

? Most Julia users use it to alleviate the necessity to restart so often.

Precompilation only happens when the package version changes. The issue with Plots is something separate.

Additionally, you may try compile_incremental with PackageCompiler.jl to build the packages into a new system image you may use: https://github.com/JuliaLang/PackageCompiler.jl

A significant number if causes of this are fixed in julia 1.3

1 Like

Packages can also get re-precompiled when used in a different environment (same version of the package), a big pain point for me when using the recommended “individual environments for different projects” workflow.

However, it’s unlikely that this is the issue here.

EDIT: To be a bit more precise, re-precompilation for Package A only happens when either A itself or one of its dependencies has a different version in the other environment. If the environments are identical then there is no re-precompilation.

1 Like

A straightforward possibility is to run a script file (include("updatePkg.jl")) “overnight” every now and then, which contains statements of type:

using Pkg
Pkg.update()
using Plots
using DifferentialEquations
...

(with using ... for all the packages that are big and take long time to precompile). This way, the precompilation work is done during sleep and is not noticeable.

Ok, since I am still in the early stages of this mini-project I think I’ll just switch to the most recent 1.3. I’ve been using 1.2 as the “stable” release.

1 Like

This is a great idea. I will start using this too.

Not really a great idea; rather a trivial idea – and I’m sure many others do the same. But I like to make the computer work while I sleep…

there is a bug in precompile. perhaps that’s the problem with Plots here?

also, tamas_papp— you meant JIT i think, not AOT.