Open
Description
Hi, I'm having a troublesome issue with vector of SVector.
When I try to convert an Vector{SVector{3,Float64} into a Nx3 Matrix for plotting, Julia doesn't return if the vector is too long.
It seems that SVector require a lots of memory allocation for the job and 99% most of the time is used in wasted compilation time. (See example below)
Normal Vector of Vector doesn't have this issue. It is possible the issue has already been flagged I didn't find it.
Normal Vectors:
julia> v = [zeros(3) for i in 1:10_000]
10000-element Vector{Vector{Float64}}:
[0.0, 0.0, 0.0]
⋮
[0.0, 0.0, 0.0]
julia> @time hcat(v...)
0.000528 seconds (7 allocations: 391.000 KiB)
3×10000 Matrix{Float64}:
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Issue:
julia> using StaticArrays
julia> v = zeros(SVector{3,Float64}, 100)
julia> @time hcat(v...)
@time hcat(v...)
5.367366 seconds (4.43 M allocations: 230.121 MiB, 0.62% gc time, 99.70% compilation time)
3×100 SMatrix{3, 100, Float64, 300} with indices SOneTo(3)×SOneTo(100):
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 … 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
if size is higher than 1000 the function just doesn't return anything.