JuliaSmoothOptimizers / JuliaSmoothOptimizers/LinearOperators.jl
Type inference and exponentially large compile times
- Dominant language
- Julia
- Stars
- 209
- Forks
- 46
- Avg merge
- 6h 50m
- Merged PRs (30d)
- 1
Description
Issue #97 seemed to fix problems with type inference taking an inordinate amount of time when stringing together several `LinearOperator`s. As far as I could tell, issue #97 was fixed, but the problem seems to be back in Julia 1.8.1. Please see below for a minimal working example + output on a fresh session of Julia 1.8.1 (I am using `v2.4.1`). Of course after running this another time in the same Julia session, the type inference is done and the whole thing takes very little time (as it would be expected)
```julia
# put in file lops.jl
# LinearOperator type stability
using LinearOperators
Ns = 4:17
function test_type_stability(N,n=5)
lops = [ LinearOperator(randn(n,n)) for i=1:N ]
C = hcat(lops...)
stats = @timed y = C*randn(n*length(lops))
return stats.time
end
ts = test_type_stability.(Ns)
for i=1:length(Ns)
println("t=$(ts[i]), N=$(Ns[i])")
end
```
Julia takes 46s to do type inference on a `hcat` of 17 operators:
```
julia> include("lops.jl")
t=0.160799892, N=4
t=0.063678277, N=5
t=0.053124796, N=6
t=0.052513037, N=7
t=0.061400427, N=8
t=0.061368384, N=9
t=0.072215448, N=10
t=0.11183163, N=11
t=0.242638285, N=12
t=0.639014602, N=13
t=1.658588125, N=14
t=5.229325223, N=15
t=14.906830724, N=16
t=46.837328005, N=17
```
Contributor guide
Assessment
This issue has not been assessed yet.