SciML / OrdinaryDiffEq.jl

High performance ordinary differential equation (ODE) and differential-algebraic equation (DAE) solvers, including neural ordinary differential equations (neural ODEs) and scientific machine learning (SciML)
https://diffeq.sciml.ai/latest/
Other
535 stars 202 forks source link

Analysis of time spent precompiling #1937

Closed KristofferC closed 6 months ago

KristofferC commented 1 year ago

With the new profiling tools in Julia it is now easier to get a good look at what happens during precompilation. Since OrdinaryDiffEq has a quite large compilation time, I did a bit of analysis.

The profile trace can be seen online in https://topolarity.github.io/trace-viewer/?trace=https%3A%2F%2Fraw.githubusercontent.com%2FKristofferC%2Ftracy-traces%2Fmain%2Forddiffeq_precompile.tracy&size=9821725.

The top sections where time is spent is:

image

So in summary, we are compiling a lot of different methods which means we have to infer and compile them. Not strange.

These are the inference time of the different methods that take the most time:

gnome-shell-screenshot-bctd16

One perhaps interesting note is that it seems we are compiling 28 versions of solve_call with a CompositeAlgorithm. That seems like a lot? Each such solve_call seems to take around 500ms to infer:

gnome-shell-screenshot-921r89

Some possible ways to improve things:

KristofferC commented 6 months ago

Cost per combination is the same but the number of combinations seems to have been reduced a lot by default.

gdalle commented 6 months ago

Out of curiosity what "new profiling tools" did you use?

KristofferC commented 6 months ago

Tracy, https://docs.julialang.org/en/v1/devdocs/external_profilers/