What's actually inside precompiled Julia files?

Actually, many types are known when the module is loaded — any functions that are called during module initialization, along with any function for which precompile is called. The SnoopCompile package can automatically generate precompile statements for functions that are called during a program execution.

My understanding is that it’s currently the lowered+type-inferred code, plus the values of global variables (e.g. const foo = ...some expensive function...). When a precompiled module is loaded, only its __init__ function is called since the results of any top-level code execution (e.g. generated code via @eval statements or computation of global constants) were cached.

Since precompilation already has type-inferred code, caching machine code is “merely” a technical implementation issue, which is why we are pretty confident it will be completed in a future Julia version (now that the multithreading milestone in 1.3 has been achieved).

Use SnoopCompile.

4 Likes