-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
[FR] Improve performance of plotting heatmaps #4520
Comments
@jlchan, can you check if |
Thanks @t-bltg. Using @BioTurboNick's snippet above with julia> @btime f($mat, 100)
511.680 ms (290431 allocations: 215.73 MiB) On julia> @btime f($mat, 100)
509.745 ms (81638 allocations: 207.71 MiB) |
Thanks, it's disappointing. |
Thanks for tackling this! I was going to poke around this week/weekend. Can still if you get stumped. |
I appreciate it! FYI I've found a workaround by adding another custom recipe. However, improving multiple |
There is still room ! |
Haha sorry. My system has 48 GB of RAM and caps out at 21 GB consumed by Julia. But you could easily cut the number down, Or cut the matrix size by half, too. I just chose a reasonably large one to show the effect, and I didn't pay attention to RAM usage haha. Manually running GC doesn't reduce the number here. Just holding on to all the plot series values looks like 19.5 GB of RAM. |
Let's focus on The problem in this loop is that we accumulate series, so when exporting to I've added the ability to empty the So now the example looks like: using BenchmarkTools, Plots
const mat = randn(512, 512)
f(x, n) = begin
pl = plot()
for _ in 1:n
empty!(pl) # clear out previous series
heatmap!(x)
end
pl
end
@btime f($mat, 100) # 597.178 ms (42561 allocations: 206.52 MiB) It still allocates too much, but we can now focus on |
Hum, @jlchan it would be better imo to have provide a contained mwe showing a real case scenario then. |
My suspicion is the problem is generic to number of series and size of data per series. |
Yeah, I observe a similar phenomena when plotting many series over each other. An example of where I usually see this is creating a scatter plot from a matrix x = randn(100,1000)
y = randn(100,1000)
z = randn(100,1000)
scatter(x, y, zcolor=z) This longer than My other use cases are similar, usually I loop over a list containing plot data input. I've been concatenating my plot arrays into one large array to avoid this issue. |
I can add a MWE involving triangulations if that's helpful, but as @BioTurboNick said I don't think the issue is unique to |
Reported on Slack by Jesse Chan, repeated calls to
plot!
to produce overlying heatmaps was very slow.Allocation profiler shows the large majority of allocations occurring in
heatmap_edges
:And the large majority of computation time in
expand_extrema!
(which callsheatmap_edges
) andupdate_clims
(my old nemesis):The text was updated successfully, but these errors were encountered: