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

Speed up test/operator.jl, fix bug on Julia 1.0 with Base.warn_one. #1443

Merged
merged 3 commits into from Sep 10, 2018

Conversation

IainNZ
Copy link
Collaborator

@IainNZ IainNZ commented Aug 27, 2018

Operator warning used Base.warn_once, which doesn't exist on Julia 1.0.
Test was unnecessarily expensive to basically just check one function wasn't
called too many times

Comment out all other includes in test/runtests.jl, and in test/operator.jl
comment out extension test. Saving is probably 20 seconds in full test.

Before
real	2m6.533s
user	2m5.312s
sys	0m1.349s

After
real	1m55.578s
user	1m54.548s
sys	0m1.176s

src/JuMP.jl Show resolved Hide resolved
src/JuMP.jl Outdated
@@ -702,15 +712,15 @@ a warning is generated once.
function operator_warn(::AbstractModel) end
function operator_warn(model::Model)
model.operator_counter += 1
if model.operator_counter > 20000
Base.warn_once(
if model.operator_counter > OPERATOR_WARN_LIMIT
Copy link
Member

Choose a reason for hiding this comment

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

This introduces a type inference issue. Maybe OPERATOR_WARN_LIMIT::Int here and function set_operator_warn_limit(new_limit::Int) above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is it because OPERATOR_WARN_LIMIT is a non-const module level global?
It only works on JuMP.Model-s anyway - could make a Model field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would have the benefit of making clear the global-ish behaviour that this has already.

Copy link
Member

Choose a reason for hiding this comment

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

Is it because OPERATOR_WARN_LIMIT is a non-const module level global?

Yep.

could make a Model field?

Seems a bit iffy to add a field to Model just to speed up one test. If the goal is to get test coverage, we might as (1) do some additions and check that operator_counter is nonzero, and (2) call operator_warn directly 20,000 times and make sure it prints the warning.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In fact, later in this file (test/operators.jl), something similar to that happens!
I'm going to integrate the princple of this change into that, and drop the global.

@codecov

This comment has been minimized.

Operator warning used Base.warn_once, which doesn't exist on Julia 1.0.
Test was unnecessarily expensive to basically just check one function wasn't
called too many times

Comment out all other includes in test/runtests.jl, and in test/operator.jl
comment out extension test.

```
Before
real	2m6.533s
user	2m5.312s
sys	0m1.349s

After
real	1m55.578s
user	1m54.548s
sys	0m1.176s
```
@IainNZ
Copy link
Collaborator Author

IainNZ commented Sep 9, 2018

Simplified the change a lot, ready for review (as long as tests pass on CI!)

test/operator.jl Outdated Show resolved Hide resolved
test/operator.jl Outdated Show resolved Hide resolved
test/operator.jl Outdated Show resolved Hide resolved
test/operator.jl Outdated Show resolved Hide resolved
@IainNZ
Copy link
Collaborator Author

IainNZ commented Sep 10, 2018

Updated

@mlubin mlubin merged commit aee3718 into master Sep 10, 2018
@mlubin mlubin deleted the ird/opwarn branch September 10, 2018 14:56
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.

None yet

2 participants