Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broadcasting with FillArray allocates and is much slower #208

Closed
rmsrosa opened this issue Mar 3, 2023 · 1 comment · Fixed by #211
Closed

Broadcasting with FillArray allocates and is much slower #208

rmsrosa opened this issue Mar 3, 2023 · 1 comment · Fixed by #211

Comments

@rmsrosa
Copy link

rmsrosa commented Mar 3, 2023

I found an undesirable allocation when drawing from a MvNormal(I(n)) which boils down to broadcasting with FillArrays:

julia> u = rand(2); v = Zeros(2); w = collect(v);

julia> f(u, v) = ( u .+= v)
f (generic function with 1 method)

julia> @btime f($u, $v)
  47.824 ns (1 allocation: 80 bytes)
2-element Vector{Float64}:
 0.17323378731244632
 0.4293927595304291

julia> @btime f($u, $w)
  5.292 ns (0 allocations: 0 bytes)
2-element Vector{Float64}:
 0.17323378731244632
 0.4293927595304291

Might be somewhat related to #188 and #58

@jishnub
Copy link
Member

jishnub commented Mar 4, 2023

This isn't related to those issues, it's simply a badly implemented broadcasted method that materializes the result. Should be an easy fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants