Oh interesting, one thing that is happening is Julia’s function handling heuristics are getting in the way.
function f!(dθ, θ, h::H, p, t) where H
ω, A = p
n = length(θ)
lags = reshape(lag, n,n)
@inbounds for j in 1:n
coupling = 0.0
@inbounds for i in 1:n
coupling += A[i,j]*sin(h(p, t-lags[i,j]; idxs=i) - θ[j])
end
dθ[j] = ω[j] + coupling
end
nothing
end
is 6 times faster. Before:
julia> @time solve(prob, MethodOfSteps(BS3()), saveat=0.01, reltol=0, abstol=1e-5)
56.409539 seconds (1.96 G allocations: 32.454 GiB, 7.17% gc time)
After:
julia> @time solve(prob, MethodOfSteps(BS3()), saveat=0.01, reltol=0, abstol=1e-5)
12.284248 seconds (5.79 M allocations: 455.702 MiB, 1.67% gc time)
https://github.com/SciML/SciMLBase.jl/pull/110 fixes that.