haberdashPI/MetaArrays.jl

Performance of broadcasting operations on MetaArrays

Opened this issue · 0 comments

ymtoo commented

The MWE shows a huge performance difference between Matrix{Float64} and MetaArray(::Matrix{Float64}, Base.OneTo(1)).

x = randn(2000000, 16)
xminvals = minimum(x; dims=1)
xmaxvals = maximum(x; dims=1)
@btime Float64(10) .* (x .- xminvals) ./ (xmaxvals .- xminvals) 
# 101.110 ms (10 allocations: 244.14 MiB)

y = MetaArray(9600, x)
yminvals = minimum(y; dims=1)
ymaxvals = maximum(y; dims=1)
@btime Float64(10) .* (y .- yminvals) ./ (ymaxvals .- yminvals)
# 22.020 s (800000022 allocations: 14.54 GiB)

Julia and package versions:

julia> versioninfo()
Julia Version 1.7.3
Commit 742b9abb4d (2022-05-06 12:58 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)

(jl_l0qhTn) pkg> st
      Status `/tmp/jl_l0qhTn/Project.toml`
  [36b8f3f0] MetaArrays v0.2.10