-
Notifications
You must be signed in to change notification settings - Fork 148
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
slow down when @. assignment expression has more than 3 terms #797
Comments
Just noticed it's not exactly the number of terms: changing the assignment order
then there's no allocation and the speed is fast:
Also, changing the first Profiling with Juno suggests this line is dynamically dispatched: StaticArrays.jl/src/broadcast.jl Line 155 in 64c64b2
profiling script here. Note you may change the loop iteration number to higher or adjust |
Likely this is more or less the same issue as #682. |
Might be slightly different since here |
Small update: I've proposed a solution here: JuliaLang/julia#41090 . |
Not sure if it's a julia issue or StaticArrays issue: Assignment expressions such as
@. r = a + 5 * b + 3 * c - d
slows down dramatically when the right-hand-side has 4 terms [allocate and may be dynamically dispatched according to profile]:with standard array:
with static array
however, if tested with the function
g_ex!
which takes one term out of the assignment,benchmark:
so this is a ~650 slowdown (17.648 μs vs 26.951 ns). This is very noticeable when functions containing such expressions are in a deeply-nested/hot loop.
Also, it's ok when the assignment only has 3 terms in the function
g3!()
benchmark:
The text was updated successfully, but these errors were encountered: