Time to build system and problem is slower in Julia 1.12 with MTKv11

Hi, while I was trying the new version (v11) of ModelingToolkit.jl , I noticed it took longer to build the ODE system and problem under Julia 1.12.

Here is the GitHub actions workflow running the script

using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using OrdinaryDiffEq

@parameters τ = 3.0 # parameters
@variables x(t) = 0.0 # dependent variables
eqs = [D(x) ~ (1 - x) / τ]

@time "Build system" @mtkcompile fol = System(eqs, t)
@time "Build problem" prob = ODEProblem(fol, [], (0.0, 10.0))
@time "Solve problem" sol = solve(prob, Tsit5())

Time for building the ODESystem / ODEProblem in seconds.

MTK JL1.10 JL1.12
v10 1.25/2.04 0.76/1.89
v11 1.91/1.35 33.44/17.37

Is there anything I can do to reduce the first time to build systems/problems in 1.12?

1 Like

Hi! Thanks for reporting this. This is certainly very abnormal, and I’ve gone to great lengths to ensure that TTFX of MTKv11 on 1.12 is as fast as possible. I’ll investigate what’s going on here. Before I do, I’ll need a little more information.

  • What versions of ModelingToolkit, ModelingToolkitBase, ModelingToolkitTearing, Symbolics and SymbolicUtils are you running?
  • Did you run the above code in the REPL or as a script?
  • What packages do you have in your global environment on each Julia version?
  • Did you use the --project flag when starting Julia? If you didn’t, and if you ran the code in a script file, how did you load the appropriate environment?
1 Like

All questions should be answered in the linked CI workflow? fix · sosiristseng/mtk-ttfx@68045eb · GitHub

1 Like

Ah, thanks. Somehow I glossed over that part.

A quick mockup of your example indeed reproduces compile time differences, but not nearly as significant as in your CI. I get

Julia 1.10:

Build system: 0.662157 seconds (1.43 M allocations: 106.126 MiB, 1.52% gc time, 99.15% compilation time)
Build problem: 0.568265 seconds (1.26 M allocations: 90.375 MiB, 1.43% gc time, 94.27% compilation time)

Julia 1.12:

Build system: 2.221802 seconds (2.72 M allocations: 139.684 MiB, 1.89% gc time, 99.62% compilation time: 100% of which was recompilation)
Build problem: 3.862440 seconds (25.89 M allocations: 1.300 GiB, 2.59% gc time, 99.53% compilation time: 62% of which was recompilation)

All of the time is Julia compile time. I’m not yet sure why it increased so dramatically.

Thanks for the reply.

  1. I need to print manifest in the CI.
  2. I ran it as a script: julia test.jl
  3. There is no global packages installed (prior to point 4). The CI spins a fresh environment every time.
  4. By point 3, I just install all packages in the global environment.

Edit: Added pkg versions

  [961ee093] ModelingToolkit v11.9.0
  [7771a370] ModelingToolkitBase v1.12.0
  [6bb917b9] ModelingToolkitTearing v1.2.6
  [d1185830] SymbolicUtils v4.17.0
  [0c5d862f] Symbolics v7.13.0

Output of versioninfo():

Julia Version 1.10.10
Commit 95f30e51f41 (2025-06-27 09:51 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × AMD EPYC 7763 64-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 4 default, 0 interactive, 2 GC (on 4 virtual cores)
Environment:
  JULIA_CI = true
  JULIA_NUM_THREADS = auto
Julia Version 1.12.4
Commit 01a2eadb047 (2026-01-06 16:56 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × AMD EPYC 7763 64-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, znver3)
  GC: Built with stock GC
Threads: 4 default, 1 interactive, 4 GC (on 4 virtual cores)
Environment:
  JULIA_CI = true
  JULIA_NUM_THREADS = auto

It seems something invalidated the mtkcompile method recently, so it doesn’t precompile.

1 Like

It seems like TTFX in Julia 1.12 is much faster after MTK v11.13, demonstrated by this GitHub CI run.

Thank you SciML team!

2 Likes