Skip to content

Improvements for cross-module-optimization #32495

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
merged 4 commits into from
Jun 23, 2020

Conversation

eeckstein
Copy link
Contributor

  • Include small non-generic functions for serializaion
  • serialize initializer of global variables: so that global let variables can be constant propagated across modules

rdar://problem/60696510

For details see the commit messages

Unlike SIL functions, there is no way to distinguish a global declaration from a global definition - other than the linkage.
Propagate a value from a static "let" global variable.
This optimization is also done by GlobalOpt, but not with de-serialized globals, which can occur with cross-module optimization.
This is needed for cross-module optimization: it enables constant folding of global let variables which are defined in another module.
* Include small non-generic functions for serializaion
* serialize initializer of global variables: so that global let variables can be constant propagated across modules

rdar://problem/60696510
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
SuffixAnySequence 258 2052 +695.3% 0.13x
DropLastAnySequence 635 1924 +203.0% 0.33x
ObjectiveCBridgeStubFromNSDateRef 4720 5760 +22.0% 0.82x (?)
UTF8Decode_InitFromCustom_contiguous_ascii_as_ascii 390 441 +13.1% 0.88x (?)
CharacterLiteralsLarge 97 108 +11.3% 0.90x (?)
DropFirstSequence 53 59 +11.3% 0.90x
DropFirstSequenceLazy 53 59 +11.3% 0.90x
 
Improvement OLD NEW DELTA RATIO
EqualSubstringSubstring 41 38 -7.3% 1.08x
LessSubstringSubstring 41 38 -7.3% 1.08x
EqualSubstringSubstringGenericEquatable 41 38 -7.3% 1.08x
EqualSubstringString 41 38 -7.3% 1.08x (?)
LessSubstringSubstringGenericComparable 41 38 -7.3% 1.08x
EqualStringSubstring 42 39 -7.1% 1.08x (?)
NSStringConversion.MutableCopy.Rebridge 996 929 -6.7% 1.07x (?)

Code size: -O

Regression OLD NEW DELTA RATIO
Suffix.o 22189 22581 +1.8% 0.98x

Performance: -Osize

Regression OLD NEW DELTA RATIO
DropLastAnySequence 731 2314 +216.6% 0.32x
SuffixAnySequence 800 2169 +171.1% 0.37x
PrefixAnyCollection 182 217 +19.2% 0.84x
SuffixAnyCollection 65 76 +16.9% 0.86x
PrefixWhileAnyCollection 235 269 +14.5% 0.87x
DropFirstSequence 53 59 +11.3% 0.90x
DropFirstSequenceLazy 53 59 +11.3% 0.90x
CharacterLiteralsLarge 100 111 +11.0% 0.90x
ObjectiveCBridgeStubDateAccess 257 285 +10.9% 0.90x
PrefixAnySeqCRangeIterLazy 176 194 +10.2% 0.91x
PrefixAnySeqCntRangeLazy 176 194 +10.2% 0.91x
SuffixCountableRangeLazy 11 12 +9.1% 0.92x (?)
Array2D 7520 8112 +7.9% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
DropFirstAnySeqCRangeIter 61029 182 -99.7% 335.32x
DropFirstAnySeqCntRange 61024 182 -99.7% 335.29x
PrefixAnySeqCntRange 46728 175 -99.6% 267.02x
PrefixAnySeqCRangeIter 46321 193 -99.6% 240.00x
DropWhileSequenceLazy 140 105 -25.0% 1.33x
DropWhileAnySequenceLazy 2524 2125 -15.8% 1.19x (?)
ObjectiveCBridgeStubFromNSDate 7320 6320 -13.7% 1.16x (?)
PrefixAnySequenceLazy 1725 1581 -8.3% 1.09x (?)
SuffixArrayLazy 12 11 -8.3% 1.09x
SuffixArray 12 11 -8.3% 1.09x (?)
EqualSubstringSubstring 41 38 -7.3% 1.08x (?)
EqualStringSubstring 41 38 -7.3% 1.08x (?)
EqualSubstringSubstringGenericEquatable 41 38 -7.3% 1.08x (?)
EqualSubstringString 41 38 -7.3% 1.08x (?)
LessSubstringSubstring 42 39 -7.1% 1.08x (?)
LessSubstringSubstringGenericComparable 42 39 -7.1% 1.08x

Code size: -Osize

Improvement OLD NEW DELTA RATIO
DropFirst.o 18320 17226 -6.0% 1.06x
Prefix.o 18053 17723 -1.8% 1.02x

Performance: -Onone

Regression OLD NEW DELTA RATIO
StrComplexWalk 7560 8250 +9.1% 0.92x
 
Improvement OLD NEW DELTA RATIO
EqualSubstringSubstring 49 45 -8.2% 1.09x (?)

Code size: -swiftlibs

Improvement OLD NEW DELTA RATIO
libswiftDarwin.dylib 32768 28672 -12.5% 1.14x
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 Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a7425c1

@eeckstein
Copy link
Contributor Author

@swift-ci test linux

@eeckstein eeckstein merged commit 15dfa83 into swiftlang:master Jun 23, 2020
@eeckstein eeckstein deleted the cmo-improvements branch June 23, 2020 08:54
@compnerd
Copy link
Member

Hey @eeckstein - this seems to have been checked in with a failing windows test. The CI actually caught that, and the bots are currently red. Could you please look into that or revert this please?

@eeckstein
Copy link
Contributor Author

eeckstein commented Jun 24, 2020

@compnerd Sorry. That's a reminder to always look at the windows build log, too. #32520 will fix it. Unfortunately PR testing is currently broken, so I cannot merge it :-(

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