# Performance degradation of \`fill\` in latest Julia 0.7 Dev?

**URL:** https://discourse.julialang.org/t/performance-degradation-of-fill-in-latest-julia-0-7-dev/9648
**Category:** Performance
**Created:** [March 11, 2018, 8:20pm UTC](https://discourse.julialang.org/t/performance-degradation-of-fill-in-latest-julia-0-7-dev/9648 "2018-03-11T20:20:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)
#### Post date: [March 11, 2018, 8:20pm UTC](https://discourse.julialang.org/t/performance-degradation-of-fill-in-latest-julia-0-7-dev/9648/1 "2018-03-11T20:20:20Z")

</div>

I’m not sure if this has already been observed by someone, but I searched and didn’t find anything. The performance of `fill` is very slow in 0.7 in comparison to 0.6.2 or an explicit loop. The following results are from 0.7 installed today:

```julia
julia> @btime fill(0.0,5,5)
  814.123 ns (2 allocations: 368 bytes)
5×5 Array{Float64,2}:
 0.0 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0 0.0

```

and the results in 0.6.2:

```julia
julia> @btime fill(0.0,5,5)
  33.100 ns (1 allocation: 336 bytes)
5×5 Array{Float64,2}:
 0.0 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0 0.0
 0.0 0.0 0.0 0.0 0.0

```

Any thoughts?

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [March 11, 2018, 8:47pm UTC](https://discourse.julialang.org/t/performance-degradation-of-fill-in-latest-julia-0-7-dev/9648/2 "2018-03-11T20:47:50Z")

</div>

Hmm

```julia
julia> @btime fill(0.0, 5, 5);
  972.071 ns (2 allocations: 368 bytes)

julia> @btime fill!(Array{Float64}(undef, 5,5), 0.0);
  50.922 ns (1 allocation: 336 bytes)

```

The second expression is literally the definition of `fill`…

Edit: The difference is that on 0.7 the definition for `fill!` gets inlined which trashes performance for some reason.

---

<div class="post-metadata">

### Author: ![Seif\_Shebl](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@Seif\_Shebl](https://discourse.julialang.org/u/Seif_Shebl)
#### Post date: [March 11, 2018, 9:16pm UTC](https://discourse.julialang.org/t/performance-degradation-of-fill-in-latest-julia-0-7-dev/9648/3 "2018-03-11T21:16:25Z")

</div>

I think it may be related to splatting the dimensions, if I replace `dims...` with explicit `m, n` in [the original definition](https://github.com/JuliaLang/julia/blob/f738de4e9fd747969c320afe90471e80d9f69704/base/array.jl#L349), I can restore the performance again.
