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-10209] Compile Time Regression with Optimization Enabled #52609

Closed
swift-ci opened this issue Mar 28, 2019 · 13 comments
Closed

[SR-10209] Compile Time Regression with Optimization Enabled #52609

swift-ci opened this issue Mar 28, 2019 · 13 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself optimized only Flag: An issue whose reproduction requires optimized compilation performance regression swift 5.0

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-10209
Radar rdar://problem/49522869
Original Reporter eskerber (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Xcode 10.2 (10E125)

Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.2.0

Additional Detail from JIRA
Votes 4
Component/s Compiler
Labels Bug, 5.0Regression, OptimizedOnly, Performance
Assignee @eeckstein
Priority Medium

md5: 649a338e2e34cbfee9dc430aea4138ee

Issue Description:

The open project swift-html-entities contains a file with several extremely large literals defining a Dictionary of [String: Character].

Constants.swift

When building with optimizations enabled (during archiving), the project fails to build for armv7 in a "reasonable" amount of time. In my attempts, I let it run for as much as 560 seconds before terminating the build. The arm64 build finishes in about 30 seconds, still an unusually high amount of time for such a small project.

Using released versions of Xcode/Swift before 10.2 does not result in this behavior, and the archive completes in a few seconds.

@belkadan
Copy link
Contributor

@eeckstein, aschwaighofer@apple.com (JIRA User), is this the same as the other compile time issues with optimizations on?

@eeckstein
Copy link
Member

No, this looks like a separate issue. It's a problem in the inliner and in SimplifyCFG. I don't think we saw those problems on other test cases so far.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Apr 6, 2019

Comment by Robbie Trencheny (JIRA)

I'm personally seeing compile times run over an hour now when they previously took maybe 20 minutes. I've identified the problem as a third party library for using icon fonts, named Iconic. I've documented my findings thus far here. I also found another project having similar issues, SwiftDate.

I can provide a test case from Iconic if necessary. It builds a massive dictionary that maps icon name to unicode character, e.g. "mdi-iphone": "\u0034".

UPDATE 1: Looks like this and this may be related.

UPDATE 2: Disabling optimization doesn't affect build times.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Apr 8, 2019

Comment by Valentin Pertuisot (JIRA)

Hello, I need to add that this issue isn't 5.0 specific, it's Xcode 10.2 specific :

@belkadan
Copy link
Contributor

belkadan commented Apr 8, 2019

"Swift 5.0" refers to the version of the compiler, not the version of the language.

Robbie and Valentin, please file your issues separately; until we know that they have the same root cause, it's more useful to be able to investigate them independently.

@swift-ci
Copy link
Collaborator Author

Comment by Zhao Wang (JIRA)

Hi, I just want to add some information. I am experiencing this issue with my project (it literally stuck and didn't finish for a whole night). The problem happens when I have Swift Compiler -> Optimization Level -> "Optimize for time" selected, which is by default on. If I change to "Optimize for size", then the build process finish quickly.

Hope this can be fixed soon. Thanks.

@belkadan
Copy link
Contributor

Hi, Zhao Wang. Same advice to you: please file your bug separately in case it has a different root cause!

@eeckstein
Copy link
Member

Fixed in #23931

The compile time is still not great, because other optimizations also take time for such huge functions.
But the biggest problems are fixed.

@milseman
Copy link
Mannequin

milseman mannequin commented Apr 25, 2019

@eeckstein, was this cherry-picked onto 5.1?

@eeckstein
Copy link
Member

yes

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Aug 9, 2019

eskerber (JIRA User), Could you verify if the problem is fixed and if so move the JIRA to "Closed"?

Thanks!
Anna

@swift-ci
Copy link
Collaborator Author

Comment by Erik Kerber (JIRA)

@AnnaZaks It does - the optimized Swift build (from the SHA of the project I originally filed this against) now completes in 34 seconds.

@AnnaZaks
Copy link
Mannequin

AnnaZaks mannequin commented Aug 12, 2019

Great! Thank you for confirming.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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 optimized only Flag: An issue whose reproduction requires optimized compilation performance regression swift 5.0
Projects
None yet
Development

No branches or pull requests

4 participants