# Plots.jl precompile performance

**URL:** <https://discourse.julialang.org/t/plots-jl-precompile-performance/123979>\
**Category:** Visualization\
**Tags:** plotting\
**Created:** [December 19, 2024, 6:18am UTC](https://discourse.julialang.org/t/plots-jl-precompile-performance/123979 "2024-12-19T06:18:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![deszoeke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/deszoeke/32/2174_2.png) [@deszoeke](https://discourse.julialang.org/u/deszoeke)\
**Post date:** [December 19, 2024, 6:18am UTC](https://discourse.julialang.org/t/plots-jl-precompile-performance/123979/1 "2024-12-19T06:18:39Z")

</div>

Is there a lightweight version or workflow for Plots.jl that doesn’t precompile all the backends and dependencies? Most users will only need to use a small subset of backends from one environment, or maybe ever. Could the dependencies be loaded on demand?

I added Plots to get UnicodePlots and it precompiled in 268 s. The first time I know is the worst case scenario. I know from experience this will bog down my Pkg.update precompiles. I could pin Plots, I suppose.

Matplotlib compiles much faster. It has the idiosyncratic user interface that it has. I wish I could use Plots’s elegant unified interface as an efficient entry point for more backends, but it seems that having Plots as a frontend dependency adds a lot of overhead.

Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [December 19, 2024, 6:35am UTC](https://discourse.julialang.org/t/plots-jl-precompile-performance/123979/2 "2024-12-19T06:35:14Z")

</div>

t does not precompile all the backends, and a lot of care has been taken to only load dependencies on demand. I think plotting packages are just complex to compile - Makie is even larger. The time-to-first-plot with Plots has classically been one of the biggest pain points in Julia, but has improved a lot in recent versions. It is fairly fast now, but yeah, precompiles when adding new packages does take time.

---

<div class="post-metadata">

**Author:** ![deszoeke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/deszoeke/32/2174_2.png) [@deszoeke](https://discourse.julialang.org/u/deszoeke)\
**Post date:** [December 19, 2024, 6:42am UTC](https://discourse.julialang.org/t/plots-jl-precompile-performance/123979/3 "2024-12-19T06:42:29Z")

</div>

That’s great Plots.jl does load packages on demand.

This was my result for  
`] add Plots, UnicodePlots`

`113 dependencies successfully precompiled in 268 seconds. 107 already precompiled.`

I guess Plots’s builtin flexibility with calls and keywords leads to a large graph of methods. Smart stuff for a complicated problem.

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [December 19, 2024, 7:52am UTC](https://discourse.julialang.org/t/plots-jl-precompile-performance/123979/4 "2024-12-19T07:52:30Z")

</div>

What I do is have a default julia environment that is almost empty (except for Revise) and then add packages to specific project environments as I need them. That way I don’t need to precompile every single installed package every time I add something.

On my Macbook Air I get

```julia
] add Plots, UnicodePlots

```

```julia
40 dependencies successfully precompiled in 97 seconds. 154 already precompiled.

```

Still not fast, but better.

---

<div class="post-metadata">

**Author:** ![deszoeke](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/deszoeke/32/2174_2.png) [@deszoeke](https://discourse.julialang.org/u/deszoeke)\
**Post date:** [December 19, 2024, 4:56pm UTC](https://discourse.julialang.org/t/plots-jl-precompile-performance/123979/5 "2024-12-19T16:56:11Z")

</div>

Thanks for that test. I also do the same with my julia environments. I only have Revise and IJulia in the base 1.11 environment, and MAT, NCDatasets, and PyPlot in the local environment.

I was also using my old slow server (where my data are) for that last compile. That’s where I feel slow compiles the most.
