Compiled program from PackageCompiler is much slower than REPL?

Hi, Community members.
Recently, I want to compile my code to an executable program, but I have the speed problem.

I develop my program based on a package JuliaGrid. In this package, it calls many other packages, like, SparseArrays, HDF5, JuMP… When I run the functions in the REPL, it is very fast and takes 0.1s. However, after I compile it with PackageCompiler,
(create_app("C:\\Users\\lin\\.julia\\dev\\JuliaGrid",".\\dist\\se",force=true)),
it is really slow in the cmd window, almost takes 18 seconds.

18.388602 seconds (34.03 M allocations: 1.645 GiB, 4.38% gc time)

If it takes 1 or 2 seconds slower, I can accept it, but this is too slow for me. Do I miss something when I compile it ? or I should set some parameters to improve this?

Thank you in advance!

Below is part of compile log:

create_app("C:\\Users\\lin\\.julia\\dev\\JuliaGrid",".\\dist\\se",force=true)
┌ Warning: ArrayInterface has a dependency on Requires.jl, code in `@require` will not be run
└ @ PackageCompiler C:\Users\lin\.julia\packages\PackageCompiler\xtztx\src\PackageCompiler.jl:510
┌ Warning: FiniteDiff has a dependency on Requires.jl, code in `@require` will not be run
└ @ PackageCompiler C:\Users\lin\.julia\packages\PackageCompiler\xtztx\src\PackageCompiler.jl:510
┌ Warning: Package TimeZones has a build script, this might indicate that it is not relocatable
└ @ PackageCompiler C:\Users\lin\.julia\packages\PackageCompiler\xtztx\src\PackageCompiler.jl:523
┌ Warning: Package HDF5 has a build script, this might indicate that it is not relocatable
└ @ PackageCompiler C:\Users\lin\.julia\packages\PackageCompiler\xtztx\src\PackageCompiler.jl:523
┌ Warning: Package Ipopt has a build script, this might indicate that it is not relocatable
└ @ PackageCompiler C:\Users\lin\.julia\packages\PackageCompiler\xtztx\src\PackageCompiler.jl:523
┌ Warning: Package GLPK has a build script, this might indicate that it is not relocatable
└ @ PackageCompiler C:\Users\lin\.julia\packages\PackageCompiler\xtztx\src\PackageCompiler.jl:523
[ Info: PackageCompiler: creating base system image (incremental=false)...
[ Info: PackageCompiler: creating system image object file, this might take a while...
┌ Warning: Package JuliaGrid does not have DifferentialEquations in its dependencies:
│ - If you have JuliaGrid checked out for development and have
│   added DifferentialEquations as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with JuliaGrid
└ Loading DifferentialEquations into JuliaGrid from project dependency, future warnings for JuliaGrid are suppressed.
WARNING: Method definition idx_bus() in module JuliaGrid at C:\Users\lin\.julia\dev\JuliaGrid\src\system\basic.jl:18 overwritten at C:\Users\lin\.julia\dev\JuliaGrid\src\system\basic.jl:18.
  ** incremental compilation may be fatally broken for this module **

Can you post your code here so that we can play with it?

3 Likes

I observed the same behavior. Any application built with Julia 1.4.2 and PackageCompiler 1.0 is fast. Built with anything newer is as slow as running all imports, precompilation and jít compilations in a fresh Julia session. I tested Julia 1.5.3 and 1.6.0-beta1 with PackageCompiler 1.2.5.

I recommend the MyApp sample from the PackageCompiler documentation - the one that reads a CSV file into DataFrame and prints the number of rows and columns in the df.

I tried to run the app from REPL before building it hoping the compiled code is used during app build, but apparently no success.

I’d like to bump this because I observed the same problem, not to mention that when using Julia 1.9 compiling with PackageCompiler simply fails for me.
Running the example app (~/.julia/packages/PackageCompiler/.../examples/MyApp) takes a good ~20 seconds