-
-
Notifications
You must be signed in to change notification settings - Fork 233
Description
The π
When trying to run generate_control_function with a system that has 1757 equations, it is several orders of magnitude slower than just running structural_simplify with the same arguments on the same system.
Expected behavior
structural_simplify and generate_control_function should have around the same runtime. When I run profileview on the system, it shows that generate_control_function uses around 60% of its runtime on the following line:
inputoutput.jl, generate_control_function: sys, _ = io_preprocessing(sys, inputs, []; simplify, kwargs...)
and 40% of its runtime is used on:
inputoutput.jl, generate_control_function: eqs = [eq for eq in full_equations(sys)]
With an impressive total runtime of more than 8000 seconds (more than 2 hours):
@time (_, f_ip), dvs, psym, io_sys = ModelingToolkit.generate_control_function(model, inputs, split=false; outputs=outputs)
8306.809924 seconds (5.55 G allocations: 260.320 GiB, 80.75% gc time)While the runtime of structural_simplify on the same model is around 5-10 seconds:
@time structural_simplify(kite_model, (inputs, []))
5.424258 seconds (12.56 M allocations: 717.108 MiB, 2.76% gc time)How to reproduce
git clone https://github.com/Albatross-Kite-Transport/KitePredictiveControl.jl.git
cd KitePredictiveControl.jl
git checkout issue_3077
julia --project=.
julia> ] instantiate
julia> ] add https://github.com/ufechner7/KiteModels.jl/tree/feat/xfoil-polars
julia> using KitePredictiveControl
julia> run_controller()
running structural_simplify
8.340810 seconds (11.99 M allocations: 710.245 MiB, 2.52% gc time, 81.88% compilation time: 33% of which was recompilation)
running generate_control_function
8306.809924 seconds (5.55 G allocations: 260.320 GiB, 80.75% gc time)My manifest.toml is in the repository under Manifest.toml.bug. The profview file is in data/kitemodels.jlprof