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-6037] [Xcode 9] Compile too slow and re-compile every files #48594

Open
swift-ci opened this issue Oct 1, 2017 · 17 comments
Open

[SR-6037] [Xcode 9] Compile too slow and re-compile every files #48594

swift-ci opened this issue Oct 1, 2017 · 17 comments
Labels
compiler The Swift compiler in itself improvement performance

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 1, 2017

Previous ID SR-6037
Radar rdar://problem/34783005
Original Reporter haithngn (JIRA User)
Type Improvement
Status Reopened
Resolution

Attachment: Download

Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels Improvement, Performance
Assignee None
Priority Medium

md5: 7d07dc87f97cf2069847cef5b35d3070

Issue Description:

I was facing with this issue in xcode 8 and now it still happens in the Xcode 9 final with Swift 4.0.

My project write in pure Swift all frameworks are built via Carthage. The compiler take long time at the first compile after clean all previous build.

Sometime, a little change on any file that make Xcode ide re-compile every swift files.

I hope you can show more suggestions in the Xcode that will help us figure out where are the bad swift syntax to improve the compile time.

Thank you Apple 🙂 !

@belkadan
Copy link
Contributor

belkadan commented Oct 2, 2017

Thanks for reporting the issue; it's something we know is still a problem. Would you mind attaching your project so that we have another concrete test case to investigate? More examples of real code are always helpful.

(If you're worried about posting your code publicly, you can also file a bug report with just Apple at https://bugreport.apple.com.)

@swift-ci
Copy link
Collaborator Author

swift-ci commented Oct 3, 2017

Comment by Nguyen Thanh Hai (JIRA)

@@belkadan, thank you for your reply, I have create a problem at https://bugreport.apple.com/web/?problemID=34783005

and also attached full project's source code, hope it can help you.
Hai,

@belkadan
Copy link
Contributor

belkadan commented Oct 5, 2017

Thanks! This is a great test case for us. Meanwhile, we noticed that the project actually compiles much faster under Whole-Module Optimization mode with actual optimization manually turned off. This isn't an officially supported configuration, and it gives up entirely on incremental builds, but there are a number of people who've seen enough improvement to make it worth it. To enable this, set your Optimization Level to "Fast, Whole Module Optimization", but then add "-Onone" to the "Other Swift Flags" build setting in the Debug configuration.

@swift-ci
Copy link
Collaborator Author

Comment by Nguyen Thanh Hai (JIRA)

@belkadan,
It's does not work (Xcode 9.1), compiler is now very very slow and compile every file whenever I make a modify swift codes,
your trick just help Xcode hide the build's message the compiling still bad

🙁,

@swift-ci
Copy link
Collaborator Author

Comment by Nguyen Thanh Hai (JIRA)

It still happens on Xcode 9.2, please fix asap

@swift-ci
Copy link
Collaborator Author

Comment by Bang Nguyen (JIRA)

Seems still happen with my project with Xcode 9.2: change 1 swift file in a framework -> trigger rebuild all source file in dependencies (even just change private function 🙁)

@belkadan
Copy link
Contributor

Bang, any chance you can share your project as well? It's likely a separate issue from Thanh Hai's.

@swift-ci
Copy link
Collaborator Author

Comment by Nguyen Thanh Hai (JIRA)

@belkadan, do we have any solution for this issue ?

The xcode 9.2 took more than 1 hour to compile my project.

And it's do it too many times. Please help asap.
Tks

@swift-ci
Copy link
Collaborator Author

Comment by Bang Nguyen (JIRA)

Hi @belkadan,

Yes, I generate that project for testing. I have a workspace: TestBreakToSmallProject.xcworkspace, including 2 subprojects: CoreLib and App. App uses the CoreLib.

There are 200 swift files in each of CoreLib and App.

If I change a swift file in App, incremental build is very fast, ~ 5s.

But if I change a swift file in CoreLib (eg. in NothingManager263.swift, rename a private function), incremental build takes 39s (I see Xcode rebuild all swift files in CoreLib and App).

Here is my test project:

TestSwiftCompileTime.zip

Thanks

Bang Nguyen

@swift-ci
Copy link
Collaborator Author

Comment by Bang Nguyen (JIRA)

OMG, I test and see the WMO and -Onone still can help to speed up swift build in Xcode 9.2!!

@swift-ci
Copy link
Collaborator Author

Comment by Nguyen Thanh Hai (JIRA)

Hi BangNguyen (JIRA User), @belkadan,

I have compared Xcode with Jetbrain's Appcode IDE, there are whats I saw.

At the first time I compile the source code the cost to finish is quite same.

But other compile later Appcode just re-compile some modified files and/or some related file not re-build all files like Xcode do.

My project is now go bigger, I hope Apple will release a better swift compiler soon.
Tks

@swift-ci
Copy link
Collaborator Author

Comment by Nguyen Thanh Hai (JIRA)

hi @belkadan,

I have migrated my project's frameworks to Swift 4.1 to compilable in Xcode 9.3 final.
This issue was solved in this xcode version, now the IDE do not re-build all swift files when I made a change on them, they just re-compile a few related files so it's quite faster.

There are a little performance issue with closure but it's does not important right now.

That's awesome thing I have waiting for a year.

Thank you Apple Team.

@swift-ci
Copy link
Collaborator Author

Comment by Nguyen Thanh Hai (JIRA)

Today I use xcode 9.4.1,

I change 1 line in a swift file then xcode compile alot of file same all project

Please improve this.

@belkadan
Copy link
Contributor

Does this still happen with the project you attached? What change did you make, so that we can reproduce the problem?

@swift-ci
Copy link
Collaborator Author

Comment by Nguyen Thanh Hai (JIRA)

@belkadan yes, it still.

Project is now bigger then this issue is now more serious.

@belkadan
Copy link
Contributor

Sorry, please include an example of "I changed line X in file Y to 'zzz' and more things recompiled than I expected".

@swift-ci
Copy link
Collaborator Author

Comment by Nguyen Thanh Hai (JIRA)

I have compiled succeed and ran on a Simulator then I make change on value of a variable:

From
'private let htmlContainerSuffix = "</textarea>" +
"<!– Initialize the editor. -->" +
"<script>$(function() {$('#froala-editor')" +
".froalaEditor({toolbarSticky: false," + "colorsHEXInput: false," +
"placeholderText: ''," +
"heightMin: 500," +
"toolbarButtons: (buttons)," +
"toolbarButtonsXS: (buttons)," +
"toolbarButtonsSM: (buttons)," +
"toolbarButtonsMD: (buttons)," +
"linkList: []," +
"autofocus: true"'

to

private let htmlContainerSuffix = "</textarea>" +
"<!– Initialize the editor. -->" +
"<script>$(function() {$('#froala-editor')" +
".froalaEditor({toolbarSticky: false," + "colorsHEXInput: false," +
"placeholderText: ''," +
"heightMin: 500," +
"toolbarButtons: (buttons)," +
"toolbarButtonsXS: (buttons)," +
"toolbarButtonsSM: (buttons)," +
"toolbarButtonsMD: (buttons)," +
"linkList: []," +
"autofocus: false"'

Hit run, so a lot of file will be re-compile even al project maybe re-compile. It's take a lot of time for each change sometime the compiler raise a error like missing/too small file, etc...

![](Screen Shot 2018-07-19 at 09.49.24.png)

@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
compiler The Swift compiler in itself improvement performance
Projects
None yet
Development

No branches or pull requests

2 participants