Skip to content

Commit 4003555

Browse files
Merge pull request SciML#60 from ChrisRackauckas-Claude/precompile-improvements-20251229-142258
Add PrecompileTools workload for faster startup
2 parents 4c75510 + 0e86cfe commit 4003555

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ version = "1.3.0"
66
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
77
MATLAB = "10e44e05-a98a-55b3-a45b-ba969058deb6"
88
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
9+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
910
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1011

1112
[compat]
1213
DiffEqBase = "6.122"
1314
MATLAB = "0.8, 0.9"
1415
ModelingToolkit = "8, 9, 10, 11"
16+
PrecompileTools = "1"
1517
Reexport = "0.2, 1.0"
1618
julia = "1.6"
1719

src/MATLABDiffEq.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module MATLABDiffEq
33
using Reexport
44
@reexport using DiffEqBase
55
using MATLAB, ModelingToolkit
6+
using PrecompileTools
67

78
# Handle ModelingToolkit API changes: states -> unknowns
89
if isdefined(ModelingToolkit, :unknowns)
@@ -152,4 +153,33 @@ function buildDEStats(solverstats::Dict)
152153
destats
153154
end
154155

156+
@setup_workload begin
157+
# Precompile algorithm struct instantiations and buildDEStats
158+
@compile_workload begin
159+
# Instantiate algorithm structs - this precompiles their constructors
160+
_ = ode23()
161+
_ = ode45()
162+
_ = ode113()
163+
_ = ode23s()
164+
_ = ode23t()
165+
_ = ode23tb()
166+
_ = ode15s()
167+
_ = ode15i()
168+
169+
# Precompile buildDEStats with typical MATLAB stats dictionaries
170+
test_stats = Dict{String, Any}(
171+
"nfevals" => 100,
172+
"nfailed" => 5,
173+
"nsteps" => 95,
174+
"nsolves" => 50,
175+
"npds" => 10,
176+
"ndecomps" => 8
177+
)
178+
_ = buildDEStats(test_stats)
179+
180+
# Also precompile with missing keys (common case)
181+
_ = buildDEStats(Dict{String, Any}())
182+
end
183+
end
184+
155185
end # module

0 commit comments

Comments
 (0)