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

reduce MAX_TYPEUNION_COMPLEXITY to 2 #30833

Merged
merged 1 commit into from
Jan 31, 2019
Merged

reduce MAX_TYPEUNION_COMPLEXITY to 2 #30833

merged 1 commit into from
Jan 31, 2019

Conversation

JeffBezanson
Copy link
Sponsor Member

This helps make the compiler more efficient. In v0.6 the limit was unions with 3 elements, i.e. Union{A,B,C}. However the meaning of the variable was changed to refer to the number of 2-argument union constructors involved, so setting it to 3 allowed unions with 4 elements. This PR reduces the limit down to the same level as in v0.6.

@JeffBezanson JeffBezanson added compiler:inference Type inference compiler:latency Compiler latency labels Jan 25, 2019
@Keno
Copy link
Member

Keno commented Jan 25, 2019

Does it make sense to put this into Params?

@test Core.Compiler.tmerge(Int32, Union{Int16, Nothing, Tuple{ComplexF32, ComplexF32}}) ==
Union{Int16, Int32, Nothing, Tuple{ComplexF32, ComplexF32}}
@test Core.Compiler.tmerge(Union{Int32, Nothing, Tuple{ComplexF32}}, Union{Int16, Nothing, Tuple{ComplexF32, ComplexF32}}) ==
@test Core.Compiler.tmerge(Union{Int32, Nothing, Tuple{ComplexF32}}, Union{Int32, Nothing, Tuple{ComplexF32, ComplexF32}}) ==
Union{Int16, Int32, Nothing, Tuple{Vararg{ComplexF32}}}
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

how does Int16 get in there?

@vtjnash vtjnash added the needs nanosoldier run This PR should have benchmarks run on it label Jan 25, 2019
@JeffBezanson
Copy link
Sponsor Member Author

Does it make sense to put this into Params?

I'm not sure; this mostly controls how fast we widen when type information isn't too good, so I suspect there aren't many use cases.

@JeffBezanson
Copy link
Sponsor Member Author

Aha, one use of this limit was comparing with <= and another used <. That helps explain why it was set the way it was.

@JeffBezanson
Copy link
Sponsor Member Author

@nanosoldier runbenchmarks(ALL, vs = ":master")

@martinholters
Copy link
Member

Ah, good catch.

@KristofferC
Copy link
Sponsor Member

Any numbers to share? Just curious (and presumably some benchmarking justified this).

@JeffBezanson
Copy link
Sponsor Member Author

It reduces the time to first plot by 1 second. Disappointing, but I think still makes sense since it restores what we did in 0.6. There could also very well be other cases that benefit more.

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@JeffBezanson
Copy link
Sponsor Member Author

@nanosoldier runbenchmarks("problem", vs = ":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - no performance regressions were detected. A full report can be found here. cc @ararslan

@JeffBezanson
Copy link
Sponsor Member Author

Ok, I think we actually need two kinds of limits here. One is on "length", i.e. Union{a, b, c, ...}, looking only inside Union types. The other is on nesting depth of unions and tuples, arising from recursion. That allows us to shorten the first limit, without excluding cases like Union{Nothing, Tuple{Union{A,B}}}.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference compiler:latency Compiler latency needs nanosoldier run This PR should have benchmarks run on it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants