-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
View allocation elimination stumped by conditional? #28226
Comments
Actually, changing out |
Smells like the inlining heuristic change. |
I checked out the commit before #27857 and it didn't change anything. |
In fact, manually inlining shows the same regression: using BenchmarkTools
function colwise!(r, A, B)
@inbounds for j = 1:size(A,2)
a = view(A, :, j)
b = view(B, :, j)
r[j] = begin
if #= false && =# length(a) == 0 # Remove comment and fast
0.0
else
@inbounds begin
s = 0.0
for I in eachindex(a, b)
ai = a[I]
bi = b[I]
s += abs2(ai - bi)
end
s
end
end
end
end
r
end
using BenchmarkTools
z = zeros(41); A = rand(2, 41); B = rand(2, 41);
@btime colwise!($z, $A, $B); With and without
So I think inlining can be ruled out. |
Changing the Edit: Not enough on the original issue though. Removing Edit2: The final fix was to change |
Fixed, now zero allocations. |
Tracked down after performance report on Distances.jl (JuliaStats/Distances.jl#100)
Code to reproduce:
On 0.7:
On 0.6:
Now, if we comment away the
length(a) == 0 && return 0.0
line:0.7:
0.6:
The text was updated successfully, but these errors were encountered: