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

[SILGen] Use temporary initializer for switch address subject. #32072

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zoecarver
Copy link
Contributor

@zoecarver zoecarver commented May 28, 2020

If the subject of a switch statement is a tuple address, using an initializer to initialize it gets rid of one stack allocation for each tuple element.

Based on #31779.

Right now we also have to create a temporary allocation but, I have another patch that removes it in SILGen.

Update: removed example that is no longer correct.

If the subject of a switch statement is an address, use an initializer to initialize it. This produces better codegen in some cases.
@zoecarver
Copy link
Contributor Author

@swift-ci please benchmark.

@zoecarver
Copy link
Contributor Author

@swift-ci please benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
EqualSubstringSubstring 22 30 +36.4% 0.73x
LessSubstringSubstring 22 30 +36.4% 0.73x
EqualSubstringSubstringGenericEquatable 22 30 +36.4% 0.73x
LessSubstringSubstringGenericComparable 22 30 +36.4% 0.73x
EqualStringSubstring 23 31 +34.8% 0.74x
EqualSubstringString 23 30 +30.4% 0.77x
ObjectiveCBridgeStubFromNSDate 3790 4630 +22.2% 0.82x (?)
ObjectiveCBridgeStringHash 72 84 +16.7% 0.86x
ArrayAppendLatin1Substring 19332 22536 +16.6% 0.86x (?)
ArrayAppendAsciiSubstring 18936 22068 +16.5% 0.86x (?)
ArrayAppendUTF16Substring 18972 22068 +16.3% 0.86x (?)
UTF8Decode_InitDecoding 141 164 +16.3% 0.86x
UTF8Decode_InitFromCustom_contiguous 142 164 +15.5% 0.87x (?)
Breadcrumbs.MutatedIdxToUTF16.Mixed 185 209 +13.0% 0.89x
DataAccessBytesMedium 45 50 +11.1% 0.90x (?)
Data.hash.Empty 45 50 +11.1% 0.90x
StringComparison_longSharedPrefix 321 356 +10.9% 0.90x (?)
ObjectiveCBridgeStringGetASCIIContents 287 317 +10.5% 0.91x (?)
AngryPhonebook.Strasse 136 149 +9.6% 0.91x (?)
UTF8Decode_InitFromCustom_noncontiguous 302 329 +8.9% 0.92x (?)
IterateData 901 980 +8.8% 0.92x (?)
SubstringEqualString 276 297 +7.6% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
ChainedFilterMap 621 504 -18.8% 1.23x (?)
ArrayAppendLazyMap 850 690 -18.8% 1.23x (?)

Code size: -O

Regression OLD NEW DELTA RATIO
DictionaryKeysContains.o 8299 8620 +3.9% 0.96x
DictionaryCompactMapValues.o 13093 13509 +3.2% 0.97x
 
Improvement OLD NEW DELTA RATIO
ChainedFilterMap.o 3429 3365 -1.9% 1.02x

Performance: -Osize

Regression OLD NEW DELTA RATIO
ArrayAppendRepeatCol 420 850 +102.4% 0.49x
EqualSubstringSubstring 22 30 +36.4% 0.73x
EqualStringSubstring 22 30 +36.4% 0.73x
EqualSubstringSubstringGenericEquatable 22 30 +36.4% 0.73x
EqualSubstringString 22 30 +36.4% 0.73x
LessSubstringSubstring 23 31 +34.8% 0.74x
LessSubstringSubstringGenericComparable 23 30 +30.4% 0.77x
ObjectiveCBridgeStringHash 71 84 +18.3% 0.85x (?)
UTF8Decode_InitDecoding 140 165 +17.9% 0.85x
UTF8Decode_InitFromCustom_contiguous 144 168 +16.7% 0.86x
Breadcrumbs.MutatedUTF16ToIdx.Mixed 181 204 +12.7% 0.89x
Breadcrumbs.MutatedIdxToUTF16.Mixed 185 208 +12.4% 0.89x
StringComparison_longSharedPrefix 324 361 +11.4% 0.90x (?)
ArrayAppendLatin1Substring 19368 21492 +11.0% 0.90x (?)
ArrayAppendUTF16Substring 19008 21060 +10.8% 0.90x (?)
ArrayAppendAsciiSubstring 19008 21060 +10.8% 0.90x (?)
AngryPhonebook.Strasse 136 150 +10.3% 0.91x (?)
ObjectiveCBridgeStringGetASCIIContents 288 317 +10.1% 0.91x
UTF8Decode_InitFromData 148 162 +9.5% 0.91x (?)
FlattenListFlatMap 4164 4540 +9.0% 0.92x (?)
AngryPhonebook 252 273 +8.3% 0.92x
Calculator 156 168 +7.7% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
Dictionary4OfObjects 328 276 -15.9% 1.19x
Dictionary4 240 207 -13.7% 1.16x
DropWhileAnySeqCntRange 105 96 -8.6% 1.09x (?)
StrToInt 1210 1120 -7.4% 1.08x (?)
DropWhileAnyCollectionLazy 157 146 -7.0% 1.08x (?)
RGBHistogram 1640 1530 -6.7% 1.07x (?)

Code size: -Osize

Regression OLD NEW DELTA RATIO
DictionaryKeysContains.o 8108 8508 +4.9% 0.95x
DictionaryCompactMapValues.o 12330 12730 +3.2% 0.97x
 
Improvement OLD NEW DELTA RATIO
SortLettersInPlace.o 8173 8005 -2.1% 1.02x
ChainedFilterMap.o 3334 3286 -1.4% 1.01x

Performance: -Onone

Regression OLD NEW DELTA RATIO
CaptureProp 416020 567160 +36.3% 0.73x
LessSubstringSubstring 27 35 +29.6% 0.77x
EqualSubstringSubstringGenericEquatable 27 35 +29.6% 0.77x
EqualSubstringSubstring 27 34 +25.9% 0.79x
LessSubstringSubstringGenericComparable 27 34 +25.9% 0.79x
EqualStringSubstring 28 35 +25.0% 0.80x
EqualSubstringString 28 35 +25.0% 0.80x
ObjectiveCBridgeStringHash 72 86 +19.4% 0.84x (?)
UTF8Decode_InitDecoding 146 173 +18.5% 0.84x
UTF8Decode_InitFromCustom_contiguous 149 174 +16.8% 0.86x
Breadcrumbs.MutatedIdxToUTF16.Mixed 198 223 +12.6% 0.89x (?)
Breadcrumbs.MutatedUTF16ToIdx.Mixed 196 220 +12.2% 0.89x (?)
StringRemoveDupes 490 547 +11.6% 0.90x (?)
ObjectiveCBridgeStringGetASCIIContents 287 317 +10.5% 0.91x (?)
AngryPhonebook.Strasse 136 149 +9.6% 0.91x (?)
 
Improvement OLD NEW DELTA RATIO
StringWalk 2920 2480 -15.1% 1.18x (?)
ArrayOfPOD 723 643 -11.1% 1.12x (?)
PrefixSequenceLazy 3543 3219 -9.1% 1.10x (?)
ObjectiveCBridgeStubToNSDateRef 2720 2480 -8.8% 1.10x (?)
PrefixWhileSequenceLazy 4696 4306 -8.3% 1.09x (?)
PrefixSequence 3513 3228 -8.1% 1.09x (?)

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

@shahmishal
Copy link
Member

Please update the base branch to main by Oct 5th otherwise the pull request will be closed automatically.

  • How to change the base branch: (Link)
  • More detail about the branch update: (Link)

@zoecarver zoecarver changed the base branch from master to main October 2, 2020 04:02
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