JuliaLang/julia

Precompiling modules outside of packages

Open

#32.926 aperta il 16 ago 2019

Vedi su GitHub
 (7 commenti) (8 reazioni) (0 assegnatari)Julia (5773 fork)batch import
docshelp wanted

Metriche repository

Star
 (48.709 star)
Metriche merge PR
 (Merge medio 23g 11h) (145 PR mergiate in 30 g)

Descrizione

As far as I can tell, there's currently no built-in way to cache a precompiled module if it's not part of a package. There's two problems here:

  1. This isn't made sufficiently clear by the documentation on module precompilation. In fact, that section of the docs says you can cache arbitrary precompiled modules by simply calling Base.compilecache. This is clearly not the case since Base.compilecache takes a PkgId as its argument.
  2. For use-cases involving distributing a single script with relatively long compilation-time and short run-time, this leaves a lot of performance on the table. For me a couple times its made the difference between whether or not Julia was a viable language for the problem.

So is there any way to either:

  1. Cache precompiled arbitrary modules using the current infrastructure in ~/.julia/compiled or
  2. Automatically cache modules not part of packages in the same directory as the file(s) with the module or
  3. Provide a documented way of creating .ji files programmatically for a given module from within julia code and also loading said .ji files if they already exist.

The documentation on module precompilation should also be fixed, but I'm not confident enough in my understanding of the relation between Base and Pkg to do so myself.

Guida contributor