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

[SR-6672] 7+ chained optionals makes compilation take a very long time. #49221

Open
swift-ci opened this issue Dec 28, 2017 · 3 comments
Open
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself performance type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6672
Radar None
Original Reporter etc (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Performance, TypeChecker
Assignee None
Priority Medium

md5: 7febdbee7e421e96be4e0eb6f75effb3

Issue Description:

Putting this into "test.swift" and running "swiftc test.swift && ./test" takes many minutes to compile.

func read() -> String? {
return "hi"
}

func main() {
let x = read() ?? read() ?? read() ?? read() ?? read() ?? read() ?? read() ?? read() ?? read() ?? read() ?? read()
print(x!)
}

main()

However if you have only 6 of the read calls, for example, it takes seconds. 7 or more takes a very long time.

$ swiftc --version
Swift version 4.1-dev (LLVM 67b9a8e8c2, Clang e617c83242, Swift 4c99be4)
Target: x86_64-unknown-linux-gnu

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial

@swift-ci
Copy link
Collaborator Author

Comment by Charles (JIRA)

Also they have to all be in the same assignment.

If you split up the 7 between two let statements it doesn't take long to compile.

@belkadan
Copy link
Contributor

belkadan commented Jan 2, 2018

cc @rudkx, @xedin

@xedin
Copy link
Member

xedin commented Jan 2, 2018

There are still perf problems with operator chaining unfortunately, especially when there are 5+ operators involved, but we are actively working on trying to resolve underlying issue. Thanks for reporting, etc (JIRA User)!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself performance type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants