Skip to content

[metadata prespecialization] Prespecialize common standard library types #31925

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

Conversation

airspeedswift
Copy link
Member

The standard library is already prespecializing types it uses within itself, but many commonly-used types aren't actually used by the standard library. This adds uses of these types to the std lib to force their prespecialization.

Note this list is not ABI. We can add and remove from it in each release. I generated this starter list by looking for types used by more than 1 app in a sample of a few Mac apps run on my desktop. We should eventually make resampling some representative programs to generate this list part of the Swift release process.

There are some types in this list we can't yet prespecialize (like those parameterized by non-nominal types or AnyObject) but I'm assuming those are coming so they're fine to keep in here.

@airspeedswift
Copy link
Member Author

@swift-ci please test

@airspeedswift
Copy link
Member Author

@swift-ci please benchmark

Copy link
Contributor

@nate-chandler nate-chandler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Some of these won't result in prespecialization immediately (such as those involving existentials) but as the functionality gets brought up it they will.

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
EqualSubstringSubstring 23 30 +30.4% 0.77x
LessSubstringSubstring 23 30 +30.4% 0.77x
EqualStringSubstring 23 30 +30.4% 0.77x (?)
EqualSubstringSubstringGenericEquatable 23 30 +30.4% 0.77x
EqualSubstringString 23 30 +30.4% 0.77x
LessSubstringSubstringGenericComparable 23 30 +30.4% 0.77x
DistinctClassFieldAccesses 177 211 +19.2% 0.84x
StringComparison_longSharedPrefix 323 359 +11.1% 0.90x (?)
ObjectiveCBridgeStringHash 76 84 +10.5% 0.90x (?)
ObjectiveCBridgeStubToNSDate2 330 360 +9.1% 0.92x (?)
StringHasSuffixAscii 1370 1480 +8.0% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
Set.isSubset.Seq.Empty.Int 82 76 -7.3% 1.08x (?)

Code size: -O

Performance: -Osize

Regression OLD NEW DELTA RATIO
EqualSubstringSubstring 23 30 +30.4% 0.77x (?)
EqualStringSubstring 23 30 +30.4% 0.77x
EqualSubstringSubstringGenericEquatable 23 30 +30.4% 0.77x
EqualSubstringString 23 30 +30.4% 0.77x
LessSubstringSubstring 24 31 +29.2% 0.77x
LessSubstringSubstringGenericComparable 24 31 +29.2% 0.77x
StringComparison_longSharedPrefix 319 357 +11.9% 0.89x (?)
ObjectiveCBridgeStringHash 76 84 +10.5% 0.90x (?)
AngryPhonebook.Armenian 157 171 +8.9% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
Set.subtracting.Empty.Int 28 26 -7.1% 1.08x (?)

Code size: -Osize

Performance: -Onone

Regression OLD NEW DELTA RATIO
EqualSubstringSubstringGenericEquatable 27 34 +25.9% 0.79x
LessSubstringSubstringGenericComparable 27 34 +25.9% 0.79x
LessSubstringSubstring 28 35 +25.0% 0.80x
EqualSubstringSubstring 28 34 +21.4% 0.82x (?)
EqualStringSubstring 28 34 +21.4% 0.82x (?)
EqualSubstringString 28 34 +21.4% 0.82x (?)
ObjectiveCBridgeStringHash 76 84 +10.5% 0.90x (?)
AngryPhonebook.Strasse 136 150 +10.3% 0.91x (?)
 
Improvement OLD NEW DELTA RATIO
Set.subtracting.Seq.Empty.Int 339 279 -17.7% 1.22x
Set.isDisjoint.Empty.Int 284 234 -17.6% 1.21x
Set.subtracting.Empty.Int 72 62 -13.9% 1.16x (?)
Set.subtracting.Seq.Int.Empty 560 502 -10.4% 1.12x (?)
StringFromLongWholeSubstring 10 9 -10.0% 1.11x
Set.isStrictSubset.Seq.Int.Empty 683 618 -9.5% 1.11x (?)
Set.subtracting.Int.Empty 98 89 -9.2% 1.10x (?)
Set.isSubset.Seq.Int.Empty 685 624 -8.9% 1.10x (?)

Code size: -swiftlibs

How to read the data The tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.

If you see any unexpected regressions, you should consider fixing the
regressions before you merge the PR.

Noise: Sometimes the performance results (not code size!) contain false
alarms. Unexpected regressions which are marked with '(?)' are probably noise.
If you see regressions which you cannot explain you can try to run the
benchmarks again. If regressions still show up, please consult with the
performance team (@eeckstein).

Hardware Overview
  Model Name: Mac mini
  Model Identifier: Macmini8,1
  Processor Name: 6-Core Intel Core i7
  Processor Speed: 3.2 GHz
  Number of Processors: 1
  Total Number of Cores: 6
  L2 Cache (per Core): 256 KB
  L3 Cache: 12 MB
  Memory: 64 GB

@airspeedswift
Copy link
Member Author

@swift-ci please test windows

@airspeedswift
Copy link
Member Author

@swift-ci please test macOS

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 9cb7dce

@nate-chandler
Copy link
Contributor

@swift-ci please clean test os x platform

@nate-chandler
Copy link
Contributor

@swift-ci please clean test macOS

@airspeedswift airspeedswift merged commit e67e8ab into swiftlang:master May 21, 2020
@airspeedswift airspeedswift deleted the prespecialize-common-metadata branch May 21, 2020 10:50
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