JuliaArrays / JuliaArrays/StaticArrays.jl
Unexpected Performance Difference between / and \
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
I noticed significant speed differences for left (\) and right(/) matrix division for 4 by 4 and bigger matrices. To my understanding, / is just mapped to \ and thus, I wouldn't expect these differences especially not / being faster than \. Does anyone know why this is happening?
julia> using StaticArrays, BenchmarkTools
julia> @benchmark a \ b setup = begin
a = rand(SMatrix{4, 4})
b = rand(SMatrix{4, 4})
end
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 232.326 ns (0.00% GC)
median time: 234.532 ns (0.00% GC)
mean time: 260.624 ns (0.00% GC)
maximum time: 1.799 μs (0.00% GC)
--------------
samples: 10000
evals/sample: 442
julia> @benchmark a / b setup = begin
a = rand(SMatrix{4, 4})
b = rand(SMatrix{4, 4})
end
BenchmarkTools.Trial:
memory estimate: 0 bytes
allocs estimate: 0
--------------
minimum time: 183.468 ns (0.00% GC)
median time: 184.085 ns (0.00% GC)
mean time: 206.420 ns (0.00% GC)
maximum time: 4.133 μs (0.00% GC)
--------------
samples: 10000
evals/sample: 681
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the benchmark examples in issue #585, comparing left () and right (/) division for StaticArrays SMatrix values of size 4×4 and larger. Reproduce both timings with Julia, StaticArrays, and BenchmarkTools, then inspect the division paths to determine why their performance differs. Done means the cause is identified and a focused fix or documented explanation is supported by benchmark results.
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
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100