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

Sema: Rewrite partial applications into closures #28698

Merged
merged 4 commits into from
Mar 18, 2020

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Dec 11, 2019

Fixes rdar://21289579 / https://bugs.swift.org/browse/SR-75.

There's a big follow-up cleanup, which is removing curry thunks and assorted machinery from SILGen. I'll land that separately.

@slavapestov slavapestov changed the title Rewrite partially-applied methods into closures in CSApply Sema: Rewrite partial applications into closures Dec 12, 2019
@slavapestov slavapestov marked this pull request as ready for review December 17, 2019 02:48
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 76dd4c9722b7222a32abc60b9ded6189c84f02af

@swift-ci
Copy link
Contributor

Build failed before running benchmark.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 76dd4c9722b7222a32abc60b9ded6189c84f02af

@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor Author

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
StaticArray 1 4 +299.7% 0.25x
SortAdjacentIntPyramids 735 2055 +179.6% 0.36x
NibbleSort 2140 5530 +158.4% 0.39x
Phonebook 1246 3192 +156.2% 0.39x
SortIntPyramid 480 955 +99.0% 0.50x
Dictionary4 161 251 +55.9% 0.64x
Set.isSubset.Int.Empty 47 51 +8.5% 0.92x (?)
Set.isStrictSuperset.Seq.Empty.Int 154 166 +7.8% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod 2460 1380 -43.9% 1.78x
ObserverUnappliedMethod 1500 860 -42.7% 1.74x
LessSubstringSubstring 28 21 -25.0% 1.33x
EqualSubstringString 28 21 -25.0% 1.33x
LessSubstringSubstringGenericComparable 28 21 -25.0% 1.33x
EqualSubstringSubstring 28 22 -21.4% 1.27x
EqualStringSubstring 28 22 -21.4% 1.27x
EqualSubstringSubstringGenericEquatable 28 22 -21.4% 1.27x
DictionaryCompactMapValuesOfCastValue 6426 5076 -21.0% 1.27x

Code size: -O

Regression OLD NEW DELTA RATIO
SortIntPyramids.o 11623 12522 +7.7% 0.93x
NibbleSort.o 12294 13040 +6.1% 0.94x
StaticArray.o 13353 14110 +5.7% 0.95x
SortStrings.o 27618 29048 +5.2% 0.95x
Breadcrumbs.o 43879 45631 +4.0% 0.96x
Phonebook.o 11649 12098 +3.9% 0.96x
DriverUtils.o 148548 151937 +2.3% 0.98x
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod.o 3263 3077 -5.7% 1.06x
ObserverUnappliedMethod.o 4728 4589 -2.9% 1.03x
DictionaryCompactMapValues.o 17441 16949 -2.8% 1.03x

Performance: -Osize

Regression OLD NEW DELTA RATIO
StaticArray 1 3 +199.8% 0.33x (?)
SortAdjacentIntPyramids 680 2020 +197.1% 0.34x
Phonebook 1281 3059 +138.8% 0.42x
SortIntPyramid 535 1000 +86.9% 0.54x
NibbleSort 2440 4500 +84.4% 0.54x
Set.isDisjoint.Box.Empty 90 100 +11.1% 0.90x (?)
Set.isStrictSubset.Int.Empty 47 52 +10.6% 0.90x (?)
StringHasPrefixAscii 1130 1240 +9.7% 0.91x (?)
StringHashing_fastPrenormal 550 600 +9.1% 0.92x (?)
NormalizedIterator_fastPrenormal 610 660 +8.2% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
ObserverUnappliedMethod 1480 840 -43.2% 1.76x
ObserverPartiallyAppliedMethod 2460 1460 -40.7% 1.68x
DictionaryCompactMapValuesOfCastValue 6696 5022 -25.0% 1.33x
LessSubstringSubstring 27 21 -22.2% 1.29x (?)
EqualSubstringString 27 21 -22.2% 1.29x
LessSubstringSubstringGenericComparable 27 21 -22.2% 1.29x (?)
EqualSubstringSubstring 28 22 -21.4% 1.27x
EqualStringSubstring 28 22 -21.4% 1.27x (?)
EqualSubstringSubstringGenericEquatable 28 22 -21.4% 1.27x
Dictionary4 204 168 -17.6% 1.21x (?)
Set.isSubset.Int.Empty 53 46 -13.2% 1.15x (?)
StringComparison_longSharedPrefix 351 314 -10.5% 1.12x (?)
NSStringConversion.Long 589 549 -6.8% 1.07x (?)

