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

Use Unicode.Scalar initializer for most character definitions #51

Merged
merged 1 commit into from
Apr 29, 2019

Conversation

erikkerber
Copy link
Contributor

@erikkerber erikkerber commented Mar 27, 2019

Description

To resolve a drastic degradation in compiling optimized Swift code using, as is present in Constants.swift, thousands of literals, a large conversion to using Character initializers helped the build process at least complete on hardware that is-of-this-world.

Important to note that any character that required multiple code points, I kept the original escaped String sequence.

Motivation and Context

Issue as described in #50

How Has This Been Tested?

Unit tests pass, archive completes.

Checklist:

  • I have submitted a CLA form
  • If applicable, I have updated the documentation accordingly.
  • If applicable, I have added tests to cover my changes.

@erikkerber
Copy link
Contributor Author

erikkerber commented Mar 27, 2019

Unfortunately the diff is not going to be particularly friendly if you want to guarantee correctness for literally every entry. There are tests, and they are good tests, but I do not believe they would catch every single mistake.

@erikkerber
Copy link
Contributor Author

@ianpartridge any thoughts on this?

@pushkarnk
Copy link

Hi @eskerber , can you please sign the CLA?

@erikkerber
Copy link
Contributor Author

@pushkarnk I signed it a while ago. The bot is not working.

@pushkarnk
Copy link

pushkarnk commented Apr 5, 2019

@eskerber Thanks for submitting this pull request! I can see that this change is working around an apparent Swift compiler issue and giving us a considerable performance boost. I am just curious to know if the compiler limitation is around "managing constants" or "handling constants in a dictionary". If the limitation is about constants in a dictionary, is it worth writing an embarrassingly long switch statement to map the Strings to Characters? If it is about managing constants overall, I don't think we can do much.

Eager to know your views!

@erikkerber
Copy link
Contributor Author

erikkerber commented Apr 5, 2019

@pushkarnk I posted the SR I created for this in the referenced issue:

https://bugs.swift.org/browse/SR-10209

It is a performance regression in Swift 5 optimizations that the team is investigating. I imagine they will fix this in relatively short order (even though that means waiting for a new Swift/Xcode release), so I wouldn't necessarily spend too much time gutting the current implementation.

It's difficult to know exactly if whatever inlining is being held up is simply a result of how many literals there are vs them being in a dictionary. For what it's worth, I did try to break up the dictionaries into a series of dictionary merges 4-5 key/value pairs at a time and it was still slow.

@pushkarnk
Copy link

pushkarnk commented Apr 10, 2019

There's no harm in accepting this PR as a work-around for a serious performance problem with the swift compiler. We must revisit this problem once there is a resolution for SR-10209.

@pushkarnk pushkarnk self-requested a review April 10, 2019 18:52
@pushkarnk
Copy link

@eskerber The branch has conflicts. If you could rebase it, I'll go ahead and merge this.

@pushkarnk
Copy link

Hi @eskerber , just wanted to check if you could rebase your branch against the latest master. We can get this merged. Thanks!

@erikkerber erikkerber force-pushed the swift-4.2-optimization-fix branch from abbc82b to a9003b6 Compare April 25, 2019 18:04
@erikkerber
Copy link
Contributor Author

Sorry - usually spend my time in enterprise Github

Rebased 👍

@pushkarnk
Copy link

Oh, the failures seem to be Travis issues. We're seeing them on other repos too.

@ianpartridge
Copy link
Contributor

Yes @djones6 and I know what the problem is. Will fix ASAP.

@pushkarnk
Copy link

Hi @djones6 , @eskerber has signed the CLA but the bot doesn't seem to report so. Can you please advise what we could do here?

@ianpartridge
Copy link
Contributor

Can we test whether the slow compilation is still a problem in Swift 5.0.1? I know there were some optimizer performance fixes included in 5.0.1 so if the problem in the compiler is fixed that would make this PR moot?

@brentleyjones
Copy link

I believe it was still an issue when we checked.

@erikkerber
Copy link
Contributor Author

erikkerber commented Apr 29, 2019

@ianpartridge
Copy link
Contributor

OK thanks for checking. Let's release this 👍

@ianpartridge ianpartridge merged commit b8ddf22 into Kitura:master Apr 29, 2019
@ianpartridge
Copy link
Contributor

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.

4 participants