[BoundaryValueDiffEq.jl] Avoid recompilation


I am trying to use the TwoPointBVPProblem from BoundaryValueDiffEq. I put my code in a file and runs it by including in the REPL. The code runs great but the first call to solve always triggers a (long) “recompilation” time. The next solve calls inside the files are ok. But if I keep the same REPL and include the file again, I always have this first precompilation time. Is there a way to avoid / improve it (apart from solution like PackageCompiler)?

Here is the full code and the timings on my machine. I am using BoundaryValueDiffEq - 5.7.1.

using BoundaryValueDiffEq

function f!(du, u, p, t)
    F0 = u[1]
    F1 = u[2]
    F2 = u[3]

    du .= F1, F2, 2 * F1 * (F2 / (F0 - p.myeps) - 1 / (p.r^2))

bc2a!(resid_a, u_a, p) = resid_a[1] = u_a[1]
bc2b!(resid_b, u_b, p) = resid_b .= u_b[1] + 1.0, u_b[2]

tspan = (-1.0, 0.0)
u0 = [-1.0, 0.0, 0.0] # I don't know how to use the init function

myeps = 1e-10
dt = 0.01
p = (r=1.0, myeps=myeps)
bvp = TwoPointBVProblem(f!, (bc2a!, bc2b!), u0, tspan, p; bcresid_prototype=(zeros(1), zeros(2)))
@time sol = solve(bvp, MIRK4(), dt=dt)
@time sol = solve(bvp, MIRK4(), dt=dt)
9.803415 seconds (2.23 M allocations: 153.588 MiB, 0.22% gc time, 99.98% compilation time: 100% of which was recompilation)
0.002087 seconds (13.48 k allocations: 1.517 MiB)

Open an issue, we’d have to dig into the compilation caches and see what’s missed.