Yes, but the way itās written isnāt fair because it makes it sound like itās harmful in any case other than running the same code once or twice:
If you just wish to run the code once or twice then Juliaās long compilation may be something you want to avoid.
Thatās false. For one thing, compilation-time is fixed. You donāt have to āsolve a problem twiceā to get side step compilation time if the calculation is long since at that point it wonāt cause any noticable difference anyways (Iāve enountered that some people believe āthe compilation runā is somehow slower: no, thatās not the case. All it does it compile first. Thereās no type-instabilities in the first run or anything like that.)
Also, the problem is constrained to only the first call, even if a different optimization problem is solved. Hereās an example:
using Distributions, Optim
# hard coded data\observations
odr=[0.10,0.20,0.15,0.22,0.15,0.10,0.08,0.09,0.12]
Q_t = quantile.(Normal(0,1), odr)
# return a function that accepts `[mu, sigma]` as parameter
function neglik_tn(Q_t)
maxx = maximum(Q_t)
f(Ī¼Ļ) = -sum(logpdf.(Truncated(Normal(Ī¼Ļ[1],Ī¼Ļ[2]), -Inf, maxx), Q_t))
f
end
neglikfn = neglik_tn(Q_t)
# optimize!
# start searching
@time res = optimize(neglikfn, [mean(Q_t), std(Q_t)]) # 7 seconds
@time res = optimize(neglikfn, [mean(Q_t), std(Q_t)]) # 0.0001 seconds
function neglik_tn2(Q_t)
maxx = maximum(Q_t)
f(Ī¼Ļ) = -sum(logpdf.(Truncated(Normal(Ī¼Ļ[1],Ī¼Ļ[2]), -Inf, maxx), Q_t))
f
end
neglikfn2 = neglik_tn2(Q_t)
@time res = optimize(neglikfn2, [mean(Q_t), std(Q_t)]) # 0.06 seconds
A more accurate statement is:
If you wish to solve only a single optimization problem and that problem takes <10 seconds, then Juliaās long initial compilation is something you want to avoid. For long enough problems, or for solving multiple optimization problems, the compilation time is not noticeable.
Maybe explain via some examples. I would write it as:
If you want to solve a problem that takes 3000 seconds to solve, the first time in a Julia session will make it take 3007 seconds making the total runtime more relevant to the total time than compilation. If you want to solve many 100 10 second optimization problems, the first will take 17 seconds, and subsequent calls will not have the compilation and will take roughly 10 seconds, making the total runtime 1007 seconds and thus the individual problem each is more relevant than the compilation time. If you want to solve a single 5 second optimization problem, itāll be 12 seconds. Thus the compilation time issue can be annoying for interactive use when you want to solve a single problem but doesnāt effect performance-sensitive uses.
Julia v0.7 does have an interpreter though which promises to reduce compilation time in exchange for less optimizations and this may be an interesting middle ground for the specific interactive use case. Additionally, tools like PackageCompiler.jl may become more common, limiting the āstartup timeā of package code that is noticed here.
So there is an issue, but IMO when you explain exactly what that issue is it becomes apparent that itās due to how itās being used, and whether that would be an issue for you is something for the reader to decide.