Skip to content
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

Fix performance issues #188

Merged
merged 3 commits into from
Feb 2, 2019
Merged

Fix performance issues #188

merged 3 commits into from
Feb 2, 2019

Conversation

odow
Copy link
Member

@odow odow commented Jan 31, 2019

Cleverly calling update_model! results in an order-of-magnitude improvement.

cc @evanfields

Closes #184. (Note, running the benchmark in #184 yields an identical 10x improvement.)

benchmark_jump.jl is:

using Gurobi, JuMP
function benchmark(n = 150)
	m = JuMP.direct_model(Gurobi.Optimizer())
	@variable(m, f[1:n, 1:n] >= 0)
    return m
end
@time benchmark()
@time benchmark()
@time benchmark()
@time benchmark()
@time benchmark()

The results are

C:\Users\Oscar\.julia\dev\Gurobi>git checkout od/moi_speed
Switched to branch 'od/moi_speed'

C:\Users\Oscar\.julia\dev\Gurobi>julia --color=yes benchmark_jump.jl
Academic license - for non-commercial use only
  2.896283 seconds (5.20 M allocations: 279.623 MiB, 7.16% gc time)
Academic license - for non-commercial use only
  0.314600 seconds (821.42 k allocations: 63.965 MiB, 34.51% gc time)
Academic license - for non-commercial use only
  0.184337 seconds (802.34 k allocations: 62.967 MiB, 13.06% gc time)
Academic license - for non-commercial use only
  0.368996 seconds (802.34 k allocations: 62.967 MiB, 40.08% gc time)
Academic license - for non-commercial use only
  0.242605 seconds (802.34 k allocations: 62.967 MiB, 25.85% gc time)

C:\Users\Oscar\.julia\dev\Gurobi>git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

C:\Users\Oscar\.julia\dev\Gurobi>julia --color=yes benchmark_jump.jl
Academic license - for non-commercial use only
  4.386719 seconds (5.49 M allocations: 294.247 MiB, 4.21% gc time)
Academic license - for non-commercial use only
  1.936523 seconds (802.34 k allocations: 62.966 MiB, 3.52% gc time)
Academic license - for non-commercial use only
  1.981247 seconds (821.42 k allocations: 63.966 MiB, 4.13% gc time)
Academic license - for non-commercial use only
  1.925684 seconds (802.34 k allocations: 62.967 MiB, 1.39% gc time)
Academic license - for non-commercial use only
  2.019717 seconds (802.34 k allocations: 62.967 MiB, 6.44% gc time)

@evanfields
Copy link

I can confirm this branch gives a huge speedup on our research code - thanks! This is a really big deal for the problem we're working on.

Not sure I have much more to add. It seems like there is still meaningful overhead in solver communication; though surely some of that is inevitable. Is there a (distant) future where models can be passed at once rather than built incrementally, leading to further speedups?

@mlubin
Copy link
Member

mlubin commented Jan 31, 2019

Is there a (distant) future where models can be passed at once rather than built incrementally, leading to further speedups?

Yes, MOI is structured to allow this. Gurobi would need to implement copy_to efficiently to construct the constraint matrix all together instead of falling back to incrementally adding constraints.

@odow
Copy link
Member Author

odow commented Jan 31, 2019

Gurobi would need to implement copy_to

LinQuadOptInterface.j should be the one to implement copy_to. The solver wrappers all implement plural arguments. I've opened an issue: JuliaOpt/LinQuadOptInterface.jl#85.

src/MOIWrapper.jl Outdated Show resolved Hide resolved
Copy link
Member

@blegat blegat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be the right fix

@odow odow merged commit 39b75f5 into master Feb 2, 2019
@odow odow deleted the od/moi_speed branch February 2, 2019 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants