Very slow time to first plot, 2022

Here are my attempts to work with this. On my computer I lowered TTFX from 90sec to 4sec.

version info
julia> versioninfo()
Julia Version 1.9.0-DEV.1566
Commit ea991745a99 (2022-10-10 13:10 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 1700 Eight-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver1)
  Threads: 1 on 16 virtual cores
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 1

After precompiling and downloading datasets, I have the following:

julia> @time @eval include("plot.jl")
 85.086753 seconds (79.78 M allocations: 5.128 GiB, 3.66% gc time, 87.44% compilation time: 2% of which was recompilation)

gosh… This is ridiculously slow!

I used the sysimage builder from the VS code julia plugin. This was the JuliaSysimage.toml file I used:

[sysimage]
exclude=[]   # Additional packages to be exlucded in the system image
statements_files=[]  # Precompile statements files to be used, relative to the project folder
execution_files=["plot.jl"] # Precompile execution files to be used, relative to the project folder

I used your MWE as an execution file. Building the sysimage took 9 minutes.

With the sysimage I got:

julia> @time @eval include("plot.jl")
  3.846860 seconds (2.05 M allocations: 144.002 MiB, 1.33% gc time, 77.32% compilation time: 99% of which was recompilation)

The conclusion here is that I had to use an example workflow script in the generation of the sysimage, presumably because either CairoMakie or AlgebraOfGraphics is not using SnoopPrecompile. SnoopPrecompile is a tool that makes it easier for libraries to include example workflows which makes precompilation (and sysimages) more effective. I would suggest filing feature request issue to AlgebraOfGraphics. The ecosystem needs to use SnoopPrecompile more.

8 Likes