Slow abstractarray.jl, indices: line 64 when starting julia with `--inline=no`

When I use ProfileView to profile my code it shows that most of the time is consumed in:

abstractarray.jl, indices: line 64


Every arrow is pointing to time consumed in abstractarray.jl, indices: line 64

Unfortunately, it often shows up at the very top of the stack trace after multiple julia calls, which makes it hard to debug.

Is there a way to circumvent this performance bottleneck?

BTW: This is julia 0.6.3

Without code it’s impossible to know what’s going on. But

https://github.com/JuliaLang/julia/blob/v0.6.3/base/abstractarray.jl#L64

it looks like you’re calling indices a lot, which is causing allocations, which wouldn’t be a good idea.

The easiest example I could come up with is this:

function norm_matrix(lut::Array{Complex{Float64}, 3})
  powers = sum(abs2.(lut), 1)
  max_gain = maximum(powers)
  lut ./ sqrt(max_gain)
end
using ProfileView
const A = complex.(randn(4,360,90), randn(4,360,90))
norm_matrix(A);
@profile norm_matrix(A);
ProfileView.view()
2 Likes

That’s a wonderful example — thank you! I’ll dig into this.

1 Like

Hm, with that example I don’t see indices appear at all in the profile. I did modify it slight to get it to work:

function norm_matrix(lut::Array{Complex{Float64}, 3})
  powers = sum(abs2.(lut), 1)
  max_gain = maximum(powers)
  lut ./ sqrt(max_gain)
end
const A = complex.(randn(4,360,90), randn(4,360,90))
norm_matrix(A);
@profile for _ in 1:10000; norm_matrix(A); end

Perhaps you’re calling a different norm_matrix?

Sorry, I forgot to mention that this is only visible when starting julia with --inline=no
I started julia with inline=no to see where the actual bottlenecks are, but I guess this makes it even worse?

Oooh, yeah, that’s not going to do what you want.

Julia’s performance is heavily dependent upon inlining. Sure, you might get more “accurate” stack traces, but the runtime performance will be so abysmally different that the report will be completely useless for identifying bottlenecks.

3 Likes