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

Why using Makie; lines(rand(5)); using sysimage generated from precompiles is about 5 times slower than compile_incremental(:Makie, :AbstractPlotting)? #4

Closed
KestutisMa opened this issue Aug 4, 2019 · 10 comments

Comments

@KestutisMa
Copy link

KestutisMa commented Aug 4, 2019

Makie.lines(rand(5)); is about 5 times slower after brute_build_julia() than PackageCompiler.compile_incremental(:Makie, :AbstractPlotting). But s = Scene() is fast.
Why could be that?
Maybe something is not precompiled when calling Makie.lines()?

@TsurHerman
Copy link
Owner

If I remember correctly you have blacklisted “AbstractPlotting” , maybe whitelist it and try again?

Fezzik is not meant to be optimal. It’s purpose is to be extremely simple to use and to allow you to actually use Julia and the eco-system of it without suffering too much from time to first ..you know.

@KestutisMa
Copy link
Author

KestutisMa commented Aug 4, 2019

I have no packages blacklisted, with modified gf.c and codegen.c segfaults are gone during sysimages generation of Makie, Blink and Interact. It is interesting why such difference could appear, is seems that some functions are still compiled JIT. I am interested in technical side.

@TsurHerman
Copy link
Owner

TsurHerman commented Aug 5, 2019

I am interested in technical side.

Ok I see, my theory is that some function goes "stale" when you add other functions to the global method table...(related maybe to the assertions?) and so they need to be recompiled again.

For my use case, I build a sysimg 10-15 times (working in one window and building in the other)
and only after a while I see the number of new statements to precompile drop to below 10

you should check out also the precomp.jl file and the traces directory to see which functions are being compiled

@KestutisMa KestutisMa changed the title Why Makie.lines(rand(5)); is about 5 times slower after brute_build_julia() than PackageCompiler.compile_incremental(:Makie, :AbstractPlotting)? Why sysimage generated from precompiles from using Makie; lines(rand(5)); is about 5 times slower than compile_incremental(:Makie, :AbstractPlotting)? Aug 7, 2019
@KestutisMa KestutisMa changed the title Why sysimage generated from precompiles from using Makie; lines(rand(5)); is about 5 times slower than compile_incremental(:Makie, :AbstractPlotting)? Why using Makie; lines(rand(5)); using sysimage generated from precompiles is about 5 times slower than compile_incremental(:Makie, :AbstractPlotting)? Aug 7, 2019
@KestutisMa
Copy link
Author

I tried with and without assertions, same result (speedup is notable but still lesser).

  1. Maybe some functions are not precompiled using using Makie; lines(rand(5)); but compiled when compile_incremental is using Makie runtests.jl file for snooping (default PakageCompiler behavior)? I tried to launch julia with --compile=all flag, but I saw parsing error while tired run brute_build_julia().
  2. I ran brute_build_julia() second and third time and Fezzik genereted same precompiles, so maybe you are right about "stale" functions. But then why compile_incremental(:Makie, :AbstractPlotting) is compiling with greater speedup? maybe in that case not all functions are precompiled in that way that make them get "stale"?

Also, I tied run julia with --trace-compile flag (as mentioned in https://nextjournal.com/sdanisch/packagecompiler-talk) and replace Fezzik traces file with generated precompile file and I got same results as using Fezzik alone.

@KestutisMa
Copy link
Author

Found one difference in how PackageCompiler generates precompiles from snooping, it's compile=all option:

https://github.com/JuliaLang/PackageCompiler.jl/blob/a403d8f3c69870e24cd41cc746bef4e926c5b055/src/snooping.jl#L32

Perhaps that could be cause.

@TsurHerman
Copy link
Owner

try with the newest version of Fezzik, see if it is resolved

@TsurHerman TsurHerman reopened this Aug 16, 2019
@KestutisMa
Copy link
Author

Thanks for update, but after compiling sysimage Makie.lines(rand(5)) was same speed as with previous Fezzik version. I also tried provide Fezzik traces generated by julia --compile=all -O0 -g0 --trace-compile=traces.jl myscript.jl, there were no parsing errors this time, but Makie.lines(rand(5)) speed was the same.

I also posted here: https://discourse.julialang.org/t/why-using-makie-lines-rand-5-using-sysimage-generated-from-precompiles-is-about-5-times-slower-than-compile-incremental-makie-abstractplotting/27808
It would be nice to know why this happens.

Only few errors (but I don't think that this could effect Makie):

compiling line 146
┌ Info: UndefVarError(:WebIOServer)
│   LINE = 146
└ @ Main.##anon_module#377 /home/kest/.julia/packages/Fezzik/wdHmF/precomp.jl:149
compiling line 801
┌ Info: UndefVarError(Symbol("##96#97"))
│   LINE = 801
└ @ Main.##anon_module#377 /home/kest/.julia/packages/Fezzik/wdHmF/precomp.jl:804
compiling line 911

@KestutisMa
Copy link
Author

Maybe this could fix this JuliaLang/julia#33006

@TsurHerman
Copy link
Owner

We will see when it is merged

@TsurHerman
Copy link
Owner

@KestutisMa do you have any update on this?

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

2 participants