SciML / NonlinearSolve.jl

High-performance and differentiation-enabled nonlinear solvers (Newton methods), bracketed rootfinding (bisection, Falsi), with sparsity and Newton-Krylov support.
https://docs.sciml.ai/NonlinearSolve/stable/
MIT License
216 stars 39 forks source link

The precompilation of this package is likely excessive and not very useful #417

Open KristofferC opened 2 months ago

KristofferC commented 2 months ago

This package does a more or less exhaustive combination of problems, algorithms and element types

https://github.com/SciML/NonlinearSolve.jl/blob/d434b8d48086fa799ea344694c90a997dae22d48/src/NonlinearSolve.jl#L96-L98

https://github.com/SciML/NonlinearSolve.jl/blob/d434b8d48086fa799ea344694c90a997dae22d48/src/NonlinearSolve.jl#L137-L144

A total of 104 combinations of problems and algorithms are compiled in total.

At the same time, the problem specializes on the input function:

julia> typeof(prob)
NonlinearProblem{Float64, false, Float64, NonlinearFunction{false, SciMLBase.FullSpecialize, var"#1#2",

(the var"#1#2" is an anonymous function defined locally). so the compiled code is unlikely to be valid for users (which have their own functions that they solve).

It is not clear to me that there is any point at all to the precompilation of solve(prob, alg) after the very first call has been compiled.