# "Store" the compiled version of algorithms

**URL:** <https://discourse.julialang.org/t/store-the-compiled-version-of-algorithms/11389>\
**Category:** General Usage\
**Created:** [June 3, 2018, 2:26pm UTC](https://discourse.julialang.org/t/store-the-compiled-version-of-algorithms/11389 "2018-06-03T14:26:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [June 3, 2018, 2:26pm UTC](https://discourse.julialang.org/t/store-the-compiled-version-of-algorithms/11389/1 "2018-06-03T14:26:40Z")

</div>

Hi guys!

I have seen that, every time I restarted Julia, the first execution of a function in a package is somewhat slow, and the others are pretty fast. I understand that this is Julia compiling the code.

I do not understand those things about compilers and JITs and etc., but I am wondering: if the package did not change since the last execution, why this “compiled” version cannot be stored so that we do not have the overhead in the first call? I though that the ` __precompile__ ()` directive was doing this.

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [June 3, 2018, 3:03pm UTC](https://discourse.julialang.org/t/store-the-compiled-version-of-algorithms/11389/2 "2018-06-03T15:03:18Z")

</div>

Do all the packages you are loading at startup have the ` __precompile__ ()` directive?  
Precompiling will become the default I believe, in v1.0.

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [June 3, 2018, 3:09pm UTC](https://discourse.julialang.org/t/store-the-compiled-version-of-algorithms/11389/3 "2018-06-03T15:09:03Z")

</div>

Yes, they have!

---

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [June 3, 2018, 3:22pm UTC](https://discourse.julialang.org/t/store-the-compiled-version-of-algorithms/11389/4 "2018-06-03T15:22:26Z")

</div>

For now, “precompiled” packages are not stored as machine code and so still suffer from some compilation overhead when you actually execute a function. The plan is to move closer to native code (what I think you are suggesting) to avoid this in the future: [see issue 27362](https://github.com/JuliaLang/julia/issues/27362).

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [June 3, 2018, 3:43pm UTC](https://discourse.julialang.org/t/store-the-compiled-version-of-algorithms/11389/5 "2018-06-03T15:43:32Z")

</div>

Actually I was just trying to understand what is under the hood. You explained to me, now I get what the ` __precompile__ ` directive does 🙂

Do you know if there is a milestone (1.0, 1.1 ?) in which this new compilation behavior will be implemented?

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [June 3, 2018, 7:39pm UTC](https://discourse.julialang.org/t/store-the-compiled-version-of-algorithms/11389/6 "2018-06-03T19:39:27Z")

</div>

If you want all the gory details, I’d recommend watching [JuliaCon 2017 | AoT or JIT: How Does Julia Work? | Jameson Nash - YouTube](https://m.youtube.com/watch?v=7KGZ_9D_DbI#)

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [June 4, 2018, 9:12pm UTC](https://discourse.julialang.org/t/store-the-compiled-version-of-algorithms/11389/7 "2018-06-04T21:12:26Z")

</div>

I watched… unfortunately I do not have …err how can I say… the right expertise to understand 😃
