# Improving performance of solving ODESystem (Catalyst.jl)

**URL:** <https://discourse.julialang.org/t/improving-performance-of-solving-odesystem-catalyst-jl/83568>\
**Category:** New to Julia\
**Created:** [June 30, 2022, 2:15pm UTC](https://discourse.julialang.org/t/improving-performance-of-solving-odesystem-catalyst-jl/83568 "2022-06-30T14:15:58Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 7, 2022, 8:28am UTC](https://discourse.julialang.org/t/improving-performance-of-solving-odesystem-catalyst-jl/83568/9 "2022-07-07T08:28:19Z")

</div>

Catalyst/ModelingToolkit build non-allocating functions. You can see this because your allocations won’t change if you turn saving off and increase the time span (i.e. longer solves don’t increase the allocations). Thus the memory cost is:

1. Compiling new code
2. Setting up a new solve call
3. Saving values out

If you’re doing `save_everystep = false` you should be fine on (3). But are you avoiding code compilation each time? It’s only if `prob !== nothing`, which I haven’t looked at the code close enough to see but given you have a branch to protect against it you’re probably fine.

So then if you’ve done that correctly (and are measuring post compilation), the only other allocation is in the startup time of the `solve` call. You can move to the integrator interface ([Integrator Interface · DifferentialEquations.jl](https://diffeq.sciml.ai/stable/basics/integrator/)) and just have a single integrator that `reinit!`s to avoid recreating the solver caches, and this would make it fully non-allocating.

But to know if that’s even required, you should try benchmarking first. Use [GitHub - tkluck/StatProfilerHTML.jl: Show Julia profiling data in an explorable HTML page](https://github.com/tkluck/StatProfilerHTML.jl) to create flamegraph: that will tell you what area of the code is taking all of the time.

(I’m still travelling so I haven’t gotten a chance to run it, but the flamegraph is the first thing I would make)

---

_[View the full topic](https://discourse.julialang.org/t/improving-performance-of-solving-odesystem-catalyst-jl/83568)._
