mbaz / Gaston.jl

A julia front-end for gnuplot.
MIT License
148 stars 30 forks source link

Second plot speed #133

Open PallHaraldsson opened 4 years ago

PallHaraldsson commented 4 years ago

FYI: Second plot speed is much better as expected (with fewer allocations), but only third plot has fewest allocations, and expected speed.

I wouldn't say this is an "issue", just an observation on non-master. I've only heard of "first-plot issues". I wander about the reason and if it applies to other (plotting) packages and master here. I've always relied on benchmarking code after running ONCE. It may not be about your package, rather julia (1.5)?

julia> @time using Gaston
  0.644211 seconds (1.04 M allocations: 53.019 MiB, 1.17% gc time)

julia> @time plot(randn(10^6),randn(10^6))
  0.377701 seconds (144.02 k allocations: 22.743 MiB, 1.71% gc time)

julia> @time plot(randn(10^6),randn(10^6))
  0.179409 seconds (53.69 k allocations: 17.984 MiB, 4.22% gc time)

julia> @time plot(randn(10^6),randn(10^6))
  0.047522 seconds (33 allocations: 15.261 MiB, 3.09% gc time)

julia> @time plot(randn(10^6),randn(10^6))
  0.043855 seconds (33 allocations: 15.261 MiB, 3.35% gc time)

It seems I ruled out issue with Julia itself or @time.

mbaz commented 4 years ago

@PallHaraldsson That's interesting behavior; I woud have expected the third and subsequent plots to take the same time as the second.

There are some performance-related changes on my local master branch that might affect this. After I release 0.11 (should be a few days now), I'll run some profiling and try to figure out what is going on.

The good thing is that even the first plot is very fast!

gcalderone commented 4 years ago

Is it possible that plot(randn(10^6),randn(10^6)) simply sends the commands to gnuplot, but do not wait for it to be completed?

On my computer I get consistent results with display(plot(randn(10^6),randn(10^6))).

mbaz commented 4 years ago

@gcalderone I need to look at this in more depth (after I manage to get the next release out). However, I think I'm waiting until gnuplot finishes plotting. Gaston tells gnuplot to print a message on stderr as the last step of a plot command, and does not return until it gets the message back.