Excessive allocations with VectorOfArray in broadcast
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- julia
- Domain
- performance
Research direction
Start by running the reported VectorOfArray reproducer with DifferentialEquations, ODEProblem, RK4, and the rhs! benchmark, then compare it with the midpoint rule. Trace the allocations during the solve and identify the operation responsible for the per-element allocations; done means the RK4 case no longer shows excessive allocations while retaining the reported solve behavior.
Written by the indexing model from the issue text.
Description
I am using a VectorOfArray as state vector in DifferentialEquations. This leads to too many allocations.
using DifferentialEquations
using RecursiveArrayTools
# Set up the state vector
U = VectorOfArray([zeros(100,100,100), zeros(100,100,100)]);
rhs!(U̇, U, p, t) = U̇ .= U
# Compile all code
prob = ODEProblem(rhs!, U, (0.0, 1.0));
sol = solve(prob, RK4(); adaptive=false, dt=1.0);
# Benchmark
prob = ODEProblem(rhs!, U, (0.0, 1.0));
@time sol = solve(prob, RK4(); adaptive=false, dt=1.0);
This outputs
1.639028 seconds (42.00 M allocations: 991.828 MiB, 18.67% gc time)
Note the very large number of allocations. It seems as if some operation was performing one small allocation per array element.
(I notice that this problem disappears if I switch to the midpoint rule.)
I tried with both Julia 1.7 and the current release branch of Julia 1.8.
- Dominant language
- Julia
- Stars
- 233
- Forks
- 76
- Avg merge
- 2h 17m
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SciML/RecursiveArrayTools.jl
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
SciML/RecursiveArrayTools.jl#255 ·
-
JET: similar_type(::Any) no-matching-method in RecursiveArrayToolsRaggedArrays (pre-existing QA red) Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
SciML/RecursiveArrayTools.jl#620 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
SciML/RecursiveArrayTools.jl#619 ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
SciML/RecursiveArrayTools.jl#570 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 28/100
SciML/RecursiveArrayTools.jl#522 ·
All issues in SciML/RecursiveArrayTools.jl
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
interpolate! from a Float32 LatitudeLongitudeGrid fails on Metal: Float64 division in find_λ_range Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
CliMA/Oceananigans.jl#6056 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
JuliaPluto/PlutoPlotly.jl#72 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
epiforecasts/BVDOutbreakSize#811 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
SciML/NonlinearSolve.jl#1310 · 1 comment ·