Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executable takes a very long time to start up #28

Closed
pron opened this issue Dec 30, 2016 · 20 comments
Closed

Executable takes a very long time to start up #28

pron opened this issue Dec 30, 2016 · 20 comments

Comments

@pron
Copy link

pron commented Dec 30, 2016

Hi.
I've used build_executable to compile a very simple program:

function main()
    for x in ARGS
        println("Hi: $x")
    end
end

The produced executable takes over 6 seconds to run!

What is happening in those 6 seconds? Is it compilation? Is there a way to precompile everything I need?

@blegat
Copy link
Contributor

blegat commented Dec 30, 2016

This is a follow up from this reddit post

@ihnorton
Copy link

ihnorton commented Dec 30, 2016

The issue is that the output of BuildExecutable does not actually load the associated precompiled image, so everything must be JIT'd again before the app can do anything. You can get normal (faster) startup by specifying the image manually:

JULIA_SYSIMAGE=libapp.dylib ./app Hello

(from the build directory, using the build command from your reddit post)

@pron
Copy link
Author

pron commented Dec 30, 2016

It works! Thank you very much. You may want to consider adding it to the README.
Could this be automatically done by the executable?

P.S.

I'm very new to Julia. Where is the best place to ask questions? Reddit? SO? discourse.julialang.org?

@MatthiasErdmann
Copy link

Hi,
I am also very new to Julia (have been using Matlab/Python for many years). I am using Julia 0.5.0 64bit on Windows and have tried to compile a simple program using build_executable, but I have not been successful - the process always breaks with a Load Error:

