-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
latencyLatencyLatency
Description
Some time ago I noticed compile-time regressions for long static vectors #32076
which was promptly addressed in #32105
There are still situations in which long static vectors (length 50 is long enough) causes a very long compile time. For a function reproduced below, we have the following timings on julia v1.3.1, v1.4.1 and v1.5.0-DEV.660, and for vector length 5 vs. 50
julia 1.3.1
vector length 50
julia> @time sol = solve(prob, Tsit5(), reltol = 1e-6);
198.884347 seconds (21.77 M allocations: 1.217 GiB, 0.43% gc time)
length 5
julia> @time sol = solve(prob, Tsit5(), reltol = 1e-6);
10.268011 seconds (19.30 M allocations: 1009.309 MiB, 5.39% gc time)
julia 1.4.1
length 50
julia> @time sol = solve(prob, Tsit5(), reltol = 1e-6);
156.024978 seconds (23.61 M allocations: 1.354 GiB, 0.41% gc time)
length 5
julia> @time sol = solve(prob, Tsit5(), reltol = 1e-6);
12.370106 seconds (21.20 M allocations: 1.114 GiB, 5.10% gc time)
julia v1.5.0 DEV 660
length 50
julia> @time sol = solve(prob, Tsit5(), reltol = 1e-6);
121.399936 seconds (22.42 M allocations: 1.223 GiB, 0.58% gc time)
vector length 5
julia> @time sol = solve(prob, Tsit5(), reltol = 1e-6);
31.808385 seconds (19.22 M allocations: 977.575 MiB, 3.40% gc time)
After warm-up, the function is very fast to run
julia> @time sol = solve(prob, Tsit5(), reltol = 1e-6); # second run
0.104280 seconds (210.20 k allocations: 165.901 MiB, 31.05% gc time)
It seems that the compilation times scales linearly with the length of the vectors.
The code to run the problem is the following
using BenchmarkTools, OrdinaryDiffEq, MonteCarloMeasurements, StaticArrays
N = 50 # Define the length of the static vector
g = StaticParticles(N,Normal(9.79, 0.02));
L = StaticParticles(N,Normal(1, 0.01));
u₀ = [0+0L, π/3+0L]
p = [g, L]
function simplependulum(u,p,t)
g,L = p
θ = u[1]
dθ = u[2]
[dθ,-(g/L) * sin(θ)]
end
prob = ODEProblem(simplependulum, u₀, (0.0,200.0), p)
@time sol = solve(prob, Tsit5(), reltol = 1e-6);EDIT: Added timings for julia nightly (DEV 660.).
Metadata
Metadata
Assignees
Labels
latencyLatencyLatency