Looking for advice on achieving faster startup times

I am letting PackageCompiler.create_sysimage handle the details of the compilation. I am giving it as precompile_execution_file the same script I am using for timing, so I was hoping that it would be precompiling anything that is significantly expensive, but that may not be not the case. I have just checked, and there are a few statements that, when using the sysimage, still take in the order of 1-2 seconds (each) to run the first time they appear in the script, but not on subsequent instances. For example, the first call to print(Float64) still takes over 2 seconds when using the sysimage. The second such call takes <2ms.

I am not sure how much of that is due to precompilation, and how much due to non-cached vs. cached filesystem reads. Those times were measured after having run the script a few times, so I would expect that most of the filesystem reads are from cache, but I can’t be sure.

But at least half of the ~10 seconds that the script takes to run after rebooting the OS (i.e, with no filesystem caching) take place before any of the script statements start to be evaluated/precompiled. This initial overhead is similar to the time it takes Julia to “run” an empty script after a reboot (6 seconds).

3 Likes