Code size: -Osize

Regression OLD NEW DELTA RATIO
SortIntPyramids.o 11861 12672 +6.8% 0.94x
Phonebook.o 11151 11800 +5.8% 0.95x
StaticArray.o 11918 12572 +5.5% 0.95x
NibbleSort.o 12028 12686 +5.5% 0.95x
SortStrings.o 27592 28638 +3.8% 0.96x
DriverUtils.o 130608 134821 +3.2% 0.97x
Breadcrumbs.o 42750 43694 +2.2% 0.98x
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod.o 3687 3442 -6.6% 1.07x
DictionaryCompactMapValues.o 12743 12059 -5.4% 1.06x
ObserverUnappliedMethod.o 4968 4749 -4.4% 1.05x
StringReplaceSubrange.o 4705 4625 -1.7% 1.02x
SetTests.o 120277 118549 -1.4% 1.01x

Performance: -Onone

Improvement OLD NEW DELTA RATIO
IterateData 3025 2129 -29.6% 1.42x
EqualSubstringSubstringGenericEquatable 31 25 -19.4% 1.24x
LessSubstringSubstringGenericComparable 31 25 -19.4% 1.24x
EqualSubstringSubstring 32 26 -18.7% 1.23x
LessSubstringSubstring 32 26 -18.7% 1.23x
ObserverUnappliedMethod 7250 6030 -16.8% 1.20x
EqualStringSubstring 32 27 -15.6% 1.19x
EqualSubstringString 32 27 -15.6% 1.19x (?)
ObserverPartiallyAppliedMethod 6560 5560 -15.2% 1.18x
ArrayOfGenericPOD2 813 752 -7.5% 1.08x (?)
MapReduceShortString 163 151 -7.4% 1.08x (?)
MapReduceLazySequence 13612 12642 -7.1% 1.08x (?)

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: 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

let _ = AClass(x: 1).foo
// CHECK: [[@LINE-1]]:22 | instance-method/Swift | foo() | [[AClass_foo_USR]] | Ref | rel: 0
// CHECK: [[@LINE-1]]:22 | instance-method/Swift | foo() | [[AClass_foo_USR]] | Ref,Call | rel: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Marking these as "call sites" is inaccurate, could you correct this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test passes with no changes in the latest version of the commit.

@@ -352,7 +352,7 @@ let otherInstance = AStruct(x: 1)

_ = AStruct.init(x:)
// CHECK: [[@LINE-1]]:18 | instance-property/Swift | x | [[AStruct_x_USR]] | Ref | rel: 0
// CHECK: [[@LINE-2]]:5 | struct/Swift | AStruct | [[AStruct_USR]] | Ref | rel: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the reference to AStruct in this line not reported anymore?

return 2;
} else if (auto *elt = dyn_cast<EnumElementDecl>(member)) {
return elt->getParameterList() ? 2 : 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the brains of this function just be ValueDecl::getNumCurryLevels()? The assertions are still good to keep.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup! Thanks.

Type type;
Type type = openedType;

if (!outerDC->getSelfProtocolDecl()) {
Copy link
Contributor

@CodaFi CodaFi Dec 17, 2019

Choose a reason for hiding this comment

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

This is like the third or fourth time this block appears in the codebase. Can we centralize this? One of them is going to fall out of sync one day...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I only found two, but I'll extract it into a new method on ValueDecl.

Copy link
Contributor

@CodaFi CodaFi left a comment

Choose a reason for hiding this comment

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

I've only got nits. The approach looks fantastic.

@slavapestov
Copy link
Contributor Author

@swift-ci Please benchmark

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
StaticArray 1 3 +199.8% 0.33x
Phonebook 1092 2849 +160.9% 0.38x
SortAdjacentIntPyramids 645 1510 +134.1% 0.43x
NibbleSort 1880 4290 +128.2% 0.44x
SortIntPyramid 450 1005 +123.3% 0.45x
EqualSubstringSubstring 22 28 +27.3% 0.79x
LessSubstringSubstring 22 28 +27.3% 0.79x
EqualSubstringSubstringGenericEquatable 22 28 +27.3% 0.79x
EqualSubstringString 22 28 +27.3% 0.79x
LessSubstringSubstringGenericComparable 22 28 +27.3% 0.79x
EqualStringSubstring 23 29 +26.1% 0.79x
StringComparison_longSharedPrefix 313 349 +11.5% 0.90x (?)
NSStringConversion.LongUTF8 296 330 +11.5% 0.90x (?)
ArrayAppendLazyMap 3300 3650 +10.6% 0.90x (?)
LazilyFilteredArrayContains 21600 23800 +10.2% 0.91x
NSStringConversion.Long 501 545 +8.8% 0.92x (?)
Set.subtracting.Empty.Int 26 28 +7.7% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod 2300 1320 -42.6% 1.74x
ObserverUnappliedMethod 1490 920 -38.3% 1.62x
UTF8Decode_InitDecoding 164 138 -15.9% 1.19x
Set.subtracting.Empty.Box 8 7 -12.5% 1.14x (?)
FlattenListFlatMap 5131 4576 -10.8% 1.12x (?)
DictionaryCompactMapValuesOfCastValue 5508 4914 -10.8% 1.12x (?)
RemoveWhereSwapInts 38 34 -10.5% 1.12x (?)
RemoveWhereMoveInts 19 17 -10.5% 1.12x (?)
ArrayPlusEqualFiveElementCollection 4810 4329 -10.0% 1.11x (?)
ObjectiveCBridgeStringHash 79 72 -8.9% 1.10x (?)
PrefixWhileSequence 176 162 -8.0% 1.09x (?)
PrefixWhileAnySeqCntRange 176 162 -8.0% 1.09x (?)
PrefixWhileAnySeqCRangeIter 176 164 -6.8% 1.07x (?)
SetSubtractingInt0 45 42 -6.7% 1.07x (?)

Code size: -O

Regression OLD NEW DELTA RATIO
SortStrings.o 24724 28771 +16.4% 0.86x
SortIntPyramids.o 9005 9989 +10.9% 0.90x
StaticArray.o 11991 13005 +8.5% 0.92x
NibbleSort.o 13304 14288 +7.4% 0.93x
Phonebook.o 9963 10347 +3.9% 0.96x
Breadcrumbs.o 37679 39047 +3.6% 0.96x
DriverUtils.o 138580 141703 +2.3% 0.98x
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod.o 2791 2525 -9.5% 1.11x
ObserverUnappliedMethod.o 5305 5089 -4.1% 1.04x
DictionaryCompactMapValues.o 13929 13373 -4.0% 1.04x

Performance: -Osize

Regression OLD NEW DELTA RATIO
StaticArray 1 3 +199.8% 0.33x
Phonebook 1148 2912 +153.7% 0.39x
SortIntPyramid 430 985 +129.1% 0.44x
SortAdjacentIntPyramids 725 1570 +116.6% 0.46x
NibbleSort 2220 3590 +61.7% 0.62x
LessSubstringSubstring 22 28 +27.3% 0.79x
EqualSubstringString 22 28 +27.3% 0.79x
LessSubstringSubstringGenericComparable 22 28 +27.3% 0.79x
Dictionary4 156 196 +25.6% 0.80x
EqualSubstringSubstring 23 28 +21.7% 0.82x (?)
EqualStringSubstring 23 28 +21.7% 0.82x
EqualSubstringSubstringGenericEquatable 23 28 +21.7% 0.82x
DropLastCountableRange 5 6 +20.0% 0.83x (?)
Dictionary4OfObjects 226 268 +18.6% 0.84x
FlattenListLoop 2678 3173 +18.5% 0.84x (?)
StringComparison_longSharedPrefix 314 349 +11.1% 0.90x
Set.isDisjoint.Int.Empty 51 55 +7.8% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod 2360 1420 -39.8% 1.66x
ObserverUnappliedMethod 1510 920 -39.1% 1.64x
ArraySetElement 317 262 -17.4% 1.21x
UTF8Decode_InitDecoding 162 135 -16.7% 1.20x
DictionaryCompactMapValuesOfCastValue 5832 4914 -15.7% 1.19x (?)
ObjectiveCBridgeStringHash 79 72 -8.9% 1.10x (?)
ObjectiveCBridgeStringIsEqualAllSwift 48 44 -8.3% 1.09x (?)
ObjectiveCBridgeStringIsEqual 174 162 -6.9% 1.07x (?)
ObjectiveCBridgeStringIsEqual2 182 170 -6.6% 1.07x (?)

Code size: -Osize

Regression OLD NEW DELTA RATIO
SortIntPyramids.o 9062 10017 +10.5% 0.90x
StaticArray.o 11093 11941 +7.6% 0.93x
NibbleSort.o 13000 13960 +7.4% 0.93x
Phonebook.o 9478 9925 +4.7% 0.95x
Breadcrumbs.o 37136 38552 +3.8% 0.96x
SortStrings.o 27250 28123 +3.2% 0.97x
DriverUtils.o 125158 127961 +2.2% 0.98x
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod.o 3159 2905 -8.0% 1.09x
DictionaryCompactMapValues.o 13575 12811 -5.6% 1.06x
ObserverUnappliedMethod.o 5569 5353 -3.9% 1.04x
SetTests.o 120973 118877 -1.7% 1.02x

Performance: -Onone

Regression OLD NEW DELTA RATIO
EqualSubstringSubstringGenericEquatable 26 32 +23.1% 0.81x
LessSubstringSubstringGenericComparable 26 32 +23.1% 0.81x
LessSubstringSubstring 27 33 +22.2% 0.82x
EqualSubstringSubstring 28 33 +17.9% 0.85x
EqualStringSubstring 28 33 +17.9% 0.85x
EqualSubstringString 28 33 +17.9% 0.85x
Data.hash.Empty 96 105 +9.4% 0.91x (?)
UTF8Decode_InitDecoding_ascii 283 306 +8.1% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
IterateData 3312 2424 -26.8% 1.37x
ObserverUnappliedMethod 7130 5900 -17.3% 1.21x
ObserverPartiallyAppliedMethod 6260 5420 -13.4% 1.15x
UTF8Decode_InitDecoding 183 162 -11.5% 1.13x (?)
ObjectiveCBridgeStringHash 80 73 -8.7% 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: 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

@slavapestov
Copy link
Contributor Author

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
EqualSubstringSubstring 22 28 +27.3% 0.79x (?)
LessSubstringSubstring 22 28 +27.3% 0.79x
EqualSubstringSubstringGenericEquatable 22 28 +27.3% 0.79x
EqualSubstringString 22 28 +27.3% 0.79x (?)
LessSubstringSubstringGenericComparable 22 28 +27.3% 0.79x
EqualStringSubstring 23 29 +26.1% 0.79x
StringComparison_longSharedPrefix 313 349 +11.5% 0.90x (?)
NSStringConversion.Long 498 547 +9.8% 0.91x (?)
Set.subtracting.Empty.Int 26 28 +7.7% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod 2300 1300 -43.5% 1.77x
ObserverUnappliedMethod 1490 890 -40.3% 1.67x
SortIntPyramid 450 360 -20.0% 1.25x (?)
UTF8Decode_InitDecoding 164 137 -16.5% 1.20x (?)
StringInterpolationManySmallSegments 10800 9300 -13.9% 1.16x (?)
ArrayPlusEqualFiveElementCollection 4810 4292 -10.8% 1.12x (?)
RemoveWhereSwapInts 38 34 -10.5% 1.12x (?)
RemoveWhereMoveInts 19 17 -10.5% 1.12x (?)
ObjectiveCBridgeStringHash 79 73 -7.6% 1.08x (?)

Code size: -O

Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod.o 2791 2525 -9.5% 1.11x
ObserverUnappliedMethod.o 5305 5089 -4.1% 1.04x
DictionaryCompactMapValues.o 13929 13373 -4.0% 1.04x
DriverUtils.o 138580 137135 -1.0% 1.01x
Breadcrumbs.o 37679 37303 -1.0% 1.01x

Performance: -Osize

Regression OLD NEW DELTA RATIO
LessSubstringSubstring 22 28 +27.3% 0.79x
EqualSubstringString 22 28 +27.3% 0.79x (?)
LessSubstringSubstringGenericComparable 22 28 +27.3% 0.79x
Dictionary4 155 197 +27.1% 0.79x
EqualStringSubstring 23 29 +26.1% 0.79x (?)
EqualSubstringSubstringGenericEquatable 23 29 +26.1% 0.79x
EqualSubstringSubstring 23 28 +21.7% 0.82x
Dictionary4OfObjects 226 270 +19.5% 0.84x
SortIntPyramid 430 505 +17.4% 0.85x (?)
StringComparison_longSharedPrefix 314 349 +11.1% 0.90x
NSStringConversion.Long 509 556 +9.2% 0.92x (?)
NSStringConversion.LongUTF8 302 326 +7.9% 0.93x (?)
Set.isDisjoint.Int.Empty 51 55 +7.8% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod 2360 1420 -39.8% 1.66x
ObserverUnappliedMethod 1510 920 -39.1% 1.64x
FlattenListFlatMap 4673 2960 -36.7% 1.58x (?)
ArraySetElement 326 262 -19.6% 1.24x
StringInterpolationManySmallSegments 10700 8900 -16.8% 1.20x (?)
DictionaryCompactMapValuesOfCastValue 5832 4860 -16.7% 1.20x
FlattenListLoop 3191 2665 -16.5% 1.20x (?)
UTF8Decode_InitDecoding 166 139 -16.3% 1.19x
ArrayPlusEqualFiveElementCollection 4921 4292 -12.8% 1.15x (?)
SortAdjacentIntPyramids 725 635 -12.4% 1.14x
RandomShuffleLCG2 464 416 -10.3% 1.12x
ParseFloat.Float.Exp 10 9 -10.0% 1.11x (?)
ObjectiveCBridgeStringHash 79 72 -8.9% 1.10x
UTF8Decode_InitFromData_ascii 187 172 -8.0% 1.09x (?)
PrefixWhileAnySeqCRangeIter 200 186 -7.0% 1.08x (?)
Set.isStrictSuperset.Seq.Empty.Int 160 149 -6.9% 1.07x (?)
PrefixWhileSequence 190 177 -6.8% 1.07x (?)

Code size: -Osize

Improvement OLD NEW DELTA RATIO
SortStrings.o 27250 24306 -10.8% 1.12x
ObserverPartiallyAppliedMethod.o 3159 2905 -8.0% 1.09x
DictionaryCompactMapValues.o 13575 12811 -5.6% 1.06x
ObserverUnappliedMethod.o 5569 5409 -2.9% 1.03x
SetTests.o 120973 118877 -1.7% 1.02x
Breadcrumbs.o 37136 36632 -1.4% 1.01x

Performance: -Onone

Regression OLD NEW DELTA RATIO
EqualSubstringSubstringGenericEquatable 26 32 +23.1% 0.81x (?)
LessSubstringSubstringGenericComparable 26 32 +23.1% 0.81x (?)
LessSubstringSubstring 27 33 +22.2% 0.82x
EqualSubstringSubstring 28 33 +17.9% 0.85x (?)
EqualStringSubstring 28 33 +17.9% 0.85x (?)
EqualSubstringString 28 33 +17.9% 0.85x
 
Improvement OLD NEW DELTA RATIO
IterateData 3311 2439 -26.3% 1.36x
ObserverUnappliedMethod 7130 5790 -18.8% 1.23x
ObserverPartiallyAppliedMethod 6260 5280 -15.7% 1.19x
UTF8Decode_InitDecoding 184 160 -13.0% 1.15x
ObjectiveCBridgeStringIsEqualAllSwift 45 41 -8.9% 1.10x (?)
ObjectiveCBridgeStringHash 79 72 -8.9% 1.10x (?)
MapReduceShortString 165 153 -7.3% 1.08x (?)
ObjectiveCBridgeStringIsEqual2 178 166 -6.7% 1.07x

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: 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

@slavapestov
Copy link
Contributor Author

@swift-ci Please benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
Calculator 135 153 +13.3% 0.88x
ObjectiveCBridgeStubFromNSStringRef 84 94 +11.9% 0.89x (?)
ArrayAppendLazyMap 3300 3650 +10.6% 0.90x (?)
NormalizedIterator_fastPrenormal 580 640 +10.3% 0.91x (?)
NormalizedIterator_latin1 202 222 +9.9% 0.91x
LazilyFilteredArrayContains 21600 23700 +9.7% 0.91x
Chars2 3100 3400 +9.7% 0.91x
OpenClose 56 61 +8.9% 0.92x
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod 2300 1300 -43.5% 1.77x
ObserverUnappliedMethod 1490 900 -39.6% 1.66x
UTF8Decode_InitFromBytes 166 132 -20.5% 1.26x
UTF8Decode_InitFromData 152 121 -20.4% 1.26x
SortIntPyramid 450 365 -18.9% 1.23x
Set.subtracting.Empty.Box 8 7 -12.5% 1.14x
DictionaryCompactMapValuesOfCastValue 5562 4914 -11.7% 1.13x
RemoveWhereSwapInts 38 34 -10.5% 1.12x (?)
RemoveWhereMoveInts 19 17 -10.5% 1.12x (?)
ArrayPlusEqualFiveElementCollection 4810 4329 -10.0% 1.11x (?)
PrefixWhileAnySeqCntRange 177 162 -8.5% 1.09x (?)
PrefixWhileSequence 177 163 -7.9% 1.09x (?)
PrefixWhileAnySeqCRangeIter 177 163 -7.9% 1.09x (?)
ArrayInClass 915 845 -7.7% 1.08x (?)
SuffixSequenceLazy 253 234 -7.5% 1.08x (?)
ArraySetElement 283 262 -7.4% 1.08x (?)
RandomShuffleLCG2 448 416 -7.1% 1.08x (?)
SuffixSequence 252 234 -7.1% 1.08x (?)

Code size: -O

Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod.o 2791 2525 -9.5% 1.11x
ObserverUnappliedMethod.o 5305 5089 -4.1% 1.04x
DictionaryCompactMapValues.o 13929 13373 -4.0% 1.04x
DriverUtils.o 138580 137135 -1.0% 1.01x
Breadcrumbs.o 37679 37303 -1.0% 1.01x

Performance: -Osize

Regression OLD NEW DELTA RATIO
Dictionary4 156 206 +32.1% 0.76x
Dictionary4OfObjects 226 262 +15.9% 0.86x
Calculator 136 154 +13.2% 0.88x (?)
NopDeinit 8800 9900 +12.5% 0.89x
StringComparison_ascii 340 376 +10.6% 0.90x (?)
StringToDataEmpty 500 550 +10.0% 0.91x (?)
NormalizedIterator_fastPrenormal 620 670 +8.1% 0.93x
Set.isDisjoint.Int.Empty 51 55 +7.8% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod 2340 1400 -40.2% 1.67x
ObserverUnappliedMethod 1500 920 -38.7% 1.63x
UTF8Decode_InitFromData 156 125 -19.9% 1.25x
ArraySetElement 324 262 -19.1% 1.24x
UTF8Decode_InitFromBytes 162 133 -17.9% 1.22x
DictionaryCompactMapValuesOfCastValue 5832 4914 -15.7% 1.19x
RandomShuffleLCG2 464 416 -10.3% 1.12x (?)
PrefixWhileSequence 191 178 -6.8% 1.07x (?)

Code size: -Osize

Regression OLD NEW DELTA RATIO
Phonebook.o 9478 9718 +2.5% 0.98x
 
Improvement OLD NEW DELTA RATIO
ObserverPartiallyAppliedMethod.o 3159 2905 -8.0% 1.09x
DictionaryCompactMapValues.o 13575 12811 -5.6% 1.06x
ObserverUnappliedMethod.o 5569 5409 -2.9% 1.03x
SetTests.o 120973 118877 -1.7% 1.02x
Breadcrumbs.o 37136 36728 -1.1% 1.01x

Performance: -Onone

Regression OLD NEW DELTA RATIO
ArrayOfPOD 649 727 +12.0% 0.89x (?)
NormalizedIterator_fastPrenormal 900 980 +8.9% 0.92x (?)
ObjectiveCBridgeStubToNSDate2 350 380 +8.6% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
IterateData 3311 2502 -24.4% 1.32x
UTF8Decode_InitFromData 154 124 -19.5% 1.24x
UTF8Decode_InitFromBytes 164 134 -18.3% 1.22x
ObserverUnappliedMethod 6950 5780 -16.8% 1.20x
ObserverPartiallyAppliedMethod 6240 5260 -15.7% 1.19x (?)

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: 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

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

1 similar comment
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

When a method is called with fewer than two parameter lists,
transform it into a fully-applied call by wrapping it in a
closure.

Eg,

Foo.bar => { self in { args... self.bar(args...) } }
foo.bar => { self in { args... self.bar(args...) } }(self)

super.bar => { args... in super.bar(args...) }

With this change, SILGen only ever sees fully-applied calls,
which will allow ripping out some code.

This new way of doing curry thunks fixes a long-standing bug
where unbound references to protocol methods did not work.

This is because such a reference must open the existential
*inside* the closure, after 'self' has been applied, whereas
the old SILGen implementation of curry thunks really wanted
the type of the method reference to match the opened type of
the method.

A follow-up cleanup will remove the SILGen curry thunk
implementation.

Fixes rdar://21289579 and https://bugs.swift.org/browse/SR-75.
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test Linux

@slavapestov slavapestov merged commit 6412581 into swiftlang:master Mar 18, 2020

* [SR-75][]:

Unapplied references to protocol methods methods are now supported. Previously this
Copy link
Contributor

Choose a reason for hiding this comment

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

methods methods ➡️ methods

-Unapplied references to protocol methods methods are now supported. Previously this
+Unapplied references to protocol methods are now supported. Previously this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

func play(catToy: Toy)
}

let fn = Cat.play
Copy link
Contributor

Choose a reason for hiding this comment

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

Require parameter names when referencing to functions?

-let fn = Cat.play
+let fn = Cat.play(catToy:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not actually required, but I agree it makes the example more clear.

@davezarzycki
Copy link
Contributor

Hi @slavapestov – Congratulations on landing this and fixing a long standing issue. That's awesome! Do you know of (or foresee) any case where a DotSyntaxBaseIgnoredExpr would have an implicit autoclosure on the RHS that is NOT the thunk logic created by this pull request? Thanks in advance – Dave

@slavapestov
Copy link
Contributor Author

@davezarzycki That's a good question. It may very well be that the answer is "no". Do you have a further simplification in mind?

@davezarzycki
Copy link
Contributor

I don’t have a simplification in mind although it does seem like it could be simplified.

FWIW – This change broke a research branch I’m working on and I wanted to know how paranoid my misc diagnostic should be after this pull request. I think I know now. Thanks

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.

7 participants