Precompilation of DifferentialEquations.jl

I am loading (with using) several packages. DifferentialEquations.jl takes a long time to precompile (1-2 minutes). I exit Julia and reload the packages. Again, DifferentialEquations.jl takes the same time to precompile. Why would that be? Perhaps I should load it first? Here is my loading code:

using Revise
using Zygote
using ForwardDiff
using Lux
using Random
using Statistics
using Tullio
using Plots
using Optimisers
using ComponentArrays
using LinearAlgebra
using Optimization
using OptimizationOptimJL
using DifferentialEquations

Does the order of the loading affect anything?
Here is my toml file:

ComponentArrays = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Lux = "b2108857-7c20-44ae-9111-449ecde12c47"
Optimisers = "3bd65402-5787-11e9-1adc-39752487f4e2"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Tullio = "bc48ee85-29a4-5162-ae0b-a64e1601d4bc"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

Which Julia version? Which operating system?

Julia 1.8.3, Mac OS Ventura with M1 chip.
Here is the output of versioninfo():

Julia Version 1.8.3
Commit 0434deb161e (2022-11-14 20:14 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.3.0)
  CPU: 8 × Apple M1
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 2 on 4 virtual cores
  DYLD_FALLBACK_LIBRARY_PATH = /Users/erlebach/.julia/artifacts/2a86ef020f132332b2f4be2fb40912cc7df5da29/lib:/Users/erlebach/.julia/artifacts/b376941014acf8e5501996cdf9932036cfb3bb71/lib:/Users/erlebach/.julia/artifacts/5b338c8fa90c05e6faea86e54d2996cca76cfbbe/lib:/Applications/

It does have a long precompile, but it should only precompile when you update it or its dependencies.

Use Pkg.precompile() for parallel precompilation of the active environment. It tends to be much faster.

1 Like

ordinarydiffeq by itself can easily take 2 minutes to precompile

This is just a using call so it will precompile all the dependencies serially.

I don’t mind the time to recompile if it only happens once. But why would it need to recompile again when I exit Julia (exit()) in the REPL, even if do not execute any code except using various packages.

If you use the same Julia version and the same package versions it should not need to re-precompile.

Exactly. So something weird is going on.

You can run ENV["JULIA_DEBUG"] = "loading" before doing the usings and it should print out some maybe useful info.