You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a REPL the trivial test model runs in about 0.03 seconds on the second run, but 20 seconds with the CLI. We put a lot of effort into making the solver fast to run. Little effort has been spent to quickly start a simulation. Users running the trivial test model from the CLI (v2024.11) need to wait 20 seconds each time. For short simulations or quick tests this hinders the iteration speed of modelers. Here is the output of hyperfine on trivial:
❯ hyperfine 'ribasim ribasim.toml'
Benchmark 1: ribasim ribasim.toml
Time (mean ± σ): 20.835 s ± 0.280 s [User: 10.951 s, System: 0.364 s]
Range (min … max): 20.606 s … 21.525 s 10 runs
Especially on a warm filesystem cache the loading of the binary is quick, Info: Starting a Ribasim simulation appears quickly. It then takes about 10 seconds for Simulating 0% to appear, and another 10 seconds for the simulation to finish.
That indicates that it still needs to compile a lot of code during a CLI run. Ten seconds worth of initialization / validation code and ten seconds of simulation code. I hoped that https://github.com/Deltares/Ribasim/blob/v2024.11.0/build/precompile.jl would precompile more of what we need, but apparently it doesn't. We can consider looking into this with SnoopCompile.jl. Right now we don't yet use PrecompileTools.jl in Ribasim.jl. We could start doing this as well.
I assume in time having small binaries with juliac will also help here.
One way to completely avoid this issue is to run Ribasim.main("ribasim.toml") from Julia instead. If we'd support some way in the CLI to run multiple model (separate TOMLs) with one command this would similarly avoid the latency when doing multiple runs each time. It may be good to support separate TOMLs also for #47.
The text was updated successfully, but these errors were encountered:
visr
added
core
Issues related to the computational core in Julia
performance
Relates to runtime performance or convergence
labels
Nov 18, 2024
If we don't use the precompile file in PackageCompiler, the build is 6 minutes faster and only 6 MB smaller (than 313 MB) but the latency is about twice as high.
Testing a simple PrecompileTools workload like
using PrecompileTools:@compile_workload@compile_workloadbeginmain(normpath(@__DIR__, "../../generated_testmodels/basic/ribasim.toml"))
end
seems to suffer from similar issues. It still compiles a lot of code when running other models.
The compile_workload did cause world age errors related to the generated function from #1982. Here is the written out version that we should consider switching to:
function config.snake_case(nt::NodeType.T)::Symbolif nt == NodeType.Basin
return:basinelseif nt == NodeType.TabulatedRatingCurve
return:tabulated_rating_curveelseif nt == NodeType.Pump
return:pumpelseif nt == NodeType.Outlet
return:outletelseif nt == NodeType.UserDemand
return:user_demandelseif nt == NodeType.FlowDemand
return:flow_demandelseif nt == NodeType.LevelDemand
return:level_demandelseif nt == NodeType.FlowBoundary
return:flow_boundaryelseif nt == NodeType.LevelBoundary
return:level_boundaryelseif nt == NodeType.LinearResistance
return:linear_resistanceelseif nt == NodeType.ManningResistance
return:manning_resistanceelseif nt == NodeType.Terminal
return:terminalelseif nt == NodeType.DiscreteControl
return:discrete_controlelseif nt == NodeType.ContinuousControl
return:continuous_controlelseif nt == NodeType.PidControl
return:pid_controlelseerror("Unknown node type: $nt")
endend
In a REPL the
trivial
test model runs in about 0.03 seconds on the second run, but 20 seconds with the CLI. We put a lot of effort into making the solver fast to run. Little effort has been spent to quickly start a simulation. Users running thetrivial
test model from the CLI (v2024.11) need to wait 20 seconds each time. For short simulations or quick tests this hinders the iteration speed of modelers. Here is the output of hyperfine ontrivial
:Especially on a warm filesystem cache the loading of the binary is quick,
Info: Starting a Ribasim simulation
appears quickly. It then takes about 10 seconds forSimulating 0%
to appear, and another 10 seconds for the simulation to finish.That indicates that it still needs to compile a lot of code during a CLI run. Ten seconds worth of initialization / validation code and ten seconds of simulation code. I hoped that https://github.com/Deltares/Ribasim/blob/v2024.11.0/build/precompile.jl would precompile more of what we need, but apparently it doesn't. We can consider looking into this with SnoopCompile.jl. Right now we don't yet use PrecompileTools.jl in Ribasim.jl. We could start doing this as well.
I assume in time having small binaries with
juliac
will also help here.One way to completely avoid this issue is to run
Ribasim.main("ribasim.toml")
from Julia instead. If we'd support some way in the CLI to run multiple model (separate TOMLs) with one command this would similarly avoid the latency when doing multiple runs each time. It may be good to support separate TOMLs also for #47.The text was updated successfully, but these errors were encountered: