JuliaArrays / JuliaArrays/StaticArrays.jl
massive slowdown for nested folding operations
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
Nested folding operations may lead to massive slowdowns, apparently from 32 bit numbers on:
julia> N = 32; T = Int16; v = [rand(T, N) for _ in 1:1000]; w = map(SVector{N}, v);
julia> @b sum(sum, $v)
11.637 μs
julia> @b sum(sum, $w)
1.401 μs
julia> N = 16; T = Int32; v = [rand(T, N) for _ in 1:1000]; w = map(SVector{N}, v);
julia> @b sum(sum, $v)
10.120 μs
julia> @b sum(sum, $w)
28.138 μs
julia> N = 16; T = Float32; v = [rand(T, N) for _ in 1:1000]; w = map(SVector{N}, v);
julia> @b sum(sum, $v)
10.656 μs
julia> @b sum(sum, $w)
29.554 μs
I've tried out several processors (all x86-64), with the same result. Maybe it's an LLVM issue. Is it known?
Julia Version 1.11.2
Commit 5e9a32e7af2 (2024-12-01 20:02 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 4 × Intel(R) Core(TM) i3-10110U CPU @ 2.10GHz
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
StaticArrays v1.9.13
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
Reproduce the Julia REPL benchmarks from the issue with StaticArrays v1.9.13, comparing nested sum on ordinary vectors and SVector values across the listed element types and sizes. Investigate the generated performance or compiler behavior to determine why some nested folds slow down, then document a confirmed cause and regression coverage or a focused fix.
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