Hello,
I came across this weird performance issue, can someone please explain why using AMQPClient
causes ~100x performance drop?
julia> m = Matrix{Any}(rand(1000,1000));
julia> function f(m, n)
for i in 1:n
m = vcat(m, zeros(1, 1000))
end
end
f (generic function with 1 method)
julia> @time f(m, 10)
0.280798 seconds (355.77 k allocations: 94.275 MiB, 23.08% gc time)
julia> @time f(m, 10)
0.072561 seconds (10.04 k allocations: 76.945 MiB, 19.58% gc time)
julia> using AMQPClient
julia> @time f(m, 10)
6.048357 seconds (132.75 k allocations: 82.892 MiB, 0.17% gc time)
julia> @time f(m, 10)
6.084253 seconds (10.04 k allocations: 76.945 MiB, 0.17% gc time)
Henh. Strange. I don’t know what’s going on here. I can reproduce on julia 1.2.0 on Linux. But if I change m
to
m = rand(1000,1000)
then using AMPQClient
no longer causes a slowdown in f.
I was able to narrow it down to:
julia> m = Matrix{Any}(rand(1000,1000));
julia> function f(m, n)
for i in 1:n
m = vcat(m, zeros(1, 1000))
end
end
f (generic function with 1 method)
julia> @time f(m, 10);
0.306576 seconds (382.74 k allocations: 95.807 MiB, 37.96% gc time)
julia> @time f(m, 10);
0.064143 seconds (10.04 k allocations: 76.945 MiB, 18.77% gc time)
julia> import Base.convert
julia> struct MyType
end
julia> convert(::Type{Any}, o::MyType) = ""
convert (generic function with 186 methods)
julia> @time f(m, 10);
9.189991 seconds (154.01 k allocations: 84.212 MiB, 0.13% gc time)
3 Likes
Very interesting. Nice find. Are you able to open an issue about this?