IJulia.jl icon indicating copy to clipboard operation
IJulia.jl copied to clipboard

much slower than terminal

Open XinyuWuu opened this issue 3 years ago • 3 comments

When I use IJulia with a costom sysimage created by PackageCompiler.jl, the code runs much slower.

my kernel:

{
  "display_name": "Julia costom sysimage 1.6.1",
  "argv": [
    "/home/wuxinyu/Programs/julia/bin/julia",
    "-i",
    "--color=yes",
    "--sysimage=/home/wuxinyu/.julia/environments/v1.6/mysys.so",
    "/home/wuxinyu/.julia/packages/IJulia/e8kqU/src/kernel.jl",
    "{connection_file}"
  ],
  "language": "julia",
  "env": {},
  "interrupt_mode": "signal"
}

my test code:

using Gadfly, RDatasets
set_default_plot_size(21cm, 8cm)

p1 = plot(dataset("HistData","DrinksWages"), x="Wage", y="Drinks",
    shape=[Shape.square], Scale.y_log10)

aww, mws = dataset("MASS", "Animals"), dataset("quantreg", "Mammals")
p2 = plot( layer(aww, x=:Body, y=:Brain, shape=["Brain weight"]),
    layer(mws, x=:Weight, y=:Speed, shape=["Run speed"]),
    Scale.x_log10, Scale.y_log10, Guide.xlabel("Body weight"),
    Guide.ylabel("Brain weight and Run speed"),
    Theme(point_shapes=[Shape.circle, Shape.star1], alphas=[0.0],
        discrete_highlight_color=identity) )
hstack(p1, p2)

When in the terminal it runs extremely fast, but in the notebook, it takes 12s. In both case the code is the first time been executed.

XinyuWuu avatar Apr 30 '21 17:04 XinyuWuu

This is just a guess, but could it be that using IJulia causes precompilation invalidations? Did you build the sysimage with IJulia? (If not, does building with IJulia included fix the issue?)

twavv avatar Apr 30 '21 20:04 twavv

PackageCompiler.create_sysimage([:Gadfly,:DataFrames,:Colors,:Dates,:OhMyREPL,:ColorSchemes,:Distributions,:RDatasets,:Compose,:Random,:CSV,:GLPK,:HDF5,:IterTools,:JSON,:JuMP,:Measures,:RData,:XLSX,:Printf,:Statistics,:CategoricalArrays,:IJulia], precompile_statements_file="compiler_trace.jl",sysimage_path="mysys.so")

It is my build command. I have include the IJulia, but it is still much slower. And I have test not only one piece of code, but more ploting code, so I don't think it is a guess.

IJulia did not causes precompilation invalidations, it runs faster than before(without precompiled sysimage), but it is much slower than terminal.

I think IJulia definitely slow down the speed in some way, but I don't know the reasons.

XinyuWuu avatar May 01 '21 02:05 XinyuWuu

I think you also need precompile display function that is used by IJulia. My repository https://github.com/terasakisatoshi/sysimage_creator will help you. It will reduce time to initialize Jupyter Kernel and plot for the first time. Have a try.

terasakisatoshi avatar May 16 '21 04:05 terasakisatoshi