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

break some dependency backedges #20792

Merged
merged 1 commit into from
Mar 3, 2017
Merged

break some dependency backedges #20792

merged 1 commit into from
Mar 3, 2017

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Feb 24, 2017

This might be nicer if we had function types (so that we could declared that function == end::Bool for example), but this tries to at least hit a couple of the high points.

fix #20780

The main issue here was that BitArray deprecated bitwise operations, so | and ! ended with a lot of edges between anything with bitwise operations or for loops and anything required for printing warnings.

max{T<:Real}(x::T, y::T) = ifelse(y < x, x, y)
min{T<:Real}(x::T, y::T) = ifelse(y < x, y, x)
max{T<:Real}(x::T, y::T) = select_value(y < x, x, y)
min{T<:Real}(x::T, y::T) = select_value(y < x, y, x)
Copy link
Member

Choose a reason for hiding this comment

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

Now that the other methods of ifelse are deprecated, I suppose we could replace ifelse and select_value with a single ifelse builtin.

Copy link
Member Author

Choose a reason for hiding this comment

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

once the deprecations get removed, that does seem to be true

@KristofferC
Copy link
Member

KristofferC commented Feb 25, 2017

With this PR, loading Crayons.jl take 0.037s instead of 1.0s as on master and 0.017 on 0.5. Good enough for me :)

@@ -826,6 +826,7 @@ end
# Deprecate vectorized !
@deprecate(!(A::AbstractArray{Bool}), .!A) # parens for #20541
@deprecate(!(B::BitArray), .!B) # parens for #20541
!(::typeof(!)) = identity # make sure ! has at least 4 methods so that for-loops don't end up getting a back-edge to depwarn
Copy link
Member

Choose a reason for hiding this comment

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

I think it's a bit of a gotcha if !! accepts arguments that ! doesn't. Also, not too long from now the two deprecated methods of ! will be removed, which also removes the need for this method (IIUC), but in the meantime code could have become dependent on this behavior. So I think it would be helpful to type-restrict this.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK. I went with just creating an unused Function for this purpose

@tkelman
Copy link
Contributor

tkelman commented Mar 1, 2017

it's not exactly recommended, but there are packages that define comparison operators that return non Bool, that might get caught by these type annotations

@JeffBezanson
Copy link
Member

If a package wants to do that, it should be able to work around this by adding methods for e.g. != as well.

@tkelman
Copy link
Contributor

tkelman commented Mar 1, 2017

wouldn't it have to do that for all possible subtypes of Real and Number that promotion might send through these methods?

@JeffBezanson
Copy link
Member

I see what you mean now; yes the ones on the methods that call promote seem too strict.

@vtjnash
Copy link
Member Author

vtjnash commented Mar 2, 2017

Maybe I should assert that promote(x, y) returns Tuple{T, T} where T <: Real?

@tkelman
Copy link
Contributor

tkelman commented Mar 2, 2017

Is it possible to achieve the goals of this PR in another way that doesn't force promotion constraints for arbitrary user types in these fallbacks?

@vtjnash
Copy link
Member Author

vtjnash commented Mar 2, 2017

No. This PR is all about making sure type information can be better preserved.

@tkelman
Copy link
Contributor

tkelman commented Mar 2, 2017

By imposing type-assertion constraints that we previously have not been forcing on user code, which makes this a potentially breaking change post-feature-freeze.

This would be nicer if we had function types,
but this tries to at least hit a couple of the high points

fix #20780
@vtjnash
Copy link
Member Author

vtjnash commented Mar 2, 2017

Ah well, it looks like that was insufficient to break that edge anyways – it's too prevalent from other code too.

@tkelman
Copy link
Contributor

tkelman commented Mar 2, 2017

The version in 7be9009 looks safer, the != method could be overridden if needed as Jeff said.

I'd run nanosoldier here if I weren't currently hogging the workers elsewhere. Can keep an eye on the nightly runs.

@vtjnash vtjnash merged commit 1c90ed6 into master Mar 3, 2017
@vtjnash vtjnash deleted the jn/20780 branch March 3, 2017 22:54
@tkelman
Copy link
Contributor

tkelman commented Mar 4, 2017

@vtjnash
Copy link
Member Author

vtjnash commented Mar 5, 2017

Looks like that should be fixed by #20853. This commit had a bunch of coupled side-effects (type-assert not being effect-free meant that we were now able to generate line-number information for !=, but also pushed mod over the inlining threshold)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compilation time regression when extending a Base method.
4 participants