-
Notifications
You must be signed in to change notification settings - Fork 8
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
regression observed in JuMP expressions #111
Comments
Nice catch. It's obviously not going via the mutable route! |
I get issues similar to jump-dev/MathOptInterface.jl#1353 where I get allocations when calling a function for no reason I can think of. Copy pasting the same functions outside of the module sometimes decrease the allocation. julia> include("bug.jl");
0.000660 seconds (3.46 k allocations: 115.484 KiB)
0.000072 seconds (1.85 k allocations: 77.984 KiB)
0.000070 seconds (1.85 k allocations: 77.984 KiB)
0.000087 seconds (2.65 k allocations: 96.734 KiB)
0.000636 seconds (2.65 k allocations: 96.734 KiB)
0.000675 seconds (3.46 k allocations: 115.484 KiB)
julia> include("bug.jl");
0.000685 seconds (3.46 k allocations: 115.578 KiB)
0.000091 seconds (1.86 k allocations: 78.078 KiB)
0.000098 seconds (1.86 k allocations: 78.078 KiB)
0.000114 seconds (2.66 k allocations: 96.828 KiB)
0.000675 seconds (2.66 k allocations: 96.828 KiB)
0.000685 seconds (2.66 k allocations: 96.828 KiB) It seems #116 improves this time-wise (but I still don't understand these allocations). After the PR, I get: julia> include("bug.jl");
0.000090 seconds (2.64 k allocations: 96.547 KiB)
0.000076 seconds (1.84 k allocations: 77.797 KiB)
0.000080 seconds (1.84 k allocations: 77.797 KiB)
0.000097 seconds (2.64 k allocations: 96.547 KiB)
0.000123 seconds (2.64 k allocations: 96.547 KiB)
0.000110 seconds (2.64 k allocations: 96.547 KiB)
julia> include("bug.jl");
0.000114 seconds (2.67 k allocations: 96.891 KiB)
0.000079 seconds (1.86 k allocations: 78.141 KiB)
0.000082 seconds (1.86 k allocations: 78.141 KiB)
0.000088 seconds (2.67 k allocations: 96.891 KiB)
0.000103 seconds (2.67 k allocations: 96.891 KiB)
0.000107 seconds (2.67 k allocations: 96.891 KiB) |
Is this another stack/heap heuristic failure? |
I don't know where it would come from. I use |
@blegat Is this considered to be solved? with
I get julia> let N = 100
Random.seed!(1)
m = JuMP.Model()
JuMP.@variable(m, P[1:N, 1:N], Symmetric)
JuMP.@constraint(m, P in JuMP.PSDCone())
A = sprand(N, N, 0.03)
B = rand(N, N)
@time JuMP.@constraint(m, dot(A, P) == 0.0)
@time JuMP.@constraint(m, dot(B, P) == 0.0)
m
end
0.001497 seconds (80.05 k allocations: 2.947 MiB)
0.002826 seconds (109.54 k allocations: 3.665 MiB) also with modified
which means that currently function fused_map_reduce0(
op::F,
a, b,
) where {F<:Function,N}
MA._same_length(a, b)
T = MA.promote_map_reduce(op, eltype(a), eltype(b))
accumulator = MA.neutral_element(MA.reduce_op(op), T)
for I in zip(eachindex(a), eachindex(b))
JuMP._add_or_set!(accumulator.terms, getindex(a, I[1]), getindex(b, I[2]))
end
return accumulator
end
function fused_map_reduce1(
op::F,
a, b,
) where {F<:Function,N}
MA._same_length(a, b)
T = MA.promote_map_reduce(op, eltype(a), eltype(b))
accumulator = MA.neutral_element(MA.reduce_op(op), T)
for I in zip(eachindex(a), eachindex(b))
accumulator = MA.operate!(
MA.add_mul,
accumulator,
adjoint(getindex(a, I[1])),
getindex(b, I[2]),
)
end
return accumulator
end are the fastest |
Closing in favor of #132 |
MWE:
in JuMP 0.20.1 I get
in JuMP 0.21.10
which is 5× slowdown (on real examples even larger, closer to 10×.
@blegat
The text was updated successfully, but these errors were encountered: