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.