JuliaLang/julia

Precompiling modules outside of packages

Open

#32,926 建立於 2019年8月16日

在 GitHub 查看
 (7 留言) (8 反應) (0 負責人)Julia (48,709 star) (5,773 fork)batch import
docshelp wanted

描述

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.

貢獻者指南