# How fast can Plots.jl work after being compiled with PackageCompiler?

**URL:** <https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314>\
**Category:** Performance\
**Tags:** package-compiler\
**Created:** [May 11, 2020, 11:50pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314 "2020-05-11T23:50:30Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [May 11, 2020, 11:50pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/1 "2020-05-11T23:50:30Z")

</div>

I just tried using PackageComipler on Plots.jl. With precompiled images, I got

```julia
julia> @time using Plots
  0.891786 seconds (1.26 M allocations: 59.289 MiB, 16.97% gc time)

julia> @time (p = plot(rand(5), rand(5)); display(p))
 19.150645 seconds (23.79 M allocations: 1.167 GiB, 3.50% gc time)

```

Without it, I got

```julia
julia> @time using Plots
 22.850512 seconds (26.91 M allocations: 1.375 GiB, 3.72% gc time)

julia> @time (p = plot(rand(5), rand(5)); display(p))
 25.178778 seconds (28.32 M allocations: 1.400 GiB, 2.38% gc time)

```

The loading time certainly improved significantly, but not so much for the first plotting time. Is this normal?

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [May 12, 2020, 2:43am UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/2 "2020-05-12T02:43:41Z")

</div>

Following the [instructions](https://julialang.github.io/PackageCompiler.jl/dev/examples/plots/#examples-plots-1) for creating a Plots.jl sysimage, I was able to reduce my load time significantly:

```julia
time julia -e "using Plots; p = plot(rand(5), rand(5)); display(p)"  
 23.78s user 0.75s system 75% cpu 32.647 total

time julia --sysimage sys_plots.so -e "using Plots; p = plot(rand(5), rand(5)); display(p)"
 0.41s user 0.20s system 67% cpu 0.908 total

```

Are you plotting in the terminal, or Atom/VSCode? If it’s the latter, try [this](https://github.com/JuliaLang/PackageCompiler.jl/issues/352#issuecomment-598340916) workaround. IDEs require extra machinery to display plots, and PackageCompiler needs to see that machinery if it’s to be compiled into a sysimage.

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [May 12, 2020, 3:52am UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/3 "2020-05-12T03:52:36Z")

</div>

I see what is the problem. I didn’t compile the image correctly. Now it’s now fast.

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [May 12, 2020, 4:11am UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/4 "2020-05-12T04:11:31Z")

</div>

Two questions… If the package is baked into your system image 1) do you not have to `add Plots` anymore? i.e. it won’t be part of your environment?

and 2) what happens when there is a new update release? Can you run `pkg> up` or does a new image have to be compiled?

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [May 12, 2020, 6:16am UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/5 "2020-05-12T06:16:32Z")

</div>

I am interested in these questions too…

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [May 12, 2020, 6:20am UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/6 "2020-05-12T06:20:02Z")

</div>

The [docs](https://julialang.github.io/PackageCompiler.jl/dev/sysimages/) explain that one of the main downsides of using PackageCompiler is that you cannot `up` a package that’s included in the sysimage anymore, i.e. it is frozen at whatever version you included in the image.

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [May 12, 2020, 12:30pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/7 "2020-05-12T12:30:53Z")

</div>

I tried the procedure [in the documentation](https://julialang.github.io/PackageCompiler.jl/dev/examples/plots/) but when I run:

```julia
using PackageCompiler
create_sysimage(:Plots, sysimage_path="sys_plots.so", precompile_execution_file="precompile_plots.jl")

```

I get:

```julia
ERROR: UndefVarError: create_sysimage not defined
Stacktrace:
 [1] top-level scope at REPL[5]:1

```

Some changes in the API ? (I installed PackageCompiler v0.6.5)

EDIT: I see that PackageCompiler is at v 1.1… I just added to a Julia1.3 instance today, it installed the v0.6.5 not the v1.1…  
How can I know what is it blocking the installation of the latest version ?

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [May 12, 2020, 12:35pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/8 "2020-05-12T12:35:11Z")

</div>

I think you can try to add a specific version of PackageCompiler like this –[How to install a specific version of a package with Pkg.add("...")](https://discourse.julialang.org/t/how-to-install-a-specific-version-of-a-package-with-pkg-add/29242)

---

<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:** [May 12, 2020, 12:38pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/9 "2020-05-12T12:38:56Z")

</div>

> [@sylvaticus](#):
>
> I just added to a Julia1.3 instance today, it installed the v0.6.5 not the v1.1…  
> How can I know what is it blocking the installation of the latest version ?

It requires Julia 1.3.1.

> [@sylvaticus](#):
>
> I just added to a Julia1.3 instance today,

The newest release is 1.4.1. You should always use the latest release.

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [May 12, 2020, 12:39pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/10 "2020-05-12T12:39:21Z")

</div>

Some how it is still much slower in REPL

```julia
(base) xing@MAT-WL-xinca341:PackageCompile$ time julia -e "using Plots; p = plot(rand(5), rand(5)); display(p)" 

real	0m48.484s
user	0m47.686s
sys	0m1.032s
(base) xing@MAT-WL-xinca341:PackageCompile$ time julia --sysimage sys_plots.so -e "using Plots; p = plot(rand(5), rand(5)); display(p)"

real	0m0.695s
user	0m0.513s
sys	0m0.726s

(base) xing@MAT-WL-xinca341:PackageCompile$ julia --sysimage sys_plots.so
julia> @time using Plots
  0.746027 seconds (1.26 M allocations: 59.292 MiB, 1.40% gc time)

julia> @time (p = plot(rand(5), rand(5)); display(p))
 14.563074 seconds (20.60 M allocations: 1.022 GiB, 5.75% gc time)

```

---

<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:** [May 12, 2020, 12:39pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/11 "2020-05-12T12:39:57Z")

</div>

> [@Xing\_Shi\_Cai](#):
>
> Some how it is still much slower in REPL

Do you load packages in `startup.jl`?

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [May 12, 2020, 12:40pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/12 "2020-05-12T12:40:26Z")

</div>

Yes, OhMyREPL and Revise.

---

<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:** [May 12, 2020, 12:42pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/13 "2020-05-12T12:42:23Z")

</div>

Okay, then you are in the territory of invalidations (see [https://github.com/JuliaLang/www.julialang.org/pull/794](https://github.com/JuliaLang/www.julialang.org/pull/794) for a WIP blogpost about this exact problem). My guess is that this will have quite a bit of focus in the upcoming months so hopefully should improve.

---

<div class="post-metadata">

**Author:** ![Xing\_Shi\_Cai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xing_shi_cai/32/14128_2.png) [@Xing\_Shi\_Cai](https://discourse.julialang.org/u/Xing_Shi_Cai)\
**Post date:** [May 12, 2020, 12:47pm UTC](https://discourse.julialang.org/t/how-fast-can-plots-jl-work-after-being-compiled-with-packagecompiler/39314/14 "2020-05-12T12:47:37Z")

</div>

OK. I have also compiled OhMyREPL following the instruction here [PackageCompiler.jl/ohmyrepl.md at master · JuliaLang/PackageCompiler.jl · GitHub](https://github.com/JuliaLang/PackageCompiler.jl/blob/master/docs/src/examples/ohmyrepl.md).  
So it’s not a problem anymore.

It seems that it’s Revise slowing things done. I will just remove it from startup.jl.
