PackageCompiler: enable --trace-compile for Jupyter session

I am using Jupyter notebook with Interact and Makie for displaying widgets and plots and I would like to quicken the startup time.
I already compiled a sysimage with Makie and it’s getting better, but displaying a scene for the first time still takes ~40s. I tried using a precompilation file where I call one of the Makie plot functions, but I didn’t get much improvement. (I cannot add Interact to the sysimage because widgets will not work, I think some WebIO functionality gets broken).
I think that for better startup time I need to catch the compilation statements used for WGLMakie (for displaying in a web based environment), but I don’t know how to pass --trace-compile when I start the Jupyter notebook from REPL, since the Jupyter kernel is different from the session from which I call notebook().
Any ideas? Thank you.

You could install a new kernel (Installation · IJulia) that has e.g. --trace-compile=ijulia_precompile.jl as one of the arguments. Then you can run a session and record stuff to that file.

1 Like

Thank you! I used your suggestion and generated ~ 3600 precompile statements. In the beginning most of them errored because they are related to modules not directly imported(but used by Interact and Makie). I added all needed packages and managed to precompile most of the statements, apart from a few which still errored (due to some Symbol("#5454") not defined). Is adding all the packages the right way to precompile?

After using the precompilation file in the sysimage I roughly cut in half the initial run time(20s). This is a good improvement, but I suspect there is more compilation going on.

I’m not familiar with the Julia/PackageCompiler internals, so I would seize this occasion and ask an additional question: Is PackageCompiler + precompile_file adding machine code or just inference results to the sysimage?