PackageCompiler - Understand how compilation works

I’m creating an app using PackageCompiler.jl as described here

I’m trying to create an executable of a simple backend application. PackageCompiler works fine since I am able to generate a binary to run my application.

What I didn’t expect is that the first time something is begin executed seems to be slower as if no compilation is made by PackageCompiler. The second time the call is fast as I expected form a normal execution by JIT.

So I’m not understading what kind of compilation is made during the process of create_app by PackageCompiler and how JIT works during execution time of the binary generated.


Well, only the parts of the code that are executed in the precompile_execution_file are fully compiled… Make sure your main usecase is covered here…

So even bundled binaries are compiled on the first execution, is that correct? Thanks.

PackageCompiler will not bundle binaries for any possible function you might call (this is impractical). With PackageCompiler you need to explicitly declare what you want to precompile and it will build the sysimage with the actual native code inside. The simple way to do this is described in the docs Sysimages · PackageCompiler

1 Like