# Sudden slowdown with ODEProblem

**URL:** <https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909>\
**Category:** New to Julia\
**Created:** [May 11, 2025, 4:54pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909 "2025-05-11T16:54:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rswhittle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rswhittle/32/216791_2.png) [@rswhittle](https://discourse.julialang.org/u/rswhittle)\
**Post date:** [May 11, 2025, 4:54pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/1 "2025-05-11T16:54:19Z")

</div>

Hi, throwing out a Hail Mary here as I have no idea what I am doing. We had/have a working ModelingToolkit model, then suddenly last night it stopped working as the DifferentialEquations.jl package wouldn’t precompile (throwing up errors in nonlinearsolver).

I totally deleted Julia from my computer, reinstalled it, created a new environment, add the packages and all now precompile.

The problem is that my ODESystem now takes 90+ s to form when I run prob=ODEProblem() on my structurally simplified model. I have made no changes to my code and before I reinstalled everything it took about 1 second. It still solves in about 3 seconds, but it’s the forming that takes ages. What’s probably going wrong and how can I fix, delete everything and do a fresh reinstall again?

---

<div class="post-metadata">

**Author:** ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)\
**Post date:** [May 11, 2025, 5:39pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/2 "2025-05-11T17:39:08Z")

</div>

You could try downgrading ModelingToolkit versions until you find a version where it is fast again. That could help to assess if it is related to some change in MTK.

---

<div class="post-metadata">

**Author:** ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)\
**Post date:** [May 11, 2025, 5:39pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/3 "2025-05-11T17:39:56Z")

</div>

And if you do find a specific point where it becomes slow it would probably make sense to open an issue on ModelingToolkit with a minimum example that experiences the slow down when changing releases.

---

<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:** [May 11, 2025, 7:26pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/4 "2025-05-11T19:26:29Z")

</div>

Do you have a manifest from before and after, or code to show? I can take a look if you share some code.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [May 12, 2025, 5:30pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/5 "2025-05-12T17:30:41Z")

</div>

We also saw a huge slow down and could fix it by adding this line to Project.toml:

```julia
SymbolicUtils = "~3.25"

```

First, add SymbolicUtils to your project. MTK itself is not the problem.

And if you have code that works well, ALWAYS make a backup of your Manifest.toml file.

---

<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:** [May 12, 2025, 8:32pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/6 "2025-05-12T20:32:44Z")

</div>

If I had to throw a guess out there, do you splat a giant tuple? If so then maybe [fix: tuples and arrays of `Symbols` should not be considered symbolic in codegen by AayushSabharwal · Pull Request #735 · JuliaSymbolics/SymbolicUtils.jl · GitHub](https://github.com/JuliaSymbolics/SymbolicUtils.jl/pull/735) actually using tuples means that “doing the right thing” (i.e. respecting that you chose to use a tuple) is bad (i.e. giant tuples are really bad for compilation performance, so you probably don’t want to do that, but if you tell us you want a tuple of 100 things we now appropriately respect that).

If you could give us a flamegraph that would be very helpful.

---

<div class="post-metadata">

**Author:** ![rveynde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveynde/32/208926_2.png) [@rveynde](https://discourse.julialang.org/u/rveynde)\
**Post date:** [May 19, 2025, 2:25pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/7 "2025-05-19T14:25:51Z")

</div>

I’ve run into the same issue I suspect. The size of our model is about 1800 unknowns in its initial form and about 260 after structural simplification.

Today I tried updating our packages and suddenly the construction of the ODEProblem takes a very long time (structural\_simplify doesn’t seem to have big changes). In the end I just killed my terminal because I did not get any results.

Here you can find the manifests from before and after the update:  
[Manifest before update.toml](https://discourse.julialang.org/uploads/short-url/ts42pyvFcuY951rsr92uCGDYSdx.toml) (123.2 KB)  
[Manifest after update.toml](https://discourse.julialang.org/uploads/short-url/g4qDvAnVjGq5VKIX6MP3B9vbnlj.toml) (122.0 KB)

Regarding the comment of @ufechner7, SymbolicUtils was 3.7 before the update and after the update it’s 3.27 so that might have something to do with it.

Our repo is currently still private, but I could try to create a flamegraph, or give you access to the repo to check out the issue?

---

<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:** [May 19, 2025, 9:38pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/8 "2025-05-19T21:38:18Z")

</div>

I’ll need an example that can run.

---

<div class="post-metadata">

**Author:** ![sass-jacob](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sass-jacob/32/215582_2.png) [@sass-jacob](https://discourse.julialang.org/u/sass-jacob)\
**Post date:** [May 27, 2025, 7:59pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/9 "2025-05-27T19:59:57Z")

</div>

Hello, as I have been running into similar issues, here is a flamegraph for possible utility:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/e/a/ea2cc2381de1c660725ad703045b285b00100bb6.jpeg)  
My problem involves many array-valued variables that I have scalarized the initial condition and initial guesses for, passing dictionaries of pairs of the scalarized variable and its Float64 value.

---

<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:** [May 27, 2025, 8:54pm UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/10 "2025-05-27T20:54:07Z")

</div>

@cryptic.ax why is reorder parameters so slow?

---

<div class="post-metadata">

**Author:** ![cryptic.ax](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cryptic.ax/32/220540_2.png) [@cryptic.ax](https://discourse.julialang.org/u/cryptic.ax)\
**Post date:** [May 28, 2025, 1:03am UTC](https://discourse.julialang.org/t/sudden-slowdown-with-odeproblem/128909/11 "2025-05-28T01:03:07Z")

</div>

It needs to scalarize array parameters in the tunables. I imagine that gets expensive if you have enough. I’ll look into using a lazily concatenated array or something.
