Hacker News new | ask | show | jobs
by anonova 2541 days ago
Yes, this is ones of my problems with Julia. It seems to be optimized for long runs and REPL/notebook usage.

Take, for example, a simple program that creates a line plot (https://docs.juliaplots.org/latest/tutorial/):

    using Plots
    x = 1:10
    y = rand(10)
    plot(x, y)
After installing the package, the first run has to precompile(?), and subsequent runs use the package cache. But ~25 s to create a simple plot is incredibly slow and frustrating to work with.

    $ julia --version
    julia version 1.1.1
    $ time julia plot.jl
    julia plot.jl  73.71s user 4.45s system 110% cpu 1:11.04 total
    $ time julia plot.jl
    julia plot.jl  24.41s user 0.39s system 100% cpu 24.633 total
    $ time julia plot.jl
    julia plot.jl  23.38s user 0.36s system 100% cpu 23.519 total
3 comments

While this probably isn't a practical way to do any real work, running it with --compile=min gives some idea what might be possible soon:

    $ julia --compile=min -e '@time (using GR; plot(rand(20)))'
      0.375836 seconds (368.83 k allocations: 20.190 MiB, 1.65% gc time)
    $ julia --compile=min -e '@time (using Plots; plot(rand(20)))'
      4.302867 seconds (6.41 M allocations: 371.485 MiB, 5.07% gc time)
The time to second plot will be a few milliseconds, in the same process - in the same Julia session. So, while the time to first plot is frustrating, it is ok if your interactive session times are longer.

Of course, we continue to work on improving compile times. About half of the time is spent in LLVM compilation, which has actually become slower over time.

What prevents the plot compilation from being pre-compiled at install?
The Plots package adds a significant overhead right now. Try using PyPlot (matplotlib) directly. These days you can use exactly the same syntax (dot-call) as in Python.

   $ time julia -e "using PyPlot;x=1:10;y=rand(10);plot(x,y);"
   real    0m5.676s