# Reduce compilation time in Testing

**URL:** <https://discourse.julialang.org/t/reduce-compilation-time-in-testing/84387>\
**Category:** General Usage\
**Created:** [July 18, 2022, 8:36am UTC](https://discourse.julialang.org/t/reduce-compilation-time-in-testing/84387 "2022-07-18T08:36:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [July 18, 2022, 8:36am UTC](https://discourse.julialang.org/t/reduce-compilation-time-in-testing/84387/1 "2022-07-18T08:36:30Z")

</div>

In the package I am (co-)developing, we write a lot of tests. Now we are running into the problem, that the tests run quite long (currently for example a little more than an hour).

In our output like

> <https://github.com/JuliaManifolds/Manifolds.jl/actions/runs/2646061850/job/7276923170#step:5:645>

So most of these, also the following ones, spent their time on compilation – sure these are all specialised functions for the separate manifolds – one user would not notice this much, when using just one of them. Still – are there any good ideas on how to reduce compilation time here, maybe?

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [July 18, 2022, 8:55am UTC](https://discourse.julialang.org/t/reduce-compilation-time-in-testing/84387/2 "2022-07-18T08:55:52Z")

</div>

You are more experienced that me 😉 But from my modules the package [SnoopCompile.jl · SnoopCompile](https://timholy.github.io/SnoopCompile.jl/stable/) really helped to reduce compile times.

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [July 18, 2022, 10:04am UTC](https://discourse.julialang.org/t/reduce-compilation-time-in-testing/84387/3 "2022-07-18T10:04:58Z")

</div>

I also suffer from similar problems, for many packages, I can reduce the time to run the tests by about 50-75% by running

```julia
julia --compile=min -O 1

```

It’s a bit tricky to use, since if you have some tests that are somewhat computationally expensive, those might become so slow with the above options that it takes longer time overall.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [July 18, 2022, 10:06am UTC](https://discourse.julialang.org/t/reduce-compilation-time-in-testing/84387/4 "2022-07-18T10:06:53Z")

</div>

That sounds nice, I have to check how to add that to GitHub CI (after trying that locally).

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [July 18, 2022, 5:13pm UTC](https://discourse.julialang.org/t/reduce-compilation-time-in-testing/84387/5 "2022-07-18T17:13:35Z")

</div>

The flags locally reduce computations for a few tests but increase them tremendously for others (from 30 seconds to 1000 seconds) so overall (locally on my machine) our tests run longer with those settings. But thanks for the idea.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [July 18, 2022, 5:18pm UTC](https://discourse.julialang.org/t/reduce-compilation-time-in-testing/84387/6 "2022-07-18T17:18:20Z")

</div>

I have not yet worked with SnoopCompile (and I am surely not experienced with recompilation) but I will take a look, thanks!

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [July 22, 2022, 11:45am UTC](https://discourse.julialang.org/t/reduce-compilation-time-in-testing/84387/7 "2022-07-22T11:45:05Z")

</div>

Update – I have a current variant, that splits my tests into two, runs some (previously determined) tests on the normal Julia and others on `-O0 --compile=min`, see

[https://github.com/JuliaManifolds/Manifolds.jl/blob/kellertuer/faster-tests/.github/workflows/ci.yml](https://github.com/JuliaManifolds/Manifolds.jl/blob/kellertuer/faster-tests/.github/workflows/ci.yml)

the one thing this does not yet seem to do is – upload the code coverage for the faster tests.
