# Precompilation of DifferentialEquations.jl

**URL:** <https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363>\
**Category:** General Usage\
**Created:** [December 31, 2022, 5:01pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363 "2022-12-31T17:01:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [December 31, 2022, 5:01pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/1 "2022-12-31T17:01:25Z")

</div>

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:

```julia
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:

```julia
[deps]
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"

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 31, 2022, 5:33pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/2 "2022-12-31T17:33:44Z")

</div>

Which Julia version? Which operating system?

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [December 31, 2022, 5:44pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/3 "2022-12-31T17:44:30Z")

</div>

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

```julia
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
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, apple-m1)
  Threads: 2 on 4 virtual cores
Environment:
  JULIA_NUM_THREADS = 2
  JULIA_EDITOR = code
  DYLD_FALLBACK_LIBRARY_PATH = /Users/erlebach/.julia/artifacts/2a86ef020f132332b2f4be2fb40912cc7df5da29/lib:/Users/erlebach/.julia/artifacts/b376941014acf8e5501996cdf9932036cfb3bb71/lib:/Users/erlebach/.julia/artifacts/5b338c8fa90c05e6faea86e54d2996cca76cfbbe/lib:/Applications/Julia-1.8.app/Contents/Resources/julia/lib/julia:/Users/erlebach/.julia/artifacts/f987f10c94bc56fe3589d9b30a6e2f419402a31c/lib:/Users/erlebach/.julia/artifacts/9410bad2635eda2239b4a72ba4316c4aa8f5b76e/lib:/Users/erlebach/.julia/artifacts/c08186c25e5525a58ec149de9bdd30703c0464c2/lib:/Users/erlebach/.julia/artifacts/086c1b4e2156bba1b383b684839e78fe75e6d546/lib:/Users/erlebach/.julia/artifacts/b917751a0a1532e56881e471e0f9b441460f2295/lib:/Users/erlebach/.julia/artifacts/0263e80940b81bc6d73a88423c690d6450a9ff09/lib:/Users/erlebach/.julia/artifacts/41d2d4f312d93b56961767987cf48ea1f6d6fadc/lib:/Users/erlebach/.julia/artifacts/e6b9fb44029423f5cd69e0cbbff25abcc4b32a8f/lib:/Users/erlebach/.julia/artifacts/b2108f561a8812e376eb80e71a24a3678a24d231/lib:/Users/erlebach/.julia/artifacts/ada2a202928dd4cb2fc4bd18c4efa9d5455ec742/lib:/Users/erlebach/.julia/artifacts/df3881e810714d6a09467fe85a6fde79385fe702/lib:/Users/erlebach/.julia/artifacts/3b3d0bcaf14a9b239a4f4dc20ef7b9e63030a47e/lib:/Users/erlebach/.julia/artifacts/abf161ac3d4df76ae74bbf5432b7e061b3876236/lib:/Users/erlebach/.julia/artifacts/4260cf51a368d8e305a5de3669e32539e1e6cc72/lib:/Users/erlebach/.julia/artifacts/fc7ba632b72ce7d852c1924aa2bbfe244a71c780/lib:/Users/erlebach/.julia/artifacts/413111420faa4e2aeaa383c075eaa213402d939c/lib:/Users/erlebach/.julia/artifacts/ca2831bf6edc5088aec5b329ea98364951d6cad0/lib:/Users/erlebach/.julia/artifacts/3fe6bf926e57cc4be598151cd40832221de2e894/lib:/Users/erlebach/.julia/artifacts/c325a23bc1f6521474cef5f634f18c8ab311bb02/lib:/Users/erlebach/.julia/artifacts/0db9c3f6cf936a0da49e2ba954ba3e10bed6ad72/lib:/Users/erlebach/.julia/artifacts/1a7e22e66b523d9cb884cf85c3ec065b5fb3e5c3/lib:/Users/erlebach/.julia/artifacts/86db9318cb3ddd958e38d2b28884c793f4bef988/lib:/Users/erlebach/.julia/artifacts/4609432e7098d8434a7a4c7876dd5b9e09b2a5e7/lib:/Users/erlebach/.julia/artifacts/bf37190b92ac2fc3dd5e7073ff7ec7bbfd10343f/lib:/Users/erlebach/.julia/artifacts/7f4d1479db8bfb628aff3806c483e5fec617271a/lib:/Users/erlebach/.julia/artifacts/2f38ae8b406b01e85a4f0e165d3976d8f6bf80c9/lib:/Users/erlebach/.julia/artifacts/b450526929615030746974fd622effa333c2c87a/lib:/Users/erlebach/.julia/artifacts/1b3d05e1af5571e3dc596223ea161ce78ad30e1c/lib:/Users/erlebach/.julia/artifacts/e0874abced850b5bab1921e0f028d50861af3e18/lib:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtConcurrent.framework/Versions/5:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtCore.framework/Versions/5:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtDBus.framework/Versions/5:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtGui.framework/Versions/5:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtNetwork.framework/Versions/5:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtOpenGL.framework/Versions/5:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtPrintSupport.framework/Versions/5:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtSql.framework/Versions/5:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtTest.framework/Versions/5:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtWidgets.framework/Versions/5:/Users/erlebach/.julia/artifacts/b37aebc8943f796682edea53e2ec10463bf624ac/lib/QtXml.framework/Versions/5:/Users/erlebach/.julia/artifacts/6b3e3e5c14527568cfadd93e4fbe951552269113/lib:/Applications/Julia-1.8.app/Contents/Resources/julia/bin/../lib/julia:/Applications/Julia-1.8.app/Contents/Resources/julia/bin/../lib:

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [December 31, 2022, 6:02pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/4 "2022-12-31T18:02:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 31, 2022, 6:23pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/5 "2022-12-31T18:23:24Z")

</div>

> [@erlebach](#):
>
> DifferentialEquations.jl takes a long time to precompile (1-2 minutes).

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

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [December 31, 2022, 6:25pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/6 "2022-12-31T18:25:00Z")

</div>

ordinarydiffeq by itself can easily take 2 minutes to precompile

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 31, 2022, 6:25pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/7 "2022-12-31T18:25:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [December 31, 2022, 6:27pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/8 "2022-12-31T18:27:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 31, 2022, 6:31pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/9 "2022-12-31T18:31:58Z")

</div>

> [@erlebach](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [December 31, 2022, 6:34pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/10 "2022-12-31T18:34:47Z")

</div>

Exactly. So something weird is going on.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [December 31, 2022, 6:57pm UTC](https://discourse.julialang.org/t/precompilation-of-differentialequations-jl/92363/11 "2022-12-31T18:57:34Z")

</div>

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