JuliaLang / JuliaLang/LinearAlgebra.jl

Large regression with StaticArrays in v1.11

Open
#1,102 11 comments 0 reactions 0 assignees View on GitHub
arrays
Dominant language
Julia
Stars
77
Forks
65
Avg merge
3d 23h
Merged PRs (30d)
10

Description

As also described in https://github.com/JuliaArrays/StaticArrays.jl/issues/1282, there is a large performance regression with `v1.11` when using `StaticArrays`:

```julia
using LinearAlgebra, StaticArrays, BenchmarkTools

function mwe1(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 mwe1(1e-5, SVector{3}(1.0, 1.0, 1.0), 1_000_000);
```
```bash
❯ julia +1.10.5 --project -t 6 mwe.jl
1.070 ms (0 allocations: 0 bytes)

❯ julia +1.11.1 --project -t 6 mwe.jl
129.890 ms (7000000 allocations: 289.92 MiB)
```
Interestingly, the problem can be solved by changing `k * X * X'` to `k * (X * X')`:
```julia
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-repl
❯ 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)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Run the provided mwe1 and mwe3 benchmarks with Julia +1.10.5 and +1.11.1, using the shown StaticArrays setup and threaded command. Compare allocations and timings, then trace the regression from the reproducer or the related StaticArrays issue. Done means the v1.11 behavior no longer shows the large allocation and performance regression.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.