-
Notifications
You must be signed in to change notification settings - Fork 36
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
Faster load times #130
Comments
When I tried timing the loading of PGFPlots myself, I observed some variation in the output of The following script computes the mean values of running using StatsBase: mean
function profileOnce(trialInfo::String)
output = read(`julia-1.3 --project=. -e "@time using PGFPlots"`, String)
print(trialInfo, output)
return output
end
function profile(n_trials::Int)
outputs = profileOnce.(map(i -> "Trial $i/$n_trials:", 0:n_trials))
data = hcat(map(
x -> parse.(Float64, [x[i] for i in 1:4]),
match.(
r" (\d+.\d+) seconds \((\d+.\d+) M allocations: (\d+.\d+) GiB, (\d+.\d+)% gc time\)",
outputs[2:end]
)
)...)' # parse all outputs into a Matrix{Float64} with shape (n_trials, 4)
p = mean(data, dims=1) # profiling results
println(
"Mean @time (ignoring the first output due to possibly required pre-compilation):\n",
" $(p[1]) seconds ($(p[2]) M allocations: $(p[3]) GiB, $(p[4])% gc time)"
)
end
profile(3) It's output on my machine:
|
Wow, that's a very long time. |
I have extended the above script to profile the load times of all dependencies. Here's the output, clearly dominated by
These loading times add up to 14.1 seconds. I do not know how the load time of a dependency precisely relates to the load time of a dependent package. For instance, lazy-loading Still, it might be valuable to check whether the load time of |
I ran the same script on the dependencies of ...Aaand here's the bad boy:
I wonder if there's any way to fix this. Poppler_jll is auto-generated by BinaryBuilder.jl. |
Wow, this is very helpful information. In Julia 1.5 on my old laptop, Poppler loads in under 4 seconds. That's still too long. We added Poppler to handle the conversion of pdfs to svg without having to rely on the binary |
Wow, I just reverted this PR locally, and bam:
Since I have |
Whoa. Can we load poppler conditionally if we try to compile and it is discovered that |
Long loading times seem to be a general problem with On Julia-1.5, things are already much faster than on earlier versions:
For comparison: PGFPlots took 16 seconds on Julia-1.3, Poppler took 8 seconds there (see above). It might be possible to set up a |
The JLL issue has been fixed (I'm not sure if the JLLs in this case have been regenerated too, but have for Gtk and it's much faster since minutes ago). On my 4 days old Julia 16 master 5.54 seconds, and:
so it could possibly be even faster, just as I know Gtk is faster still (under a sec) than on my older master. Also but 0.93 sec. and:
|
On my Julia 1.9.0 on Windows, I have 3.9 s for PGFPlots.jl, 2.9 s for Plots.jl, and 0.4 s for Poppler_jll. |
On my 1.9.0, apparently slower machine, I get:
While for:
Not much lower "compilation time" and also no "recompilation". And this is the culprit:
Or actually your largest single culprit (or its dependencies) is:
It seems it might be very important to this package (or not, since not a dependency of Plots.jl). I'm not sure, but could it be made an optional dependency? The package has an enormous Indirect Dependencies (150), thereof Packages (86) and Binary Artifacts (38), and none of those are a major problem:
OffsetArrays (why is it needed? it's been suggested for Base) is required by ImageCore which is required by your dependencies ImageMagick and Images.
|
Images.jl is used for PGFPlots.Image and PGFPlots.Histogram2. I'm perfectly fine with it being loaded on the fly since many users don't make Image and Histogram2 plots. |
I also just removed the ImageMagick.jl dependency since it is captured by Images.jl. |
[Off-topic, or seemingly not changing timing] DataFrames = "0.21, 0.22, 1.0" # note, no need to add e.g. 1.6, or keep 1.5, since implied, however you want to keep those pre-1.0 versions (dropping the lines allows even older?)? I.e. not (much) changed:
|
I'm looking at master and I still see the compat entries for DataFrames. I do want to limit it to version 1.5 because currently 1.6 fails (they are about to merge a fix, hopefully)---but for some reason the CI is still loading DataFrames 1.6 even though I think compat should be forcing it to 1.5. If you have thoughts on this or a solution, feel free to file a separate issue. Thanks! |
I managed much faster startup by, I guess (for now) braking some functionality, rather than delay loading it:
I was expecting a plot as in the docs, for the plot command, though since I got no error I went further, and think this s to be expected. I could make a (partial) PR/Draft. It's a trivial change so far. I don't even care that much about this exact package, don't use it, I just care about the (plotting) ecosystem in general, and investigating how startup time can be improved. I'm just using your package as a laboratory to test, and learn what the issues are. |
I believe I disabled Images.jl, why a got the time down so I'm still surprised to see:
Those are not your direct dependencies, only indirect, and do you know where they might come from? I went through all your direct dependencies at juliahub.com, but missed seeing it. I believe most that use StaticArrays, need not, should rather use the much faster StaticArraysCore only, directly. I can't notify all, but maybe notifying Images would be of help, if I'm correct not needed there. FYI: Looking up your package "PGFPlots.jl" doesn't find it, as with any with.jl (should be fixed there), and while "PGFPlots" finds it, it actually lists PGFPlotsX first. I would be curious why, and usually prefer alphabetical order, unless that one actually better... And it actually:
since:
In your case svg seems to be the main point, is the other a superset of your functionality, just different API? |
PGFPlotsX was designed after PGFPlots. PGFPlotsX was designed to be a relatively thin wrapper around the pgfplots latex package. PGFPlots, however, provides more functionality such as creating Images and 2D histograms easily. The API, therefore, is pretty different. PGFPlots requires generating PNG image files, and relies upon Images.jl. I'm not sure whether Images.jl can get away with just using StaticArraysCore. There does not appear to be an issue filed there yet. |
It would be great if something could be done to speed up the load time.
In Julia 1.2.0:
In Julia 1.3.1:
It could be that we just have to wait for improvements in the Julia compilation engine and that there is not much we can do right now.
The text was updated successfully, but these errors were encountered: