I really like this language due to its speed and usability. However, a lot of times my modules are recompiling, which can take a long time when my script is starting. I read here and there some stuff about the conditions, when a cache is forced to recompile. But I could not remember every condition, nor did I find the rational behind it, why the cache has to recompile under these conditions. (That the cache has to recompile when I use a different Julia version or changed a file of the module is clear. Other conditions looked a bit mysterious to me). Could you provide me with a complete list with the conditions, when a cache has to recompile? And the rational behind it, so I will understand it and remember?
Furthermore, I would really appreciate some tips and tricks how to make my modules (or modules added with the package manager) not recompile every now and then. I am using Atom with Juno for development, and sometimes I run the full skript with the Play button, sometimes I do inline evaluation, and sometimes I type something in the REPL in Atom. Sometimes I also exit() and restart Julia in the Atom REPL to get rid of the current workspace. To me it seems, the modules recompile at random occasions. I would really like to understand this behavior and find a way to work around this. Because waiting so long every time starts to get annoying.
Recompilation should only need to happen after you have updated packages or changed your julia version. Does it happen more than that?
For packages being developed, it sometimes makes sense to put __precompile__(false) on top of them to make them not precompile, since we want to reload them over and over.
Yes, it seems it does recompile more often, but not every time. I will keep a closer look on it, then I can report back. However I could not find any reproducible step yet.
I also will look for the precompile flag. Does it default to true, when it is not set?
Right now I had the case, that the library ControlSystems did recompile. Though I did not update anything since the last time I used it (some seconds ago). But I donβt know how to reproduce this. It occurs very unpredictable, but luckily also very seldom.
However, what suprprises me as well is that the first loading of a Module takes quite long. Why does it take so long and what is it doing in this time? Does it take so long to load all the functions in the RAM? And why does it take some time at the second run as well, and only the third run is very fast?
Can I actually see the reason, why a cache is recompiling, somewhere? Maybe in a Pkg or Julia debug version?
And since I forgot to mention it: I am using Julia 1.0.3
I have a reproducible scenario now:
I have installed the module QuadGK (in the official registry) in both the default environment (v1.0) as well as in Environment (EnvA). Executing the commands in the following sequence, the package will compile EVERY TIME, although none of the Julia or Package versions did change:
$ julia
> using QuadGK
[ Info: Recompiling stale cache file /home/maximilian/.julia/compiled/v1.0/QuadGK/hq5Ol.ji for QuadGK [1fd47b50-473d-5c70-9696-f719f8f3bcdc]
> exit()
$ julia
] activate EnvA
> using QuadGK
[ Info: Recompiling stale cache file /home/maximilian/.julia/compiled/v1.0/QuadGK/hq5Ol.ji for QuadGK [1fd47b50-473d-5c70-9696-f719f8f3bcdc]
> exit()
$ julia
> using QuadGK
[ Info: Recompiling stale cache file /home/maximilian/.julia/compiled/v1.0/QuadGK/hq5Ol.ji for QuadGK [1fd47b50-473d-5c70-9696-f719f8f3bcdc]
# and so on and so forth......
Notice, that the Version and the Path to the QuadGK module did not change. This only happens, when alternating between the default environment and a custom environment. When creating two custom environment (EnvA and EnvB for example), and alternating between these ones, the package will NOT recompile. Also, I tried to do this with the package Example, but this package did also not reproduce this behaviour. But QuadGK is not the only package, it happens with quite some packages, and one of them needs to compile very long.
By the way: When I installed the package Example in my default environment, it updated all the packages I have installed there. I thought, the new package manager wouldnβt do this any more. Why did I experience this?
Iβm also getting this with some of my own packages, it seems to happen more when there was some issue when installing the package (I was missing some dependencies in REQUIRE). Is there any solution to this beside deleting everything and starting fresh ? Can I save my environment and just instantiate maybe ?
The package also needs to recompile if any of the dependencies changes version. Maybe those are different between the custom and the default environment?
I have a similar (and maybe related) issue to whatβs described here.
I have two environments, say EnvA and EnvB, which contain two different versions of JuMP: EnvA is on 0.19.2, while EnvB is on 0.20. Every time I switch between environments, julia recompiles a βstale cache fileβ, which is surprising since itβs not in the same environment. This is a bit bothersome since several packages depend on JuMP and that triggers also their recompilation. Also different JuMP versions depend on packages with different versions, and all that could also trigger recompilation for packages in each environment.
I would be happy if it was possible that each environment had its own cache (with its own βhash-likeβ filename inside .julia/compiled/β¦). Better still, of course, if the package manager / runtime environment was smart enough to realize that if EnvC had JuMP also on 0.19.2, then it would not require a recompile, but just (for example) produce a (hard?) link.
Thanks! Do you know a link to a documentation page that describes how this is supposed to be used, and how this is supposed to work? I searched https://github.com/JuliaLang/julia/blob/release-1.3/NEWS.md and saw no mention of it (maybe itβs just that I used the wrong keywords, but I expected either βstaleβ or βcacheβ to pop up.