-
-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Long Compile Times for StaticArrays Arguments to solve
#2535
Comments
But the MWE is non-stiff? |
And it took less than 3 seconds?
|
When the
Ah, sorry about that. I misunderstood the definition of stiff. The reason I tried to characterize the dynamics at all (e.g. stiff) is I think I have seen some equations which compile quickly with |
I did that. It compiled just fine with MVector. |
Hm, not for me. I added some The linked issue was reported by another user too. I solved the issue by changing all code examples from Sorry this is an odd case. Maybe it's an architecture issue? I'm on an M1 MacBook Air. The output from me running the MRE is below; it just hangs on the
|
I think I found the issue for me. Changing the algorithm from Modified MREimport Pkg
Pkg.activate(tempdir())
Pkg.add("StaticArrays")
Pkg.add("OrdinaryDiffEq")
using StaticArrays
using OrdinaryDiffEq
μ = 0.012150584395829193
u = [
0.8222791798525636
0.0
0.0
0.0
0.13799313228400034
0.0
]
function r2bp(du, u, p, t)
x, y, z, ẋ, ẏ, ż = u
μ, = p
r = sqrt(x^2 + y^2 + z^2)
du[1] = ẋ
du[2] = ẏ
du[3] = ż
du[4] = μ * x / r^3
du[5] = μ * y / r^3
du[6] = μ * z / r^3
return nothing
end
@info "Solving Problem with Vector Input using Tsit5"
@warn "This should compile in a couple of seconds."
problem = ODEProblem(r2bp, u, (0.0, 3.0), (μ,))
@time solution = solve(problem, Tsit5(), reltol = 1e-12, abstol = 1e-12)
@info "Solving Problem with MVector Input using Tsit5"
@warn "This should also compile in a couple of seconds."
problem = ODEProblem(r2bp, MVector{6}(u), (0.0, 3.0), (μ,))
@time solution = solve(problem, Tsit5(), reltol = 1e-12, abstol = 1e-12)
@info "Solving Problem with Vector Input using Vern9"
@warn "This should compile in a couple of seconds."
problem = ODEProblem(r2bp, u, (0.0, 3.0), (μ,))
@time solution = solve(problem, Vern9(), reltol = 1e-12, abstol = 1e-12)
@info "Solving Problem with MVector Input using Vern9"
@error "This takes a long time to compile for me; upwards of one hour."
problem = ODEProblem(r2bp, MVector{6}(u), (0.0, 3.0), (μ,))
@time solution = solve(problem, Vern9(), reltol = 1e-12, abstol = 1e-12) |
Still only took:
How did you install Julia, using juliaup? What version? |
Strange. Yeah, I installed it through |
I can reproduce this on my It looks like an issue with a subtyping query in the broadcast exploding: JuliaLang/julia#56606 |
Good news! Testing with JuliaLang/julia#56640 seems to resolve the problem 👍 (huge thanks to @N5N3): [ Info: Solving Problem with Vector Input
┌ Warning: This should compile in a couple of seconds.
└ @ Main ~/repos/julia/mwe.jl:36
4.455485 seconds (20.61 M allocations: 1.135 GiB, 16.08% gc time, 100.00% compilation time)
[ Info: Solving Problem with MVector State
┌ Error: This will take very long to compile!
└ @ Main ~/repos/julia/mwe.jl:41
4.371111 seconds (18.77 M allocations: 902.214 MiB, 15.37% gc time, 100.00% compilation time) |
Describe the bug 🐞
I think there may be a regression in compilation times
solve(::ODEProblem)
withStaticArrays
types. I have a minimum reproducible example below. First aVector
type is used, and that compiles quickly. Next anMVector
type is used, and thesolve
call takes approximately one hour to complete; I haven't confirmed this locally (the call hangs, and I wait a few minutes before killing the process), but in CI the call does finish, but it takes around one hour.I don't have any specific package versions for when this worked, but I was able to run
solve
withMVector
types in the last year. Here is one example from 5 months ago; the full job completed in 13 minutes.Expected behavior
The
solve
call withMVector
should compile and evaluate within an order of magnitude ofVector
.Minimal Reproducible Example 👇
Environment (please complete the following information):
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
versioninfo()
The text was updated successfully, but these errors were encountered: