Skip to content

[stdlib] use @_transparent in an appropriate spot #59327

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

glessard
Copy link
Contributor

@glessard glessard commented Jun 8, 2022

This function was inconsistently @inlinable, as opposed to its peers which are @_transparent. As a consequence, the detailed diagnostics surrounding Optional with == and != differ strangely based on minute details.

Resolves rdar://46444561

@glessard
Copy link
Contributor Author

glessard commented Jun 8, 2022

@swift-ci please test

@glessard
Copy link
Contributor Author

glessard commented Jun 8, 2022

@swift-ci please benchmark

@glessard
Copy link
Contributor Author

glessard commented Jun 8, 2022

Performance (x86_64): -O

Regression OLD NEW DELTA RATIO
LessSubstringSubstring 23 29 +26.1% 0.79x
EqualSubstringSubstringGenericEquatable 23 29 +26.1% 0.79x (?)
EqualSubstringString 23 29 +26.1% 0.79x
LessSubstringSubstringGenericComparable 23 29 +26.1% 0.79x (?)
EqualSubstringSubstring 24 30 +25.0% 0.80x (?)
EqualStringSubstring 24 30 +25.0% 0.80x
FlattenListFlatMap 3826 4417 +15.4% 0.87x (?)
DataCreateEmptyArray 1350 1550 +14.8% 0.87x (?)
StringComparison_longSharedPrefix 293 331 +13.0% 0.89x (?)
FindString.Loop1.Substring 272 301 +10.7% 0.90x (?)
SortStringsUnicode 1945 2105 +8.2% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
Dictionary4 217 153 -29.5% 1.42x
UTF8Decode_InitFromCustom_contiguous 159 125 -21.4% 1.27x (?)
UTF8Decode_InitDecoding 159 127 -20.1% 1.25x (?)
Dictionary4OfObjects 259 207 -20.1% 1.25x (?)
UTF8Decode_InitFromCustom_noncontiguous 276 239 -13.4% 1.15x (?)
NormalizedIterator_emoji 396 360 -9.1% 1.10x (?)
DistinctClassFieldAccesses 250 229 -8.4% 1.09x (?)
Set.isStrictSubset.Box0 84 77 -8.3% 1.09x (?)
ArrayInClass 1200 1110 -7.5% 1.08x (?)
UnicodeStringFromCodable 202 187 -7.4% 1.08x (?)
String.replaceSubrange.String.Small 41 38 -7.3% 1.08x (?)
RemoveWhereQuadraticString 213 198 -7.0% 1.08x (?)
DictionaryKeysContainsNative 15 14 -6.7% 1.07x (?)

Code size: -O

Performance (x86_64): -Osize

Regression OLD NEW DELTA RATIO
EqualSubstringSubstring 23 30 +30.4% 0.77x
LessSubstringSubstring 23 29 +26.1% 0.79x (?)
EqualStringSubstring 23 29 +26.1% 0.79x
EqualSubstringSubstringGenericEquatable 23 29 +26.1% 0.79x (?)
EqualSubstringString 23 29 +26.1% 0.79x (?)
LessSubstringSubstringGenericComparable 23 29 +26.1% 0.79x (?)
DataCreateEmptyArray 1400 1600 +14.3% 0.88x (?)
FlattenListFlatMap 3663 4181 +14.1% 0.88x (?)
FindString.Loop1.Substring 264 300 +13.6% 0.88x (?)
StringAdder 221 250 +13.1% 0.88x (?)
StringComparison_longSharedPrefix 294 332 +12.9% 0.89x (?)
StringWalk 1360 1520 +11.8% 0.89x (?)
StringHasSuffixAscii 1350 1480 +9.6% 0.91x (?)
StringInterpolationSmall 1080 1180 +9.3% 0.92x (?)
SortStringsUnicode 1970 2145 +8.9% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
UTF8Decode_InitDecoding 159 125 -21.4% 1.27x (?)
UTF8Decode_InitFromCustom_contiguous 160 127 -20.6% 1.26x (?)
RemoveWhereFilterInts 28 23 -17.9% 1.22x (?)
UTF8Decode_InitFromCustom_noncontiguous 278 243 -12.6% 1.14x (?)
Array2D 4640 4176 -10.0% 1.11x (?)
Set.isDisjoint.Empty.Box 90 82 -8.9% 1.10x (?)
ArrayInClass 1240 1130 -8.9% 1.10x (?)
Set.isSuperset.Seq.Int0 125 114 -8.8% 1.10x (?)
Set.isStrictSubset.Int0 82 75 -8.5% 1.09x (?)
Set.isStrictSubset.Box0 84 77 -8.3% 1.09x (?)
Set.isDisjoint.Seq.Empty.Box 90 83 -7.8% 1.08x (?)
String.replaceSubrange.String.Small 41 38 -7.3% 1.08x (?)

Code size: -Osize

Performance (x86_64): -Onone

Regression OLD NEW DELTA RATIO
EqualSubstringString 28 35 +25.0% 0.80x (?)
EqualSubstringSubstringGenericEquatable 26 32 +23.1% 0.81x (?)
LessSubstringSubstringGenericComparable 26 32 +23.1% 0.81x
LessSubstringSubstring 28 34 +21.4% 0.82x (?)
EqualSubstringSubstring 28 34 +21.4% 0.82x (?)
EqualStringSubstring 29 35 +20.7% 0.83x (?)
DictionaryCompactMapValuesOfNilValue 10050 10850 +8.0% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
SubstringTrimmingASCIIWhitespace 659 469 -28.8% 1.41x
UTF8Decode_InitDecoding 169 132 -21.9% 1.28x (?)
UTF8Decode_InitFromCustom_contiguous 169 133 -21.3% 1.27x
StringMatch 28900 23400 -19.0% 1.24x (?)
StackPromo 34800 29100 -16.4% 1.20x
FindString.Rec3.Substring 567 482 -15.0% 1.18x (?)
FindString.Rec3.String 580 498 -14.1% 1.16x (?)
String.replaceSubrange.String.Small 44 40 -9.1% 1.10x (?)
ObjectiveCBridgeStubDateAccess 2168 1975 -8.9% 1.10x (?)
ObjectiveCBridgeStubNSDateRefAccess 2207 2028 -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: 32 GB

Copy link
Member

@lorentey lorentey left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me! Another thing we can try is to switch to using @inlinable @inline(__always) in all of these overloads.

@karwa
Copy link
Contributor

karwa commented Jun 17, 2022

FYI #36309

I don't remember the details any more, but it's potentially worth looking at map and flatMap as well.

@glessard glessard marked this pull request as ready for review June 22, 2022 14:34
@eeckstein
Copy link
Contributor

This change lgtm!
The benchmark results are probably just noise.

@glessard glessard merged commit 69392a7 into swiftlang:main Jun 22, 2022
@glessard glessard deleted the rdar46444561-optional-equality-operator branch June 22, 2022 14:53
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