-
Notifications
You must be signed in to change notification settings - Fork 149
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
Allocations with StaticArrays in Julia v1.11 #1282
Comments
+=
in Julia v1.11
Interesting. This looks like a regression in Julia compiler. I'd have expected call-site |
I think this should have a corresponding issue in the julia repo since it is probably a regression there. |
+=
in Julia v1.11
@KristofferC I opened an issue in the julia repo. function mwe3(a, X, n)
K = zeros(SMatrix{3,3})
for i in 1:n
k = a * i
K += k * (X * X')
end
return K
end
@btime mwe3(1e-5, SVector{3}(1.0, 1.0, 1.0), 1_000_000); ❯ julia +1.10.5 --project -t 6 mwe.jl
805.458 μs (0 allocations: 0 bytes)
❯ julia +1.11.1 --project -t 6 mwe.jl
708.208 μs (0 allocations: 0 bytes) Since the problem is likely not related to |
Before Julia 1.7, I believe this would have done After 3-arg Strangely, using |
I am the main author of the package
Peridynamics.jl
and recently changed to Juliav1.11
.With the new Julia version, a significant increase in the simulation time can be found when using a certain material.
Peridynamics.jl Benchmark
Please see the following benchmark, which is also described in more detail in the tutorials (Tutorial mode I fracture).
The same simulation takes 29x longer on
v1.11.1
thanv1.10.5
.When investigating the problem, I narrowed it down to the calculation of the deformation gradient:
https://github.com/kaipartmann/Peridynamics.jl/blob/f9b8fe60e743d828cf96d2366610c6a69d7ac054/src/physics/correspondence.jl#L174-L194
MWE
The same behavior can be reproduced with a small MWE:
I think the problem is related to allocations when using
+=
with aSMatrix
orSVector
.As a quick fix, rewriting the calculation by hand leads to even slightly better performance on
v1.11
:The text was updated successfully, but these errors were encountered: