Make first call faster

Hello, I just started using Julia, I noticed that commands
using Plotly plot(rand(10))
perform slowly ~30s in first run, but faster ~2s in second run.
Could it be possible to cache that process to make it fast after Julia restart?

Kestutis,
Lithuanian University of Health Sciences

Hi @KestutisMa, welcome to Julia’s forums. Yes, we’re aware that time-to-first-plot is a major problem. It is being worked on and is one of the top priorities for compiler work:

Compiler latency has already been improved significantly in Julia 1.1 and will be much better in the upcoming Julia 1.2 release.

10 Likes

Hi Stefan, could you give some more details about those upcoming improvements? Don’t see them mentioned in the NEWS.md on master, and I just tried

julia> VERSION
v"1.1.0"

julia> @time using PyPlot
  3.730215 seconds (7.85 M allocations: 410.184 MiB, 3.51% gc time)

julia> @time plot(rand(10))
  0.536229 seconds (1.48 M allocations: 74.613 MiB, 2.85% gc time)

vs

julia> VERSION
v"1.2.0-DEV.663"

julia> @time using PyPlot
  3.732857 seconds (7.53 M allocations: 393.297 MiB, 4.65% gc time)

julia> @time plot(rand(10))
  0.954086 seconds (3.75 M allocations: 187.505 MiB, 11.52% gc time)

which makes me think that these improvements are not in master yet. Thanks in advance.

Are there still any improvements planned? :slight_smile:

Julia v1.2.0-rc2 during test is not exhibiting better compiler latency than v1.1.1:
PyPlot:

[kest@archlinux ~]$  /home/kest/Downloads/julia-1.1.1/bin/julia -e '@time begin using PyPlot; plot(rand(5)); end'
  6.444096 seconds (9.40 M allocations: 487.974 MiB, 3.28% gc time)
[kest@archlinux ~]$  /home/kest/Downloads/julia-1.2.0-rc2/bin/julia -e '@time begin using PyPlot; plot(rand(5)); end'
  6.471744 seconds (9.06 M allocations: 470.050 MiB, 3.48% gc time)

Blink.jl:

[kest@archlinux ~]$  /home/kest/Downloads/julia-1.1.1/bin/julia -e '@time begin using Blink; w = Window(); end'
 12.486431 seconds (20.14 M allocations: 1020.407 MiB, 4.91% gc time)
[kest@archlinux ~]$  /home/kest/Downloads/julia-1.2.0-rc2/bin/julia -e '@time begin using Blink; w = Window(); end'
 12.884873 seconds (21.32 M allocations: 1.054 GiB, 5.07% gc time

Sorry, am I doing something wrong?

I don’t remember 1.2 having any dramatic impact on any load times.

1 Like

Depending on what packages you care about, you could try https://github.com/JuliaLang/PackageCompiler.jl

It’s been tested for Plots.jl (GR backend), DataFrames.jl, Query.jl, Makie.jl. After you’ve compiled them (takes more than an hour if you compile all of the above), the packages load immediately and there is almost no waiting time until the first plot.

Caveat: Needs to be done after each update of a package, so it’s not useful for stuff you are developing.

I’ve used it for a while now and I’ve almost forgotten the time-to-first-plot issue :wink:

1 Like