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

**URL:** <https://discourse.julialang.org/t/slow-abstractarray-jl-indices-line-64-when-starting-julia-with-inline-no/11647>\
**Category:** General Usage\
**Tags:** performance\
**Created:** [June 13, 2018, 2:04pm UTC](https://discourse.julialang.org/t/slow-abstractarray-jl-indices-line-64-when-starting-julia-with-inline-no/11647 "2018-06-13T14:04:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zsoerenm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zsoerenm/32/664_2.png) [@zsoerenm](https://discourse.julialang.org/u/zsoerenm)\
**Post date:** [June 13, 2018, 2:04pm UTC](https://discourse.julialang.org/t/slow-abstractarray-jl-indices-line-64-when-starting-julia-with-inline-no/11647/1 "2018-06-13T14:04:21Z")

</div>

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

```julia
abstractarray.jl, indices: line 64

```

 ![slow_indices_with_arrows](https://global.discourse-cdn.com/julialang/original/3X/0/d/0db50841a67c1dba5f5977faca6796d3f9b33dbc.png)  
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

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [June 13, 2018, 3:13pm UTC](https://discourse.julialang.org/t/slow-abstractarray-jl-indices-line-64-when-starting-julia-with-inline-no/11647/2 "2018-06-13T15:13:32Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![zsoerenm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zsoerenm/32/664_2.png) [@zsoerenm](https://discourse.julialang.org/u/zsoerenm)\
**Post date:** [June 13, 2018, 5:51pm UTC](https://discourse.julialang.org/t/slow-abstractarray-jl-indices-line-64-when-starting-julia-with-inline-no/11647/3 "2018-06-13T17:51:42Z")

</div>

The easiest example I could come up with is this:

```julia
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()

```

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 13, 2018, 6:34pm UTC](https://discourse.julialang.org/t/slow-abstractarray-jl-indices-line-64-when-starting-julia-with-inline-no/11647/4 "2018-06-13T18:34:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 13, 2018, 6:45pm UTC](https://discourse.julialang.org/t/slow-abstractarray-jl-indices-line-64-when-starting-julia-with-inline-no/11647/5 "2018-06-13T18:45:41Z")

</div>

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:

```julia
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`?

---

<div class="post-metadata">

**Author:** ![zsoerenm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zsoerenm/32/664_2.png) [@zsoerenm](https://discourse.julialang.org/u/zsoerenm)\
**Post date:** [June 13, 2018, 6:53pm UTC](https://discourse.julialang.org/t/slow-abstractarray-jl-indices-line-64-when-starting-julia-with-inline-no/11647/6 "2018-06-13T18:53:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 13, 2018, 7:09pm UTC](https://discourse.julialang.org/t/slow-abstractarray-jl-indices-line-64-when-starting-julia-with-inline-no/11647/7 "2018-06-13T19:09:55Z")

</div>

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.
