Skip to content

Fix one source of exponential behavior in the type checker. #6730

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

Merged
merged 1 commit into from
Jan 11, 2017
Merged

Fix one source of exponential behavior in the type checker. #6730

merged 1 commit into from
Jan 11, 2017

Conversation

rudkx
Copy link
Contributor

@rudkx rudkx commented Jan 11, 2017

For collection literals that contained implicitly unwrapped optionals,
we were attempting three different conversions per element of the
collection, resulting in exponential type checking time.

We should only ever attempt one of these conversions for any pair of
types where one or both is optional.

We had several reports of this as it seems quite common for people to
write expressions that create a collection of IUOs from class/struct
elements, and then either return the collection or some variation that
has been filtered and mapped.

I am looking at adding the appropriate instrumentation to the type
checker so that I can add a scale-test for this and other type checker
test cases related to slow type checking so that we can avoid regressing
in the future.

(cherry picked from commit 1efafbc)

For collection literals that contained implicitly unwrapped optionals,
we were attempting three different conversions per element of the
collection, resulting in exponential type checking time.

We should only ever attempt one of these conversions for any pair of
types where one or both is optional.

We had several reports of this as it seems quite common for people to
write expressions that create a collection of IUOs from class/struct
elements, and then either return the collection or some variation that
has been filtered and mapped.

I am looking at adding the appropriate instrumentation to the type
checker so that I can add a scale-test for this and other type checker
test cases related to slow type checking so that we can avoid regressing
in the future.

(cherry picked from commit 1efafbc)
@rudkx rudkx added this to the Swift 3.1 milestone Jan 11, 2017
@rudkx
Copy link
Contributor Author

rudkx commented Jan 11, 2017

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 0953bba
Test requested by - @rudkx

@rudkx
Copy link
Contributor Author

rudkx commented Jan 11, 2017

The test failures appear to be unrelated to my change, and happening on master as well.

@tkremenek tkremenek merged commit a86b8e7 into swiftlang:swift-3.1-branch Jan 11, 2017
@rudkx rudkx deleted the reduce-iuo-exponential-behavior-3.1 branch January 11, 2017 16:24
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.

3 participants