Investigate long compile times

Hi,

Can someone give me hint on why the following call takes ~2mn to compile please? If you have an idea of the culprit and suggestions, I’d be very happy to hear them :smiley:

Thanks a lot for your help,

fold_po_coll = @time continuation(deepcopy(br_po), 1, (@optic _.c5), opts_pocoll_fold;
        detect_codim2_bifurcation = 0,
        jacobian_ma = :minaug,
        bdlinsolver = BorderingBLS(solver = DefaultLS(), check_precision = false),
        )

The function calls continuation_coll_fold and then the general continuation_fold. In comparison, calling the function continuation_coll_pd does not lead to large compiles times (~10s).

I know that I have closures in continuation_fold but this is true for continuation_pd and this does not seem to cause large compile times.

Below is a MWE to show the compile time:

using Revise
using BifurcationKit

function Fsl(u, p)
    (;r, μ, ν, c3, c5) = p
    u1, u2 = u
    f = similar(u)
    ua = u1^2 + u2^2
    f[1] = r * u1 - ν * u2 + ua * (c3 * u1 - μ * u2) + c5 * ua^2 * u1
    f[2] = r * u2 + ν * u1 + ua * (c3 * u2 + μ * u1) + c5 * ua^2 * u2
    return f
end

par_sl = (r = -0.5, μ = 0., ν = 1.0, c3 = 0.1, c5 = -0.01)
prob = BifurcationProblem(Fsl, [0., 0], par_sl, (@optic _.r))

opts = ContinuationPar(p_min = -1.)
br = continuation(prob, PALC(), opts)

# branch of periodic orbits
br_po = continuation(br, 1, opts,
        PeriodicOrbitOCollProblem(20, 4)
        )

# computation of folds of periodic orbits
opts_pocoll_fold = ContinuationPar(br_po.contparams, max_steps = 10, p_max=1.2)
fold_po_coll = @time continuation(deepcopy(br_po), 1, (@optic _.c5), opts_pocoll_fold;
        detect_codim2_bifurcation = 0,
        jacobian_ma = :minaug,
        bdlinsolver = BorderingBLS(solver = DefaultLS(), check_precision = false),
        )
1 Like

What is the output of

versioninfo()

?

julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 12 × Apple M2 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 8

When I run this on Ubuntu Linux on a Ryzen 7840u laptop I get:

julia> @eval @time include("mwe.jl")
┌ Warning: The guess for the amplitude of the first periodic orbit on the bifurcated branch obtained by the predictor is not small: 0.4472135954976816. This may lead to convergence failure of the first newton step or select a branch far from the Hopf point.
│ You can either decrease `ds` or `δp` (which is  how far from the bifurcation point you want the branch of periodic orbits to start). Alternatively, you can specify a multiplicative factor `ampfactor` to be applied to the predictor amplitude.
└ @ BifurcationKit ~/.julia/packages/BifurcationKit/KwA2l/src/periodicorbit/PeriodicOrbits.jl:413
 33.738423 seconds (28.05 M allocations: 1.998 GiB, 2.15% gc time, 99.53% compilation time)
 66.162634 seconds (92.21 M allocations: 6.284 GiB, 4.40% gc time, 98.12% compilation time: <1% of which was recompilation)
 ┌─ Curve type: FoldPeriodicOrbitCont
 ├─ Number of points: 11
 ├─ Type of vectors: BorderedArray{Vector{Float64}, Float64}
 ├─ Parameters (:r, :c5)
 ├─ Parameter c5 starts at -0.01, ends at -0.004444740574832257
 ├─ Algo: PALC
 └─ Special points:

- #  1, endpoint at c5 ≈ -0.00395615,                                                                     step =  11

Any suggestions how to get more insight on which tasks the compilation time is spent?

The compilation time is spent in the computation of fold_po_coll. If you copied my code in mwe.jl, there is only one @time in it, so I guess the 33s reported correspond to the long computation time I observe.

1 Like

The call itself takes 0.1s once compiled…

using Tools to Analyze Long Julia Compilation Times - #3 by SteffenPL, I chose to profile the first run. Here is what I get