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?

2 Likes