Skip to content

Add allocation tests for core utility functions - #406

Closed
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:perf-improvements-20260103-064713
Closed

Add allocation tests for core utility functions#406
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:perf-improvements-20260103-064713

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Jan 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Add allocation tests for key internal utility functions in BoundaryValueDiffEqCore: interval, recursive_flatten!, recursive_unflatten!, __maybe_matmul!, and diff!
  • Tests verify these functions do not allocate after warmup
  • The original code changes (removing array comprehensions in loss functions) were already merged to master through other PRs, so this PR now only contains the new test file

Changes

  • test/misc/allocation_tests.jl (new file) — @testitem with 5 @testset blocks testing zero allocations for in-place utility functions

Test plan

  • Pkg.test() passes locally (all 8 misc test items pass, 75 tests pass)
  • Runic formatting check passes

@github-actions

github-actions Bot commented Jan 3, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results

Click to check benchmark results
master 3cba24f... master / 3cba24f...
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK2() 0.318 ± 0.02 s 0.306 ± 0.02 s 1.04 ± 0.095
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK3() 9.99 ± 2 ms 9.92 ± 0.43 ms 1.01 ± 0.21
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK4() 2.5 ± 0.096 ms 2.47 ± 0.085 ms 1.01 ± 0.052
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK5() 7.31 ± 1.9 ms 7.31 ± 1.8 ms 0.999 ± 0.36
Simple Pendulum/IIP/BoundaryValueDiffEqMIRK.MIRK6() 1.33 ± 0.35 ms 1.31 ± 0.077 ms 1.01 ± 0.28
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = false) 1.77 ± 0.99 ms 1.75 ± 1 ms 1.01 ± 0.81
Simple Pendulum/IIP/MultipleShooting(10, Tsit5; grid_coarsening = true) 2.97 ± 0.95 ms 2.95 ± 0.97 ms 1.01 ± 0.46
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.0759 ± 0.016 s 0.0706 ± 0.016 s 1.08 ± 0.34
Simple Pendulum/IIP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.0931 ± 0.025 s 0.092 ± 0.023 s 1.01 ± 0.37
Simple Pendulum/IIP/Shooting(Tsit5()) 0.239 ± 0.075 ms 0.239 ± 0.073 ms 1 ± 0.44
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK2() 0.501 ± 0.011 s 0.464 ± 0.0086 s 1.08 ± 0.031
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK3() 12.8 ± 7.8 ms 12.2 ± 7.1 ms 1.05 ± 0.89
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK4() 2.87 ± 0.28 ms 2.83 ± 0.24 ms 1.01 ± 0.13
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK5() 8.56 ± 1.2 ms 8.3 ± 1.2 ms 1.03 ± 0.21
Simple Pendulum/OOP/BoundaryValueDiffEqMIRK.MIRK6() 1.53 ± 0.24 ms 1.48 ± 0.23 ms 1.03 ± 0.23
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = false) 3.18 ± 3.1 ms 3.05 ± 3.2 ms 1.04 ± 1.5
Simple Pendulum/OOP/MultipleShooting(10, Tsit5; grid_coarsening = true) 5.49 ± 6.8 ms 5.17 ± 5.8 ms 1.06 ± 1.8
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = false) 0.124 ± 0.016 s 0.124 ± 0.0098 s 1 ± 0.15
Simple Pendulum/OOP/MultipleShooting(100, Tsit5; grid_coarsening = true) 0.16 ± 0.076 s 0.149 ± 0.068 s 1.08 ± 0.71
Simple Pendulum/OOP/Shooting(Tsit5()) 0.535 ± 0.23 ms 0.531 ± 0.3 ms 1.01 ± 0.71
time_to_load 4.62 ± 0.027 s 4.5 ± 0.024 s 1.03 ± 0.0082
### Benchmark Plots A plot of the benchmark results has been uploaded as an artifact to the workflow run for this PR. Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).

Comment thread lib/BoundaryValueDiffEqFIRK/src/firk.jl Outdated
Test that interval, recursive_flatten!, recursive_unflatten!,
__maybe_matmul!, and diff! do not allocate after warmup.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ChrisRackauckas-Claude
ChrisRackauckas-Claude force-pushed the perf-improvements-20260103-064713 branch from 3cba24f to bb4e712 Compare February 12, 2026 13:24
@ChrisRackauckas-Claude ChrisRackauckas-Claude changed the title Remove unnecessary array comprehensions in loss functions Add allocation tests for core utility functions Feb 12, 2026
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