JuliaArrays / JuliaArrays/StaticArrays.jl
Matrix exponential compiles slowly on Julia 1.0
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
Here's a simple example:
julia> using Pkg, LinearAlgebra, StaticArrays;
julia> v = @MMatrix zeros(Float64, 5, 5);
julia> v[2, 3] = -π;
julia> v[3, 2] = π;
julia> v
5×5 MArray{Tuple{5,5},Float64,2,25}:
0.0 0.0 0.0 0.0 0.0
0.0 0.0 -3.14159 0.0 0.0
0.0 3.14159 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
0.0 0.0 0.0 0.0 0.0
On Julia 1.1, this compiles and runs quickly
julia> @time exp(v)
8.741098 seconds (23.58 M allocations: 983.001 MiB, 8.48% gc time)
5×5 MArray{Tuple{5,5},Float64,2,25}:
1.0 0.0 0.0 0.0 0.0
-0.0 -1.0 -2.35127e-16 -0.0 -0.0
0.0 2.35127e-16 -1.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0
0.0 0.0 0.0 0.0 1.0
julia> versioninfo()
Julia Version 1.1.0
Commit 80516ca202 (2019-01-21 21:24 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin14.5.0)
CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, haswell)
julia> Pkg.status("StaticArrays")
Status `~/.julia/environments/v1.1/Project.toml`
[90137ffa] StaticArrays v0.11.0 #master (https://github.com/JuliaArrays/StaticArrays.jl)
On Julia 1.0, it takes nearly 50x longer:
julia> @time exp(v)
406.894653 seconds (24.31 M allocations: 1.512 GiB, 0.31% gc time)
5×5 MArray{Tuple{5,5},Float64,2,25}:
1.0 0.0 0.0 0.0 0.0
-0.0 -1.0 -2.35127e-16 -0.0 -0.0
0.0 2.35127e-16 -1.0 0.0 0.0
0.0 0.0 0.0 1.0 0.0
0.0 0.0 0.0 0.0 1.0
julia> versioninfo()
Julia Version 1.0.4
Commit 38e9fb7f80 (2019-05-16 03:38 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin15.6.0)
CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.0 (ORCJIT, haswell)
julia> Pkg.installed()["StaticArrays"]
v"0.11.0"
The culprit appears to be these lines
If I remove them and everything afterward, the function compiles and returns quickly. Also, if I interrupt the stalled command (exp(v)) with Ctrl+C, and then re-run the command, it runs instantly.
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 reproducible StaticArrays example and inspect src/expm.jl at lines 105-112, comparing Julia 1.0.4 with 1.1.0. Measure compilation and execution for exp(v), then identify whether the reported slowdown remains and document or test the resulting behavior.
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
- Clearly specified
- Newbie friendliness
- 35/100