PackageCompiler

The Problem

  • Julia is statically compiled at runtime
  • Speed like C++, dynamic scripting like with Python

=> buy into the same compilation times as C++ ... EVERY TIME!

Atom or Revise.jl

The solution:

  • to just keep Julia running
  • Julia only needs to compile small diffs

Still problematic:

  • employ to environments where Julia can't compile (wasm, embedded, ...)
  • deploy software to users that require maximum usability (no Julia install, no patience for startup times)
  • Wrappers in other languages for Julia packages
  • running Julia scripts in the cloud (time is money and it's impossible to keep Julia running)
  • developer convenience (after all, even with Atom things can crash and require restart)

The Solution: PackageCompiler

ahead of time compilation in Julia:

test1(a, b) = a + b
test2(a, b) = a + b
# compile only one
precompile(Tuple{typeof(test1), Int, Int})
@time test1(1, 2)
@time test2(1, 2);

Compiling a Package Ahead of Time

apt-get update
apt-get install libcairo2 -y
pkg"up; add PackageCompiler AbstractPlotting CairoMakie MakieGallery StatsMakie ColorBrewer"
using PackageCompiler
sys_new, sys_old = PackageCompiler.compile_incremental(:CairoMakie);
using CairoMakie, AbstractPlotting
scatter(rand(10))
cp(sys_new, sys_old, force = true) # replace system image
"/usr/local/julia/lib/julia/sys.so"

Outlook

When working nicely, this can be bigger than the combination of Python & C/C++!

  • Julia is still fully dynamic, even for the AOT compiled parts
  • even more so: one still has all the cool Julia features like @which or @edit available even for that parts that would usually require C/C++
  • Interprocedural Optimization is still possible in all cases!
  • One can decide what to compile dynamically!