# Why does precompilation take so long for this no-op module?

**URL:** https://discourse.julialang.org/t/why-does-precompilation-take-so-long-for-this-no-op-module/41026
**Category:** General Usage
**Created:** [June 9, 2020, 12:24am UTC](https://discourse.julialang.org/t/why-does-precompilation-take-so-long-for-this-no-op-module/41026 "2020-06-09T00:24:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)
#### Post date: [June 9, 2020, 12:24am UTC](https://discourse.julialang.org/t/why-does-precompilation-take-so-long-for-this-no-op-module/41026/1 "2020-06-09T00:24:22Z")

</div>

Suppose I have a basically empty package which depends on a “heavy” (i.e. slow to precompile/load) package. E.g.

```julia
module Foo
using Zygote
end

```

Why does precompiling my empty package (Julia 1.4.2) take significantly longer than precompiling the single heavy package?

```julia
# time to precompile and load Zygote
julia> @time using Zygote
[Info: Precompiling Zygote [e88e6eb3-aa80-5325-afca-941959d7151f]
 24.688621 seconds (28.59 M allocations: 1.660 GiB, 1.91% gc time)

# time to just load Zygote
julia> @time using Zygote
 10.273923 seconds (27.57 M allocations: 1.613 GiB, 4.69% gc time)

# time to precompile and load Foo when Zygote also needs to be precompiled
julia> @time using Foo
[Info: Precompiling Foo [9717d8fb-fffd-47ec-8476-db8e9679d15e]
 36.702254 seconds (37.17 M allocations: 2.075 GiB, 1.65% gc time)

```

In all cases here I have ensured all of Zygote’s dependencies are precompiled, so the timing should reflect just Zygote and Foo.

So shouldn’t precompiling Foo when Zygote also needs to be precompiled (the last case) not take any longer than the original 24 seconds?

This kind of thing comes up in my workflow alot since I often structure my analyses with modules that depend on each other like GenericAnalysisPackage ← MoreSpecificAnalysisPackage ← EvenMoreSpecificAnalysisPackage. When everything is precompiled this is great, but changing GenericAnalysisPackage triggers what feels like a needlessly slow recompilation.

Is this something simple which can be fixed, or is this secretly a more complex problem?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [June 9, 2020, 8:06am UTC](https://discourse.julialang.org/t/why-does-precompilation-take-so-long-for-this-no-op-module/41026/2 "2020-06-09T08:06:06Z")

</div>

Try the 1.5 branch, these things have improved a lot.

---

<div class="post-metadata">

### Author: ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)
#### Post date: [June 9, 2020, 7:19pm UTC](https://discourse.julialang.org/t/why-does-precompilation-take-so-long-for-this-no-op-module/41026/3 "2020-06-09T19:19:36Z")

</div>

1.5 seems a bit faster overall which is great, but still has the same problem that precompiling Foo takes longer than precompiling its dependency. Here’s with some slightly more reproducible (bash) code:

```bash
zygote=$(julia -e "using Zygote,Foo; println(pathof(Zygote))")

# time to precompile and load Zygote
touch $zygote
julia -e "@time using Zygote"
 22.005036 seconds (24.60 M allocations: 1.395 GiB, 1.08% gc time)

# time to just load Zygote
julia -e "@time using Zygote"
  7.943963 seconds (23.90 M allocations: 1.361 GiB, 0.09% gc time)

# time to precompile and load Foo when Zygote also needs to be precompiled
touch $zygote
julia -e "@time using Foo"
 27.318374 seconds (24.60 M allocations: 1.395 GiB, 0.90% gc time)

```
