"Store" the compiled version of algorithms

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.

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

Yes, they have!

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.

1 Like

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

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

If you want all the gory details, I’d recommend watching JuliaCon 2017 | AoT or JIT: How Does Julia Work? | Jameson Nash - YouTube

4 Likes

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