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
239 stars 42 forks source link

Long using time #54

Closed albheim closed 2 years ago

albheim commented 2 years ago

Not sure if this is actually an issue, but it seemed like a significant time to me so thought I would ask about it.

I tried out the new @time_imports macro in v1.8.0-beta1 and found that almost half of the load time in ControlSystems came from NonlinarSolve. Also ran it on NonlinearSolve to see how it looked there, and it was faster than the time reported in ControlSystems (3.99s vs 6.58s).

I'm not sure if there are things that can be done easily in NonlinearSolve? And maybe it is really ControlSystems that needs to do something since the load time was worse there?

ControlSystems ```julia julia> @time_imports using ControlSystems 10.1 ms ┌ Preferences 24.9 ms ┌ JLLWrappers 30.2 ms ┌ Rmath_jll 147.0 ms ┌ Rmath 3.3 ms ┌ Compat 0.4 ms ┌ NaNMath 2.7 ms ┌ Calculus 83.4 ms ┌ ChainRulesCore 84.5 ms ┌ ChangesOfVariables 0.5 ms ┌ OpenLibm_jll 0.5 ms ┌ InverseFunctions 4.2 ms ┌ DocStringExtensions 6.8 ms ┌ IrrationalConstants 0.8 ms ┌ CompilerSupportLibraries_jll 1.6 ms ┌ LogExpFunctions 1.2 ms ┌ OpenSpecFun_jll 24.8 ms ┌ SpecialFunctions 21.4 ms ┌ DualNumbers 146.2 ms ┌ HypergeometricFunctions 0.4 ms ┌ Reexport 312.0 ms ┌ StatsFuns 713.7 ms ┌ StaticArrays 717.4 ms ┌ DiffResults 16.8 ms ┌ FunctionWrappers 12.8 ms ┌ OrderedCollections 109.0 ms ┌ DataStructures 0.4 ms ┌ MuladdMacro 0.5 ms ┌ Requires 0.1 ms ┌ IfElse 61.0 ms ┌ Static 290.3 ms ┌ ArrayInterface 18.3 ms ┌ MacroTools 345.6 ms ┌ LabelledArrays 0.6 ms ┌ CommonSubexpressions 1.1 ms ┌ DiffRules 114.6 ms ┌ ForwardDiff 0.8 ms ┌ Adapt 546.1 ms ┌ PreallocationTools 25.6 ms ┌ KLU 145.2 ms ┌ Parsers 12.7 ms ┌ InlineStrings 0.8 ms ┌ ExprTools 43.0 ms ┌ RecipesBase 2.6 ms ┌ Mocking 90.4 ms ┌ TimeZones 127.2 ms ┌ Intervals 436.6 ms ┌ MutableArithmetics 1003.6 ms ┌ Polynomials 2.3 ms ┌ DataAPI 0.9 ms ┌ StatsAPI 0.9 ms ┌ SortingAlgorithms 14.0 ms ┌ Missings 58.7 ms ┌ StatsBase 17.5 ms ┌ AbstractFFTs 0.6 ms ┌ ZygoteRules 845.5 ms ┌ Hwloc_jll 848.2 ms ┌ Hwloc 0.2 ms ┌ SIMDTypes 2.5 ms ┌ ManualMemory 8.0 ms ┌ LayoutPointers 354.0 ms ┌ CPUSummary 0.4 ms ┌ BitTwiddlingConvenienceFunctions 38.3 ms ┌ HostCPUFeatures 1953.7 ms ┌ VectorizationBase 0.2 ms ┌ IteratorInterfaceExtensions 0.9 ms ┌ TableTraits 73.8 ms ┌ ThreadingUtilities 101.3 ms ┌ PolyesterWeave 6.7 ms ┌ SLEEFPirates 13.0 ms ┌ SIMDDualNumbers 0.3 ms ┌ UnPack 237.9 ms ┌ FillArrays 0.3 ms ┌ DataValueInterfaces 67.9 ms ┌ RecursiveArrayTools 5.7 ms ┌ CloseOpenIntervals 25.1 ms ┌ StrideArraysCore 33.8 ms ┌ Polyester 27.0 ms ┌ Tables 0.3 ms ┌ CommonSolve 2.4 ms ┌ ConstructionBase 0.4 ms ┌ TreeViews 410.2 ms ┌ SciMLBase 2508.7 ms ┌ Setfield 73.7 ms ┌ OffsetArrays 658.2 ms ┌ LoopVectorization 21.0 ms ┌ FiniteDiff 318.5 ms ┌ TriangularSolve 32.1 ms ┌ IterativeSolvers 208.6 ms ┌ RecursiveFactorization 6583.1 ms ┌ NonlinearSolve 1.5 ms ┌ LaTeXStrings 10.8 ms ┌ Distances 12.8 ms ┌ DEDataArrays 42.8 ms ┌ PDMats 1.2 ms ┌ Parameters 17.9 ms ┌ Krylov 11.8 ms ┌ NLSolversBase 26.5 ms ┌ LineSearches 1.1 ms ┌ Inflate 5.7 ms ┌ DensityInterface 10.2 ms ┌ QuadGK 323.0 ms ┌ Distributions 61.0 ms ┌ KrylovKit 158.8 ms ┌ LinearSolve 0.4 ms ┌ FastClosures 1.0 ms ┌ FastBroadcast 5.3 ms ┌ NLsolve 2.6 ms ┌ SimpleTraits 9.3 ms ┌ ArnoldiMethod 83.1 ms ┌ Graphs 87.4 ms ┌ VertexSafeGraphs 114.6 ms ┌ SparseDiffTools 170.4 ms ┌ DiffEqBase 29.0 ms ┌ ExponentialUtilities 2545.5 ms ┌ OrdinaryDiffEq 290.4 ms ┌ LinearMaps 241.6 ms ┌ FFTW_jll 551.2 ms ┌ FFTW 58.9 ms ┌ IterTools 146.1 ms ┌ DSP 169.7 ms ┌ FixedPointNumbers 725.9 ms ┌ ColorTypes 21.3 ms ┌ MatrixEquations 28.5 ms ┌ DelayDiffEq 14.3 ms ┌ DiffEqCallbacks 7.0 ms ┌ MatrixPencils 578.5 ms ┌ Colors 14473.5 ms ControlSystems ```
NonlinearSolve ```julia julia> @time_imports using NonlinearSolve 20.5 ms ┌ MacroTools 33.5 ms ┌ ZygoteRules 0.3 ms ┌ IteratorInterfaceExtensions 0.8 ms ┌ TableTraits 727.9 ms ┌ StaticArrays 731.4 ms ┌ DiffResults 1.8 ms ┌ Compat 0.5 ms ┌ NaNMath 0.4 ms ┌ Requires 0.2 ms ┌ UnPack 203.7 ms ┌ FillArrays 0.3 ms ┌ DataValueInterfaces 99.0 ms ┌ ChainRulesCore 100.0 ms ┌ ChangesOfVariables 4.1 ms ┌ DocStringExtensions 0.2 ms ┌ IfElse 30.1 ms ┌ RecipesBase 72.9 ms ┌ Static 258.0 ms ┌ ArrayInterface 0.6 ms ┌ Adapt 385.2 ms ┌ RecursiveArrayTools 0.5 ms ┌ OpenLibm_jll 0.4 ms ┌ InverseFunctions 0.2 ms ┌ Reexport 1.6 ms ┌ DataAPI 19.3 ms ┌ Tables 0.3 ms ┌ CommonSolve 1.3 ms ┌ ConstructionBase 0.3 ms ┌ TreeViews 358.6 ms ┌ SciMLBase 7.4 ms ┌ IrrationalConstants 0.7 ms ┌ CompilerSupportLibraries_jll 1.3 ms ┌ LogExpFunctions 9.9 ms ┌ Preferences 10.7 ms ┌ JLLWrappers 898.9 ms ┌ OpenSpecFun_jll 930.9 ms ┌ SpecialFunctions 1.1 ms ┌ CommonSubexpressions 2.0 ms ┌ DiffRules 1080.2 ms ┌ ForwardDiff 1038.4 ms ┌ Setfield 19.2 ms ┌ FiniteDiff 22.6 ms ┌ IterativeSolvers 0.6 ms ┌ RecursiveFactorization 3991.1 ms NonlinearSolve ```
ChrisRackauckas commented 2 years ago

Well we need to do something about this everywhere 😅, though we have plans in Base that should help a lot.

albheim commented 2 years ago

Yeah, kind of what I expected. Feel free to close if you don't want this to clutter the issues, otherwise I'll leave it as a reminder.