ERROR: LoadError: failed process: Process('C:\Users\merdmann\.julia\v0.5\WinRPM\deps\usr\x86_64-w64-mingw32\sys-root\mingw\bin\gcc.exe' '-LC:\Julia-0.5.0\bin' -shared -ljulia -lssp -o 'C:\Julia-0.5.0\bin\libapp.dll' 'C:\Julia-0.5.0\bin\libapp.o', ProcessExited(1)) [1]
in pipeline_error(::Base.Process) at .\process.jl:616
in run at .\process.jl:592 [inlined]
in link_sysimg(::String, ::String, ::Bool) at C:\Users\merdmann.julia\v0.5\BuildExecutable\src\build_sysimg.jl:151
in (::##2#3{Bool,String})() at C:\Users\merdmann.julia\v0.5\BuildExecutable\src\build_sysimg.jl:80
in cd(::##2#3{Bool,String}, ::String) at .\file.jl:48
in #build_sysimg#1(::Bool, ::Bool, ::Function, ::String, ::String, ::String) at C:\Users\merdmann.julia\v0.5\BuildExecutable\src\build_sysimg.jl:38
in (::#kw##build_sysimg)(::Array{Any,1}, ::#build_sysimg, ::String, ::String, ::String) at .<missing>:0
in include_from_node1(::String) at .\loading.jl:488
in process_options(::Base.JLOptions) at .\client.jl:262
in _start() at .\client.jl:318
while loading C:\Users\merdmann.julia\v0.5\BuildExecutable\src\build_sysimg.jl, in expression starting on line 187

Would you mind to help me with this problem? Thanks a lot!

@blegat
Copy link
Contributor

blegat commented Jan 2, 2017

Julia just says that the command has failed and does not give more info.
Could you run the command (i.e. C:\Users\merdmann\.julia\v0.5\WinRPM\deps\usr\x86_64-w64-mingw32\sys-root\mingw\bin\gcc.exe' '-LC:\Julia-0.5.0\bin' -shared -ljulia -lssp -o 'C:\Julia-0.5.0\bin\libapp.dll' 'C:\Julia-0.5.0\bin\libapp.o) in a terminal and tell us the output ?

@MatthiasErdmann
Copy link

Unfortunately, the command does not produce any output - the command syntax seems to be incorrect.

The final Julia error message is:

LoadError: failed process: Process('C:\Julia-0.5.0\bin\julia' 'C:\Users\merdmann\.julia\v0.5\BuildExecutable\src\build_sysimg.jl' 'C:\Julia-0.5.0\bin\libapp' native 'C:\Users\merdmann\AppData\Local\Temp\jl_D63E.tmp\userimg.jl' --force, ProcessExited(1)) [1]
in pipeline_error(::Base.Process) at .\process.jl:616
in run at .\process.jl:592 [inlined]
in #build_executable#1(::Bool, ::Bool, ::Function, ::String, ::String, ::String, ::String) at C:\Users\merdmann.julia\v0.5\BuildExecutable\src\BuildExecutable.jl:116
in build_executable(::String, ::String, ::String, ::String) at C:\Users\merdmann.julia\v0.5\BuildExecutable\src\BuildExecutable.jl:54
in include_string(::String, ::String) at .\loading.jl:441
in include_string(::Module, ::String, ::String) at C:\Users\merdmann.julia\v0.5\CodeTools\src\eval.jl:32
in (::Atom.##61#64{String,String})() at C:\Users\merdmann.julia\v0.5\Atom\src\eval.jl:81
in withpath(::Atom.##61#64{String,String}, ::String) at C:\Users\merdmann.julia\v0.5\CodeTools\src\utils.jl:30
in withpath(::Function, ::String) at C:\Users\merdmann.julia\v0.5\Atom\src\eval.jl:46
in macro expansion at C:\Users\merdmann.julia\v0.5\Atom\src\eval.jl:79 [inlined]
in (::Atom.##60#63{String,String})() at .\task.jl:60
while loading C:...\julia_sandbox\compilejulia.jl, in expression starting on line 2

My Julia version is 0.5.0 release x86_64-w64-mingw32 - but why mingw32? Does this point to a 64bit/32bit conflict?

@blegat
Copy link
Contributor

blegat commented Jan 2, 2017

What I meant is executing the gcc command outside julia. If this commands has now output it means that it succeeded. Did you run

gcc.exe '-LC:\Julia-0.5.0\bin' -shared -ljulia -lssp -o 'C:\Julia-0.5.0\bin\libapp.dll' 'C:\Julia-0.5.0\bin\libapp.o

?

@MatthiasErdmann
Copy link

Ok - indeed, when leaving out all single quotation marks (but only then),
gcc.exe -LC:\Julia-0.5.0\bin -shared -ljulia -lssp -o C:\Julia-0.5.0\bin\libapp.dll C:\Julia-0.5.0\bin\libapp.o
does succeed (has no output).

@blegat
Copy link
Contributor

blegat commented Jan 3, 2017

Good catch ! Let's see what @dhoegh thinks about it. Could you use the "Insert code" button to format the codes in your posts ? it makes it a lot more readable ;)

@MatthiasErdmann
Copy link

Ok, By the way, I just tried compiling under Linux (Ubuntu 16.04) and got a similar error.

@dhoegh
Copy link
Owner

dhoegh commented Jan 3, 2017

@MatthiasErdmann I have looked into the issue you are having and it is not related to this issue. The main issue you are having is probably related to the issue I am displaying below. If I am trying to run the command manually in CMD on windows I get the following error:
image
@MatthiasErdmann I suspect that when you execute the command manually you use a globally installed GCC while BuildExecutable uses a local one, installed by WinRPM in something like C:\Users\d-hoe\.julia\v0.5\WinRPM\deps\usr\x86_64-w64-mingw32\sys-root\mingw\bin\gcc.exe.

Do any one have an idea what is causing the build to fail with missing libwinpthread-1.dll? I suspect it is caused by an newer GCC. Appveyor has just begun failing, while a month old build succeeded.

@dhoegh
Copy link
Owner

dhoegh commented Jan 3, 2017

From http://download.opensuse.org/repositories/windows:/mingw:/win64/openSUSE_Factory/x86_64/ it seems the GCC version was updated 2016-12-30.

@MatthiasErdmann
Copy link

Actually, I have used the local gcc installed by WinRPM - Pkg.add("BuildExecutable") leads to the installation of gcc version 6.3.0 under C:\Users\"me"\.julia\v0.5\WinRPM\deps\usr\x86_64-w64-mingw32\sys-root\mingw\bin.
However, I get no error message concerning libwinpthread-1.dll. I don't know if this might give hint, but during installation of the BuildExecutable package there is an INFO: "Multiple package candidates found for mingw64-unistd-pthread-devel, picking newest".

@boonpingng
Copy link

boonpingng commented Jan 4, 2017

Hi,

@MatthiasErdmann, I have the same problem.

You need to path your "C:\Users"me".julia\v0.5\WinRPM\deps\usr\x86_64-w64-mingw32\sys-root\mingw\bin" in order to run the libwinpthread-1.dll. But after running, nothing happen.

image

Seem like the system execute the comment but there are no .exe file generated.

@pron
Copy link
Author

pron commented Jan 4, 2017

I'm experiencing the same problem as @MatthiasErdmann on Windows. I'll report more details tomorrow.

@dhoegh
Copy link
Owner

dhoegh commented Jan 4, 2017

Good news, I have a fix for the windows issue in #30.

@MatthiasErdmann
Copy link

Thank you! Adding the bin dir of the local gcc (C:\Users\"me"\.julia\v0.5\WinRPM\deps\usr\x86_64-w64-mingw32\sys-root\mingw\bin) to $PATH works for me.

@boonpingng
Copy link

Thanks dhoegh.

@dhoegh
Copy link
Owner

dhoegh commented Jan 5, 2017

I have now changed so BuildExecutable to use precompiled image in #32. Please do a Pkg.checkout("BuildExecutable") and verify it fixes the problem.

@pron
Copy link
Author

pron commented Jan 6, 2017

It works (at least on Mac). Thank you very much for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants