0
votes

I'm now trying to precompile a Julia module so that it may run faster. However, it seems strange to me that writing __precompile__() before the module declaration doesn't seem to have produced any cache file in the folder.

Then, I tried to call the function Base.compilecache with the following steps:

  1. Launch the REPL in the project folder
  2. include("M.jl")
  3. Base.compilecache("M")

However, even though the first two steps finish without problems and that I can actually run the functions defined within the module, the third step complains "ERROR: ArgumentError: M not found in path", and I still can't seem to generate any cache for the module.

What did I do wrong here?

1
btw, I assume this is just a typo in the question itself, but the instruction is __precompile__(), not __precompile()__ - Tasos Papastylianou
@TasosPapastylianou Sure, that was a typo. - xji

1 Answers

1
votes

Compiled modules are produced in a user-defined place, in linux typically ~/.julia/lib/v0.6/. I'm sure if you look in there you will find .ji files corresponding to precompiled versions of your modules. Remove one and try importing again in a julia session to confirm that it will attempt to precompile all over again; if it does, it means your __precompile__() directive is working.

Furthermore, be careful to push! the path of your custom module (i.e. the source code .jl part, not the path for the precompiled .ji files) to the LOAD_PATH (i.e. push!(LOAD_PATH, "./") ) if this is not 'installed' in the default place (typically ~/.julia/v0.6/). Julia needs access to both when you're about to import the module.

(PS. you should also see a Precompilation occuring if you update your module)