Open timholy opened 6 months ago
Also note, gmmdisplay!(ax, mgmm; display=:solid)
is much faster:
julia> @time gmmdisplay!(ax, mgmm; display=:solid)
0.641004 seconds (294.02 k allocations: 42.550 MiB, 2.01% gc time)
Plot{Main.RecipeDemo.gmmdisplay, Tuple{IsotropicMultiGMM{3, Float64, Symbol}}}
when the figure is showing.
Performance is a lot faster when display=:solid
when panning around in Axis3. The :solid
method also has only 100 plots as opposed to 900...that might contribute to the issue?
Hmm, this was slower than I expected too:
julia> using GLMakie
julia> fig = Figure();
julia> ax = Axis(fig[1, 1]);
julia> for _ = 1:900
lines!(ax, randn(32))
end
julia> fig
julia> empty!(ax)
Axis with 0 plots:
julia> @time for _ = 1:900
lines!(ax, randn(32))
end
3.930636 seconds (6.22 M allocations: 398.483 MiB, 2.12% gc time)
So perhaps it's not a 3d-specific thing?
For comparison:
julia> @time begin
x = Float64[]
y = Float64[]
for _ = 1:900
append!(x, 1:32)
push!(x, NaN)
append!(y, randn(32))
push!(y, NaN)
end
lines!(ax, x, y)
end
0.413700 seconds (20.52 k allocations: 3.748 MiB, 7.54% compilation time)
Lines{Tuple{Vector{Point{2, Float32}}}}
Presumably there's a per-transfer overhead to the GPU memory? So bundling things together and doing the transfer in a lump is more efficient than doing them for each plotted object? Of course that's only possible when all the objects are of the same type.
If a shader is being compiled per plot, then I could imagine this being the result...the NaN-separation approach is definitely better here!
There's a pretty large overhead for each plot, not because of compilation though... You should be able to give most attributes per point, so it should not be too hard to vectorize, I hope!
Is that overhead once per display or constant? Because there's noticeably less lag when panning in LScene if the number of plots is decreased.
It's drawing and plot creation;) Might also run into lscenecamera specific performance problems with many plots
Performance probably suffers here because:
boundingbox.(scene.plots)
. Could be improved by caching bboxes, ref #4240Should we close this as a situation where performance degradation is expected? Or keep it around as something that caching boundingboxes may solve?
(I'm fine with whatever the devs think best.)
]activate --temp; add Makie
)System summary:
Display:
Note: using through WSL2!
Package versions
The actual demo
Starting from an empty folder,
activate
a new project and add the following packages:Then grab the code from this gist and save to the same folder.
Here's an annotated interactive session:
Profiling
gmmdisplay!(ax, mgmm)
reveals the bottleneck is this line.