-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Large regression with StaticArrays in v1.11 #1102
Comments
I can reproduce those results in macOS. I found some interesting scenarios based on the proposed MWE: If I use this version, I see all the allocations: function mwe2(a, X, n)
local K
for i in 1:n
k = a * i
K = k * X * X'
end
return K
end
julia> @btime mwe2(1e-5, SVector{3}(1.0, 1.0, 1.0), 1_000_000)
163.540 ms (7000000 allocations: 289.92 MiB)
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
10.0 10.0 10.0
10.0 10.0 10.0
10.0 10.0 10.0 However, if I suppress the local variable function mwe3(a, X, n)
local K
for i in 1:n
K = a * i * X * X'
end
return K
end
julia> @btime mwe3(1e-5, SVector{3}(1.0, 1.0, 1.0), 1_000_000)
1.916 ns (0 allocations: 0 bytes)
3×3 SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
10.0 10.0 10.0
10.0 10.0 10.0
10.0 10.0 10.0 |
This is an inlining change function mwe1(a, X, n)
K = zeros(SMatrix{3,3})
for i in 1:n
k = a * i
K1 = k * X
K += @inline K1* X'
end
return K
end fixes it and its actually better |
Hi @gbaraldi !
Will those allocations happen on every call to that function (scalar x vector product) ? Or does it depend on the scenario? If so, I think I might experience a huge amount of performance degradation in our simulations. Is it something that might be reverted or fixed in 1.11? |
@gbaraldi what's the point with your example? As far as I see it's using different code paths so it seems irrelevant here? To be specific, the MWE is using a three-argument |
I don't remember in which release cycle (could well be in v1.11), but we introduced three-arg |
3-arg Edit: sorry this is scalar-vector-adjointvec, which now calls I am a bit surprised that the version with |
Time flies. 🤦 @nsajko: @gbaraldi's quote stems from an inspection of |
Should we close this, or is there anything actionable here? |
Closing - but please reopen if necessary. |
As also described in JuliaArrays/StaticArrays.jl#1282, there is a large performance regression with
v1.11
when usingStaticArrays
:Interestingly, the problem can be solved by changing
k * X * X'
tok * (X * X')
:The text was updated successfully, but these errors were encountered: