Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce CLI latency #1942

Open
visr opened this issue Nov 18, 2024 · 0 comments
Open

Reduce CLI latency #1942

visr opened this issue Nov 18, 2024 · 0 comments
Labels
core Issues related to the computational core in Julia performance Relates to runtime performance or convergence

Comments

@visr
Copy link
Member

visr commented Nov 18, 2024

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.

@visr visr added core Issues related to the computational core in Julia performance Relates to runtime performance or convergence labels Nov 18, 2024
@github-project-automation github-project-automation bot moved this to To do in Ribasim Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues related to the computational core in Julia performance Relates to runtime performance or convergence
Projects
Status: To do
Development

No branches or pull requests

1 participant