# PackageCompiler compilation time \> 2h

**URL:** https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910
**Category:** General Usage
**Tags:** package
**Created:** [July 21, 2023, 8:57pm UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910 "2023-07-21T20:57:37Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![martin.d.maas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martin.d.maas/32/50964_2.png) [@martin.d.maas](https://discourse.julialang.org/u/martin.d.maas)
#### Post date: [July 21, 2023, 8:57pm UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/1 "2023-07-21T20:57:37Z")

</div>

I’m trying to compile my project to a standalone executable with PackageCompiler.jl.

I have used PackageCompiler before just for toying around, and I remember compilation times were slow, but now with a real codebase (20 deps, ~1k lines of code) this is taking already more than 2 hours (and counting).

Is having several hours of compilation time for PackageCompiler a normal thing, or there might be a problem in my setup?

---

<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: [July 21, 2023, 9:04pm UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/2 "2023-07-21T21:04:21Z")

</div>

Do you have enough free RAM? Which OS? On Windows virus scanners might slow you down. So far I never saw compilation times of more than 15 min on a not too old PC with projects of a few thousand LOC…

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [July 21, 2023, 9:07pm UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/3 "2023-07-21T21:07:11Z")

</div>

What Julia version are you using?

---

<div class="post-metadata">

### Author: ![martin.d.maas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martin.d.maas/32/50964_2.png) [@martin.d.maas](https://discourse.julialang.org/u/martin.d.maas)
#### Post date: [July 21, 2023, 11:36pm UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/4 "2023-07-21T23:36:51Z")

</div>

5 hours and counting… I guess I should just stop it and try to remove some dependencies o compile a simpler main function…

> [@ufechner7](#):
>
> Do you have enough free RAM? Which OS?

8GB on Linux

> [@mkitti](#):
>
> What Julia version are you using?

1.9

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [July 21, 2023, 11:44pm UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/5 "2023-07-21T23:44:40Z")

</div>

I believe version 1.10 has some new features that would speed this up. One feature is using pkgimages to help build a system image.

---

<div class="post-metadata">

### Author: ![martin.d.maas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martin.d.maas/32/50964_2.png) [@martin.d.maas](https://discourse.julialang.org/u/martin.d.maas)
#### Post date: [July 22, 2023, 12:01am UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/6 "2023-07-22T00:01:05Z")

</div>

Well, compiling the system image took 4:30 minutes.

The project also precompiled successfully, in about 20 minutes for a total of 226 dependencies (altough I have ~20 in my Project.toml).

It then got stuch in the very last phase, it seems.

I’m trying again now with a clean environment and removing some unused deps like Revise…

---

<div class="post-metadata">

### Author: ![xgdgsc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xgdgsc/32/608_2.png) [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)
#### Post date: [July 22, 2023, 12:16am UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/7 "2023-07-22T00:16:30Z")

</div>

[Code block only for PackageCompiler and not for Revise - #5 by tim.holy](https://discourse.julialang.org/t/code-block-only-for-packagecompiler-and-not-for-revise/99870/5) I also learned of we should not add Revise to every package after using PackageCompiler.

---

<div class="post-metadata">

### Author: ![martin.d.maas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martin.d.maas/32/50964_2.png) [@martin.d.maas](https://discourse.julialang.org/u/martin.d.maas)
#### Post date: [July 22, 2023, 4:17am UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/8 "2023-07-22T04:17:48Z")

</div>

I tried again without Revise and stopped the compilation at 1 hour without success.

Btw, I’m also using `create_app`. I can compile “hello world” apps in about 5 minutes.

I also tried to compile a test application that only includes Plots:

```julia
module test_packagecompiler
using Plots
function julia_main()::Cint
    println("Generating random plot and saving to file...")
    heatmap(rand(100,100))
    savefig("random_heatmap.png")
    return 0
end
end 

```

… and after 50 minutes, I gave up.

However, I removed Plots from one of the packages I was trying to compile, and it compiled in about 12 minutes!

A funny thing happened, though. The first time I ran it, it took some time in downloading some artifact (MKL) which had apparently forgot to include during the build, but the second time I ran it, it went straight into the results.

So I guess no plotting on compiled apps? That’s curious, because the first thing I ever did with PackageCompier was to add Plots to a sysimage… Why would something work for a compiled sysimage and not for a standalone app?

---

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [July 22, 2023, 4:23am UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/9 "2023-07-22T04:23:39Z")

</div>

Is it possible that one of your precompilation scripts was waiting for input?

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [July 22, 2023, 5:45am UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/10 "2023-07-22T05:45:19Z")

</div>

8Gbytes is not a lot of RAM these days but should be enough.  
I would advise openign a new terminal and running these utilities as the compilation is happening  
top  
htop  
iotop

Often a simple ‘top’ will give you insight into what is going on.

---

<div class="post-metadata">

### Author: ![johnh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnh/32/3615_2.png) [@johnh](https://discourse.julialang.org/u/johnh)
#### Post date: [July 22, 2023, 5:50am UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/11 "2023-07-22T05:50:33Z")

</div>

Also please look at this thread

> [@How to Make Precompiling Faster?](https://discourse.julialang.org/t/how-to-make-precompiling-faster/101865/5):
>
> I timed @time Pkg.add(“InteractiveDynamics”) this morning. Agree with Tim Holy on the time. I can repeat and give exact time. This is on a laptop running Fedora. Are you very constrained in resources on your machine? Maybe low on rAM and swapping is happening?

This is twice we have a report of very large compilation times. Are we seeing the start of a common problem?

I suspect this is not a bug in Julia, rather that these systems are swapping due to large memory use. Thats just a wet finger stuck up to test the wind of course.  
Please report versioninfo()

---

<div class="post-metadata">

### Author: ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)
#### Post date: [July 22, 2023, 5:58am UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/12 "2023-07-22T05:58:48Z")

</div>

There is an open issue for PackageCompiler.jl [PackageCompiler spins infinitely when compiling sysimage · Issue #825 · JuliaLang/PackageCompiler.jl · GitHub](https://github.com/JuliaLang/PackageCompiler.jl/issues/825) So far, it seems that having Plot.jl or StatsPlots.jl included in the image leads to problems, but why this is so is not clear. With Julia 1.8.x, the same projects do compile successfully, in a “normal” amount of time.

---

<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: [July 22, 2023, 8:15am UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/13 "2023-07-22T08:15:50Z")

</div>

Just don’t try to compile Plots with PackageCompiler. It is very difficult to make it work and probably not worth the effort. There are lots of other plotting packages that cause less problems.

---

<div class="post-metadata">

### Author: ![martin.d.maas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martin.d.maas/32/50964_2.png) [@martin.d.maas](https://discourse.julialang.org/u/martin.d.maas)
#### Post date: [July 22, 2023, 2:22pm UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/14 "2023-07-22T14:22:59Z")

</div>

Yes, it seems that this is a regression somewhere, maybe in Plots or PackageCompiler… because it definitively used to work.

Just for the record:

```julia
Julia Version 1.9.0
Commit 8e630552924 (2023-05-07 11:25 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × AMD Ryzen 5 1400 Quad-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver1)
  Threads: 1 on 8 virtual cores

```

---

<div class="post-metadata">

### Author: ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)
#### Post date: [August 19, 2023, 12:18pm UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/15 "2023-08-19T12:18:20Z")

</div>

See the issue I mentioned above, there is a work around for julia 1.10rc2, which I suppose will probably not be needed for much longer.

---

<div class="post-metadata">

### Author: ![martin.d.maas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/martin.d.maas/32/50964_2.png) [@martin.d.maas](https://discourse.julialang.org/u/martin.d.maas)
#### Post date: [August 23, 2023, 8:22pm UTC](https://discourse.julialang.org/t/packagecompiler-compilation-time-2h/101910/16 "2023-08-23T20:22:53Z")

</div>

Yes, I’m watching that issue, thanks for the reference. I couldn’t try it yet, but I’ll report back when I do.
