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

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> @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> @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?

1 Like

Hmm

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.

2 Likes

I think it may be related to splatting the dimensions, if I replace dims... with explicit m, n in the original definition, I can restore the performance again.