Why can't some functions (CSV.File()) be precompiled?

Hi all!

I’m using PackageCompiler to speed up my Julia initialization time. I first run the code I usually run in a session with --trace-compile=~/Julia/trace-compilation.jl, then I create the sysimage with


using PackageCompiler

PackageCompiler.create_sysimage(
    ["CSV", "DataFrames", "Statistics",
     "Unitful", "Plots", "Debugger",
     "StatsPlots", "GLM"];
    precompile_statements_file="/home/alessandro/Julia/trace-compilation.jl",
    sysimage_path="~/Julia/reasonable-sysimage.so"
)

However then, when starting Julia with the new sysimage (using -t 4 -J ~/Julia/reasonable-sysimage.so), I noticed that some functions, like

f = open(register_init_csv_file)
register_dataframe = DataFrame(CSV.File(f))  # <---- THIS
register_grouped_df = groupby(register_dataframe, register_sym)
close(f)

are still “slow to start”. I think this is because they are not precompiled. However, I can’t understand why. I suppose it’s because the type signature of CSV.File() is not known at compile time. May it be? But so, why is it “fast” if I re-evaluate the code (after touching the file?

Thanks!