Let me start by saying I’m very new to issues regarding compilation.
(I never heard of compilation when I used Matlab-R-STATA.)
Suppose I load a Julia package AAA.jl
with one function f(x,y)
.
The first time I call f(x,y)
is usually slow for a given set of argument types. But it is usually much faster after that.
using AAA
f(1,2) # usually slow, compiles f(Int,Int)
f(1,2) # much faster
f(2,5) # equally fast
f(2.0,5) # slow again, must compile f(Float,Int)
f(2.0,5) # faster
When I run the following w/ ARCHModels.jl:
using ARCHModels
@time selectmodel(TGARCH,BG96,minlags=1,maxlags=1)
@time selectmodel(TGARCH,BG96,minlags=1,maxlags=1)
@time selectmodel(TGARCH,BG96,minlags=2,maxlags=2)
@time selectmodel(TGARCH,BG96,minlags=2,maxlags=2)
@time selectmodel(TGARCH,BG96,minlags=3,maxlags=3)
@time selectmodel(TGARCH,BG96,minlags=3,maxlags=3)
@time selectmodel(TGARCH,BG96,minlags=1,maxlags=3)
@time selectmodel(TGARCH,BG96,minlags=1,maxlags=3)
The compilation time becomes slow every time I change the number of lags, even though the types of each argument is the same:
julia>
5.247489 seconds (18.78 M allocations: 927.158 MiB, 6.23% gc time)
0.005477 seconds (2.68 k allocations: 212.594 KiB)
1.121684 seconds (3.90 M allocations: 183.957 MiB, 4.12% gc time)
0.012191 seconds (10.07 k allocations: 1.081 MiB)
1.179797 seconds (4.01 M allocations: 188.687 MiB, 5.05% gc time)
0.018243 seconds (10.68 k allocations: 1.540 MiB)
25.694519 seconds (90.85 M allocations: 4.179 GiB, 3.69% gc time)
0.098000 seconds (282.74 k allocations: 32.622 MiB)
julia>
Can this be improved?