We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The culprit code in question goes as follows:
function draw_scatter_and_line( xdata, ydata, gradient, constant_term, scatter_title, line_title, xlabel, ylabel, filename ) img_path = joinpath(@__DIR__, filename) # Generate plot object img = Plots.plot( xlabel=xlabel, ylabel=ylabel, legend=:bottomright) # Measurements Plots.scatter!( img, xdata, ydata, label=scatter_title, color=:steelblue) # Generate fit fit_x = [xdata[begin] - abs(xdata[end] / 10), xdata[end] + xdata[end] / 10] fit_y = gradient .* fit_x .+ constant_term # Draw fitted line: Plots.plot!( img, fit_x, fit_y, linestyle=:dash, label=line_title, color=:steelblue) # The bottleneck @time Plots.pdf(img, img_path) end
When called with
xdata = [i for i in 1:10] nA = maximum(xdata) / 5 noise = rand(-nA:nA/5:nA, length(xdata)) ydata = xdata + noise
the results are abysmal, especially regarding the number of allocations made:
8.972615 seconds (20.30 M allocations: 1.104 GiB, 4.26% gc time, 2.74% compilation time)
This is with just 10 data points! The issue occurs on Ubuntu 20.04 and Julia version 1.6.1. The used back-end is GR.
The text was updated successfully, but these errors were encountered:
This example isn't actually self contained, so I can't run, but is the timing the same if you run the function again?
Sorry, something went wrong.
julia> draw_scatter_and_line( xdata, ydata, 1.0, 2.0, "scaddle", "lime", "xl", "yl", "bob.png") 6.001535 seconds (16.79 M allocations: 941.686 MiB, 2.67% gc time, 45.99% compilation time) julia> @time draw_scatter_and_line( xdata, ydata, 1.0, 2.0, "scaddle", "lime", "xl", "yl", "bob.png") 0.014293 seconds (237.87 k allocations: 4.500 MiB) 0.015777 seconds (243.70 k allocations: 4.830 MiB) julia> @time draw_scatter_and_line( xdata, ydata, 1.0, 2.0, "scaddle", "lime", "xl", "yl", "bob.png") 0.014303 seconds (237.87 k allocations: 4.500 MiB) 0.015630 seconds (243.70 k allocations: 4.830 MiB) julia> @time draw_scatter_and_line( xdata, ydata, 1.0, 2.0, "scattere", "line", "xl", "yl", "bob.png") 0.015115 seconds (237.87 k allocations: 4.500 MiB) 0.016502 seconds (243.70 k allocations: 4.831 MiB)
The first call is really slow and once it compiles it gets better...
This should be better now with SnoopPrecompile. But overall, there might be a misunderstanding of the julia mechanism (jit compilation).
SnoopPrecompile
jit
No branches or pull requests
The culprit code in question goes as follows:
When called with
the results are abysmal, especially regarding the number of allocations made:
This is with just 10 data points! The issue occurs on Ubuntu 20.04 and Julia version 1.6.1. The used back-end is GR.
The text was updated successfully, but these errors were encountered: