Skip to content

Add precompilation workloads for OrdinaryDiffEqSDIRK - #3099

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:add-sdirk-precompilation
Mar 1, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:add-sdirk-precompilation

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

  • Add PrecompileTools.@compile_workload to OrdinaryDiffEqSDIRK for TRBDF2() and KenCarp4(), following the same pattern used by OrdinaryDiffEqBDF and OrdinaryDiffEqRosenbrock
  • Add PrecompileTools and Preferences as dependencies in Project.toml
  • Support all four specialization modes via Preferences.@load_preference (DefaultSpecialize enabled by default, Auto/FunctionWrapper/NoSpecialize opt-in)

OrdinaryDiffEqSDIRK was the only major solver package with zero precompilation workloads, causing unnecessary TTFX overhead for widely-used methods like TRBDF2.

Before (no precompilation)

When a second SDIRK solver is called after the first already paid shared infrastructure costs:

  • TRBDF2 (1st after KenCarp4): ~3.0s

After (with precompilation)

  • TRBDF2 (1st after KenCarp4): ~0.12s (25x improvement)
  • KenCarp4 (1st after TRBDF2): ~0.10s

Note: the first solver called in a session still pays ~2.5s for shared OrdinaryDiffEqCore/LinearSolve infrastructure compilation. --trace-compile analysis confirms this is from broadcast fusion specialization for user-specific function bodies (especially ForwardDiff dual number types), not from solver method recompilation. The solver-specific precompilation added here IS effective.

Ref: SciML/DifferentialEquations.jl#1125

Test plan

  • Pkg.precompile() succeeds (17.5s precompilation time = workload executing)
  • Pkg.test() passes (JET + Aqua tests)
  • Runic formatting check passes
  • TTFX improvement verified with timing benchmarks

🤖 Generated with Claude Code

OrdinaryDiffEqSDIRK had no @compile_workload, causing significant
TTFX overhead when using SDIRK methods like TRBDF2 and KenCarp4.

This adds PrecompileTools workloads for TRBDF2 and KenCarp4
following the same pattern used by OrdinaryDiffEqBDF and
OrdinaryDiffEqRosenbrock, with preference-controlled specialization
modes.

Ref: SciML/DifferentialEquations.jl#1125

Co-Authored-By: Chris Rackauckas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants