From 4479337fc8a99fcf9c347ff69c5cc14c2453c015 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Fri, 11 Sep 2026 17:58:29 -0400 Subject: [PATCH] Add AirspeedVelocity benchmarking CI Adds a benchmark workflow (Julia 1 and lts) and a benchmark/benchmarks.jl suite covering representative workloads so PRs check for performance regressions. Co-Authored-By: Chris Rackauckas Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Agent-Harness: devin 3000.10.21 (611c1cba) Agent-Model: SWE-2 High Agent-Session: local session transcript /home/crackauc/sandbox/tmp_20260911_112052_59120/history_6a789c0b69c64ca3.md --- .github/workflows/benchmark.yml | 29 +++++++++++++++++ benchmark/benchmarks.jl | 58 +++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 .github/workflows/benchmark.yml create mode 100644 benchmark/benchmarks.jl diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 0000000..1c3bfcd --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,29 @@ +name: Benchmark this PR + +on: + pull_request: + branches: [main] + paths-ignore: ['docs/**'] + +permissions: + pull-requests: write + contents: read + +jobs: + benchmark: + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + version: ["1", "lts"] + env: + # Force consistent Julia depot path for self-hosted runners + JULIA_DEPOT_PATH: ~/.julia + steps: + - uses: MilesCranmer/AirspeedVelocity.jl@action-v1 + with: + julia-version: ${{ matrix.version }} + script: "benchmark/benchmarks.jl" + extra-pkgs: "OrdinaryDiffEq" + job-summary: true diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl new file mode 100644 index 0000000..f0be70a --- /dev/null +++ b/benchmark/benchmarks.jl @@ -0,0 +1,58 @@ +using OrdinaryDiffEqOperatorSplitting, OrdinaryDiffEq, BenchmarkTools + +const SUITE = BenchmarkGroup() + +# Split: u' = A u + B u with A = diag decay, B = skew coupling +odeA(du, u, p, t) = (du[1] = -u[1]; du[2] = -2 * u[2]; nothing) +odeB(du, u, p, t) = (du[1] = 0.5 * u[2]; du[2] = 0.5 * u[1]; nothing) + +dofs = [1, 2] +u0 = [1.0, 1.0] +tspan = (0.0, 10.0) + +fsplit = GenericSplitFunction((ODEFunction(odeA), ODEFunction(odeB)), (dofs, dofs)) +prob = OperatorSplittingProblem(fsplit, u0, tspan) + +# Larger split problem (10 dofs per subproblem) +N = 20 +odeA_big(du, u, p, t) = (du .= -u; nothing) +function odeB_big(du, u, p, t) + @inbounds for i in 1:(length(u) - 1) + du[i] = 0.1 * (u[i + 1] - u[i]) + end + du[end] = 0.1 * (u[1] - u[end]) + return nothing +end +fsplit_big = GenericSplitFunction( + (ODEFunction(odeA_big), ODEFunction(odeB_big)), (1:N, 1:N) +) +prob_big = OperatorSplittingProblem(fsplit_big, ones(N), tspan) + +# ============================================================================= +# Construction +# ============================================================================= + +SUITE["construct"] = BenchmarkGroup() + +SUITE["construct"]["split_function"] = @benchmarkable GenericSplitFunction( + ($(ODEFunction(odeA)), $(ODEFunction(odeB))), ($dofs, $dofs) +) +SUITE["construct"]["problem"] = @benchmarkable OperatorSplittingProblem( + $fsplit, $u0, $tspan +) + +# ============================================================================= +# Solves +# ============================================================================= + +SUITE["solve"] = BenchmarkGroup() + +SUITE["solve"]["lie_trotter"] = @benchmarkable solve( + $prob, LieTrotterGodunov((Tsit5(), Tsit5())); dt = 0.1 +) +SUITE["solve"]["strang"] = @benchmarkable solve( + $prob, StrangMarchuk((Tsit5(), Tsit5())); dt = 0.1 +) +SUITE["solve"]["strang_big"] = @benchmarkable solve( + $prob_big, StrangMarchuk((Tsit5(), Tsit5())); dt = 0.1 +)