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

[stdlib] Rationalize bitshifting in protocols #11044

Merged
merged 2 commits into from
Jul 27, 2017
Merged

Conversation

dabrahams
Copy link
Contributor

This requires at least core team, if not evolution, discussion.

Only FixedWidthInteger, not BinaryInteger, should have masking shifts.
BinaryInteger should have a non-masking shift requirement.

Removed some dead code.

Dave Abrahams added 2 commits July 18, 2017 16:00
Only FixedWidthInteger, not BinaryInteger, should have masking shifts.
BinaryInteger should have a non-masking shift requirement.

Removed some dead code.
@dabrahams
Copy link
Contributor Author

@swift-ci Please test

@dabrahams
Copy link
Contributor Author

@swift-ci Please benchmark

@dabrahams
Copy link
Contributor Author

@swift-ci Please test source compatibility

@dabrahams
Copy link
Contributor Author

/cc @natecook1000

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - a86d9ae
Test requested by - @dabrahams

@dabrahams
Copy link
Contributor Author

@moiseev @rudkx Ow!

@dabrahams
Copy link
Contributor Author

Source compatibility just registers a UPASS on Chatto

@swift-ci
Copy link
Contributor

Build comment file:

Optimized (O)

Regression (4)
TEST OLD NEW DELTA SPEEDUP
PopFrontArray 1106 1203 +8.8% 0.92x (?)
ObjectiveCBridgeStubNSDateMutationRef 11797 12706 +7.7% 0.93x (?)
Calculator 31 33 +6.5% 0.94x
CaptureProp 4572 4851 +6.1% 0.94x
Improvement (3)
TEST OLD NEW DELTA SPEEDUP
MapReduceAnyCollection 331 302 -8.8% 1.10x
PrefixWhileSequence 312 294 -5.8% 1.06x
MapReduceString 99 94 -5.1% 1.05x
No Changes (314)
TEST OLD NEW DELTA SPEEDUP
AngryPhonebook 2951 2951 +0.0% 1.00x
AnyHashableWithAClass 66582 66975 +0.6% 0.99x (?)
Array2D 1976 1975 -0.1% 1.00x (?)
ArrayAppend 772 770 -0.3% 1.00x (?)
ArrayAppendArrayOfInt 597 596 -0.2% 1.00x (?)
ArrayAppendAscii 9923 9921 -0.0% 1.00x (?)
ArrayAppendFromGeneric 597 596 -0.2% 1.00x (?)
ArrayAppendGenericStructs 1223 1229 +0.5% 1.00x (?)
ArrayAppendLatin1 31592 31564 -0.1% 1.00x (?)
ArrayAppendLazyMap 929 929 +0.0% 1.00x
ArrayAppendOptionals 1215 1224 +0.7% 0.99x (?)
ArrayAppendRepeatCol 837 838 +0.1% 1.00x (?)
ArrayAppendReserved 533 533 +0.0% 1.00x
ArrayAppendSequence 944 944 +0.0% 1.00x
ArrayAppendStrings 13588 13601 +0.1% 1.00x (?)
ArrayAppendToFromGeneric 597 596 -0.2% 1.00x (?)
ArrayAppendToGeneric 597 596 -0.2% 1.00x (?)
ArrayAppendUTF16 29452 29434 -0.1% 1.00x (?)
ArrayInClass 61 61 +0.0% 1.00x
ArrayLiteral 1227 1225 -0.2% 1.00x (?)
ArrayOfGenericPOD 219 219 +0.0% 1.00x
ArrayOfGenericRef 4004 4011 +0.2% 1.00x (?)
ArrayOfPOD 166 166 +0.0% 1.00x
ArrayOfRef 3894 3889 -0.1% 1.00x (?)
ArrayPlusEqualArrayOfInt 597 596 -0.2% 1.00x
ArrayPlusEqualFiveElementCollection 4641 4677 +0.8% 0.99x (?)
ArrayPlusEqualSingleElementCollection 771 771 +0.0% 1.00x
ArrayPlusEqualThreeElements 1587 1601 +0.9% 0.99x
ArraySubscript 1460 1459 -0.1% 1.00x (?)
ArrayValueProp 6 6 +0.0% 1.00x
ArrayValueProp2 6 6 +0.0% 1.00x
ArrayValueProp3 6 6 +0.0% 1.00x
ArrayValueProp4 6 6 +0.0% 1.00x
BitCount 148 147 -0.7% 1.01x (?)
ByteSwap 118 118 +0.0% 1.00x
CStringLongAscii 4447 4674 +5.1% 0.95x (?)
CStringLongNonAscii 2098 2146 +2.3% 0.98x (?)
CStringShortAscii 4673 4724 +1.1% 0.99x (?)
CharIndexing_ascii_unicodeScalars 14212 14202 -0.1% 1.00x (?)
CharIndexing_ascii_unicodeScalars_Backwards 11644 11638 -0.1% 1.00x (?)
CharIndexing_chinese_unicodeScalars 10769 10759 -0.1% 1.00x
CharIndexing_chinese_unicodeScalars_Backwards 8831 8825 -0.1% 1.00x (?)
CharIndexing_japanese_unicodeScalars 17008 16999 -0.1% 1.00x (?)
CharIndexing_japanese_unicodeScalars_Backwards 13929 13924 -0.0% 1.00x (?)
CharIndexing_korean_unicodeScalars 13781 13772 -0.1% 1.00x (?)
CharIndexing_korean_unicodeScalars_Backwards 11293 11287 -0.1% 1.00x (?)
CharIndexing_punctuatedJapanese_unicodeScalars 2592 2582 -0.4% 1.00x
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 2152 2145 -0.3% 1.00x
CharIndexing_punctuated_unicodeScalars 3236 3228 -0.2% 1.00x
CharIndexing_punctuated_unicodeScalars_Backwards 2679 2673 -0.2% 1.00x
CharIndexing_russian_unicodeScalars 11844 11836 -0.1% 1.00x (?)
CharIndexing_russian_unicodeScalars_Backwards 9711 9705 -0.1% 1.00x
CharIndexing_tweet_unicodeScalars 28011 28008 -0.0% 1.00x (?)
CharIndexing_tweet_unicodeScalars_Backwards 22949 22950 +0.0% 1.00x (?)
CharIndexing_utf16_unicodeScalars 82690 82692 +0.0% 1.00x (?)
CharIndexing_utf16_unicodeScalars_Backwards 82524 82573 +0.1% 1.00x (?)
CharIteration_ascii_unicodeScalars 16221 15817 -2.5% 1.03x
CharIteration_ascii_unicodeScalars_Backwards 16576 16567 -0.1% 1.00x (?)
CharIteration_chinese_unicodeScalars 12284 11979 -2.5% 1.03x
CharIteration_chinese_unicodeScalars_Backwards 12550 12542 -0.1% 1.00x (?)
CharIteration_japanese_unicodeScalars 19414 18912 -2.6% 1.03x
CharIteration_japanese_unicodeScalars_Backwards 19847 19837 -0.1% 1.00x (?)
CharIteration_korean_unicodeScalars 15728 15340 -2.5% 1.03x
CharIteration_korean_unicodeScalars_Backwards 16072 16064 -0.0% 1.00x
CharIteration_punctuatedJapanese_unicodeScalars 2938 2866 -2.5% 1.03x
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 2992 2983 -0.3% 1.00x
CharIteration_punctuated_unicodeScalars 3679 3590 -2.4% 1.02x
CharIteration_punctuated_unicodeScalars_Backwards 3746 3737 -0.2% 1.00x
CharIteration_russian_unicodeScalars 13511 13179 -2.5% 1.03x
CharIteration_russian_unicodeScalars_Backwards 13809 13800 -0.1% 1.00x (?)
CharIteration_tweet_unicodeScalars 31971 31183 -2.5% 1.03x
CharIteration_tweet_unicodeScalars_Backwards 32753 32743 -0.0% 1.00x (?)
CharIteration_utf16_unicodeScalars 91728 91449 -0.3% 1.00x (?)
CharIteration_utf16_unicodeScalars_Backwards 119502 119662 +0.1% 1.00x (?)
CharacterLiteralsLarge 6023 6010 -0.2% 1.00x (?)
CharacterLiteralsSmall 403 403 +0.0% 1.00x
Chars 417 416 -0.2% 1.00x
ClassArrayGetter 13 13 +0.0% 1.00x
DeadArray 186 186 +0.0% 1.00x
Dictionary 556 555 -0.2% 1.00x (?)
Dictionary2 1838 1834 -0.2% 1.00x (?)
Dictionary2OfObjects 3280 3289 +0.3% 1.00x (?)
Dictionary3 440 440 +0.0% 1.00x
Dictionary3OfObjects 886 881 -0.6% 1.01x (?)
DictionaryBridge 2532 2528 -0.2% 1.00x (?)
DictionaryGroup 276 275 -0.4% 1.00x (?)
DictionaryGroupOfObjects 1790 1794 +0.2% 1.00x (?)
DictionaryLiteral 1478 1476 -0.1% 1.00x (?)
DictionaryOfObjects 2315 2319 +0.2% 1.00x (?)
DictionaryRemove 2425 2423 -0.1% 1.00x (?)
DictionaryRemoveOfObjects 23389 23433 +0.2% 1.00x (?)
DictionarySwap 429 433 +0.9% 0.99x
DictionarySwapOfObjects 6992 6963 -0.4% 1.00x (?)
DropFirstAnyCollection 56 56 +0.0% 1.00x
DropFirstAnyCollectionLazy 44813 44884 +0.2% 1.00x
DropFirstAnySeqCRangeIter 26292 26290 -0.0% 1.00x (?)
DropFirstAnySeqCRangeIterLazy 26282 26281 -0.0% 1.00x (?)
DropFirstAnySeqCntRange 50 50 +0.0% 1.00x
DropFirstAnySeqCntRangeLazy 50 50 +0.0% 1.00x
DropFirstAnySequence 5686 5779 +1.6% 0.98x
DropFirstAnySequenceLazy 5670 5755 +1.5% 0.99x
DropFirstArray 24 24 +0.0% 1.00x
DropFirstArrayLazy 24 24 +0.0% 1.00x
DropFirstCountableRange 32 32 +0.0% 1.00x
DropFirstCountableRangeLazy 32 32 +0.0% 1.00x
DropFirstSequence 2093 2093 +0.0% 1.00x
DropFirstSequenceLazy 2118 2118 +0.0% 1.00x
DropLastAnyCollection 22 22 +0.0% 1.00x
DropLastAnyCollectionLazy 14932 14980 +0.3% 1.00x (?)
DropLastAnySeqCRangeIter 4567 4566 -0.0% 1.00x (?)
DropLastAnySeqCRangeIterLazy 4564 4567 +0.1% 1.00x (?)
DropLastAnySeqCntRange 16 16 +0.0% 1.00x
DropLastAnySeqCntRangeLazy 16 16 +0.0% 1.00x
DropLastAnySequence 6749 6627 -1.8% 1.02x
DropLastAnySequenceLazy 6493 6506 +0.2% 1.00x (?)
DropLastArray 8 8 +0.0% 1.00x
DropLastArrayLazy 8 8 +0.0% 1.00x
DropLastCountableRange 10 10 +0.0% 1.00x
DropLastCountableRangeLazy 10 10 +0.0% 1.00x
DropLastSequence 596 570 -4.4% 1.05x
DropLastSequenceLazy 597 570 -4.5% 1.05x
DropWhileAnyCollection 70 69 -1.4% 1.01x
DropWhileAnyCollectionLazy 103 103 +0.0% 1.00x
DropWhileAnySeqCRangeIter 20996 21287 +1.4% 0.99x
DropWhileAnySeqCRangeIterLazy 103 103 +0.0% 1.00x
DropWhileAnySeqCntRange 64 64 +0.0% 1.00x
DropWhileAnySeqCntRangeLazy 103 103 +0.0% 1.00x
DropWhileAnySequence 6557 6555 -0.0% 1.00x (?)
DropWhileAnySequenceLazy 2032 2032 +0.0% 1.00x
DropWhileArray 37 37 +0.0% 1.00x
DropWhileArrayLazy 78 78 +0.0% 1.00x
DropWhileCountableRange 36 36 +0.0% 1.00x
DropWhileCountableRangeLazy 68 68 +0.0% 1.00x
DropWhileSequence 1548 1547 -0.1% 1.00x (?)
DropWhileSequenceLazy 65 65 +0.0% 1.00x
EqualStringSubstring 387 388 +0.3% 1.00x
EqualSubstringString 385 386 +0.3% 1.00x
EqualSubstringSubstring 384 387 +0.8% 0.99x (?)
EqualSubstringSubstringGenericEquatable 389 388 -0.3% 1.00x (?)
ErrorHandling 2913 2866 -1.6% 1.02x (?)
Hanoi 3342 3244 -2.9% 1.03x
HashTest 1682 1677 -0.3% 1.00x (?)
Histogram 299 304 +1.7% 0.98x (?)
Integrate 266 266 +0.0% 1.00x
IterateData 759 761 +0.3% 1.00x (?)
Join 385 372 -3.4% 1.03x (?)
LazilyFilteredArrays 63659 63750 +0.1% 1.00x (?)
LazilyFilteredRange 3884 3885 +0.0% 1.00x (?)
LessSubstringSubstring 385 386 +0.3% 1.00x (?)
LessSubstringSubstringGenericComparable 384 385 +0.3% 1.00x (?)
LinkedList 7160 7178 +0.3% 1.00x (?)
MapReduce 327 327 +0.0% 1.00x
MapReduceAnyCollectionShort 2078 1992 -4.1% 1.04x
MapReduceClass 3068 3071 +0.1% 1.00x (?)
MapReduceClassShort 4569 4607 +0.8% 0.99x
MapReduceLazyCollection 15 15 +0.0% 1.00x
MapReduceLazyCollectionShort 45 45 +0.0% 1.00x
MapReduceLazySequence 90 90 +0.0% 1.00x
MapReduceSequence 451 449 -0.4% 1.00x (?)
MapReduceShort 1917 1921 +0.2% 1.00x (?)
MapReduceShortString 21 21 +0.0% 1.00x
Memset 234 234 +0.0% 1.00x
MonteCarloE 10277 10276 -0.0% 1.00x (?)
MonteCarloPi 43789 43787 -0.0% 1.00x (?)
NSDictionaryCastToSwift 5334 5295 -0.7% 1.01x (?)
NSError 290 289 -0.3% 1.00x (?)
NSStringConversion 354 358 +1.1% 0.99x (?)
NopDeinit 22889 22890 +0.0% 1.00x (?)
ObjectAllocation 179 178 -0.6% 1.01x (?)
ObjectiveCBridgeFromNSArrayAnyObject 21901 21998 +0.4% 1.00x (?)
ObjectiveCBridgeFromNSArrayAnyObjectForced 3482 3473 -0.3% 1.00x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToString 38589 38616 +0.1% 1.00x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 32845 32595 -0.8% 1.01x (?)
ObjectiveCBridgeFromNSDictionaryAnyObject 117979 118264 +0.2% 1.00x (?)
ObjectiveCBridgeFromNSDictionaryAnyObjectForced 5075 5082 +0.1% 1.00x (?)
ObjectiveCBridgeFromNSDictionaryAnyObjectToString 89644 90377 +0.8% 0.99x (?)
ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced 97678 100862 +3.3% 0.97x (?)
ObjectiveCBridgeFromNSSetAnyObject 63979 64179 +0.3% 1.00x (?)
ObjectiveCBridgeFromNSSetAnyObjectForced 4185 4161 -0.6% 1.01x (?)
ObjectiveCBridgeFromNSSetAnyObjectToString 67115 67142 +0.0% 1.00x (?)
ObjectiveCBridgeFromNSSetAnyObjectToStringForced 67620 67065 -0.8% 1.01x (?)
ObjectiveCBridgeFromNSString 992 998 +0.6% 0.99x (?)
ObjectiveCBridgeFromNSStringForced 1810 1821 +0.6% 0.99x (?)
ObjectiveCBridgeStubDataAppend 3741 3748 +0.2% 1.00x (?)
ObjectiveCBridgeStubDateAccess 181 181 +0.0% 1.00x
ObjectiveCBridgeStubDateMutation 272 272 +0.0% 1.00x
ObjectiveCBridgeStubFromArrayOfNSString 24505 24398 -0.4% 1.00x (?)
ObjectiveCBridgeStubFromNSDate 3602 3599 -0.1% 1.00x (?)
ObjectiveCBridgeStubFromNSDateRef 4005 4009 +0.1% 1.00x (?)
ObjectiveCBridgeStubFromNSString 536 525 -2.1% 1.02x
ObjectiveCBridgeStubFromNSStringRef 142 142 +0.0% 1.00x
ObjectiveCBridgeStubNSDataAppend 2347 2276 -3.0% 1.03x (?)
ObjectiveCBridgeStubNSDateRefAccess 312 311 -0.3% 1.00x (?)
ObjectiveCBridgeStubToArrayOfNSString 28933 28748 -0.6% 1.01x (?)
ObjectiveCBridgeStubToNSDate 14630 14487 -1.0% 1.01x (?)
ObjectiveCBridgeStubToNSDateRef 3216 3256 +1.2% 0.99x (?)
ObjectiveCBridgeStubToNSString 1514 1510 -0.3% 1.00x (?)
ObjectiveCBridgeStubToNSStringRef 109 109 +0.0% 1.00x
ObjectiveCBridgeStubURLAppendPath 220531 221841 +0.6% 0.99x (?)
ObjectiveCBridgeStubURLAppendPathRef 220311 220217 -0.0% 1.00x (?)
ObjectiveCBridgeToNSArray 28973 28965 -0.0% 1.00x (?)
ObjectiveCBridgeToNSDictionary 44317 44368 +0.1% 1.00x (?)
ObjectiveCBridgeToNSSet 38722 38914 +0.5% 1.00x (?)
ObjectiveCBridgeToNSString 1270 1272 +0.2% 1.00x (?)
ObserverClosure 2252 2256 +0.2% 1.00x (?)
ObserverForwarderStruct 1091 1090 -0.1% 1.00x (?)
ObserverPartiallyAppliedMethod 3727 3724 -0.1% 1.00x (?)
ObserverUnappliedMethod 2609 2609 +0.0% 1.00x
OpenClose 51 51 +0.0% 1.00x
Phonebook 5823 5782 -0.7% 1.01x (?)
PolymorphicCalls 22 22 +0.0% 1.00x
PopFrontArrayGeneric 1211 1203 -0.7% 1.01x
PopFrontUnsafePointer 9536 9537 +0.0% 1.00x (?)
PrefixAnyCollection 56 56 +0.0% 1.00x
PrefixAnyCollectionLazy 45005 44870 -0.3% 1.00x (?)
PrefixAnySeqCRangeIter 20573 20616 +0.2% 1.00x (?)
PrefixAnySeqCRangeIterLazy 20741 20615 -0.6% 1.01x (?)
PrefixAnySeqCntRange 50 50 +0.0% 1.00x
PrefixAnySeqCntRangeLazy 50 50 +0.0% 1.00x
PrefixAnySequence 5029 4990 -0.8% 1.01x
PrefixAnySequenceLazy 5007 5011 +0.1% 1.00x (?)
PrefixArray 24 24 +0.0% 1.00x
PrefixArrayLazy 25 25 +0.0% 1.00x
PrefixCountableRange 32 32 +0.0% 1.00x
PrefixCountableRangeLazy 32 32 +0.0% 1.00x
PrefixSequence 1571 1571 +0.0% 1.00x
PrefixSequenceLazy 1515 1515 +0.0% 1.00x
PrefixWhileAnyCollection 96 96 +0.0% 1.00x
PrefixWhileAnyCollectionLazy 75 75 +0.0% 1.00x
PrefixWhileAnySeqCRangeIter 12398 12492 +0.8% 0.99x
PrefixWhileAnySeqCRangeIterLazy 75 75 +0.0% 1.00x
PrefixWhileAnySeqCntRange 90 90 +0.0% 1.00x
PrefixWhileAnySeqCntRangeLazy 75 75 +0.0% 1.00x
PrefixWhileAnySequence 13906 13912 +0.0% 1.00x (?)
PrefixWhileAnySequenceLazy 1491 1492 +0.1% 1.00x
PrefixWhileArray 62 62 +0.0% 1.00x
PrefixWhileArrayLazy 49 49 +0.0% 1.00x
PrefixWhileCountableRange 36 36 +0.0% 1.00x
PrefixWhileCountableRangeLazy 32 32 +0.0% 1.00x
PrefixWhileSequenceLazy 28 28 +0.0% 1.00x
Prims 789 775 -1.8% 1.02x (?)
ProtocolDispatch 2424 2424 +0.0% 1.00x
ProtocolDispatch2 160 160 +0.0% 1.00x
RC4 160 160 +0.0% 1.00x
RGBHistogram 2361 2366 +0.2% 1.00x (?)
RGBHistogramOfObjects 24330 24382 +0.2% 1.00x (?)
RangeAssignment 308 308 +0.0% 1.00x
RecursiveOwnedParameter 2331 2329 -0.1% 1.00x (?)
ReversedArray 49 49 +0.0% 1.00x
ReversedBidirectional 29017 28961 -0.2% 1.00x (?)
ReversedDictionary 110 110 +0.0% 1.00x
SetExclusiveOr 3156 3187 +1.0% 0.99x (?)
SetExclusiveOr_OfObjects 9526 9474 -0.5% 1.01x (?)
SetIntersect 299 300 +0.3% 1.00x (?)
SetIntersect_OfObjects 1723 1717 -0.3% 1.00x (?)
SetIsSubsetOf 292 292 +0.0% 1.00x
SetIsSubsetOf_OfObjects 359 359 +0.0% 1.00x
SetUnion 2719 2726 +0.3% 1.00x (?)
SetUnion_OfObjects 8142 8026 -1.4% 1.01x (?)
SevenBoom 1465 1466 +0.1% 1.00x (?)
Sim2DArray 276 276 +0.0% 1.00x
SortLargeExistentials 7908 7891 -0.2% 1.00x (?)
SortLettersInPlace 1146 1146 +0.0% 1.00x
SortSortedStrings 839 847 +1.0% 0.99x (?)
SortStrings 1641 1652 +0.7% 0.99x (?)
SortStringsUnicode 7889 7548 -4.3% 1.05x
StackPromo 22277 22424 +0.7% 0.99x (?)
StaticArray 18 18 +0.0% 1.00x
StrComplexWalk 720 720 +0.0% 1.00x
StrToInt 1980 1940 -2.0% 1.02x
StringAdder 3517 3506 -0.3% 1.00x (?)
StringBuilder 1025 1018 -0.7% 1.01x (?)
StringBuilderLong 930 931 +0.1% 1.00x (?)
StringEdits 114837 114903 +0.1% 1.00x (?)
StringEqualPointerComparison 333 333 +0.0% 1.00x
StringFromLongWholeSubstring 13377 13372 -0.0% 1.00x (?)
StringFromLongWholeSubstringGeneric 22 22 +0.0% 1.00x
StringHasPrefix 16 16 +0.0% 1.00x
StringHasPrefixUnicode 14774 14687 -0.6% 1.01x
StringHasSuffix 16 16 +0.0% 1.00x
StringHasSuffixUnicode 61807 61909 +0.2% 1.00x (?)
StringInterpolation 10834 10898 +0.6% 0.99x (?)
StringMatch 7720 7415 -4.0% 1.04x
StringUTF16Builder 1876 1868 -0.4% 1.00x (?)
StringWalk 1287 1292 +0.4% 1.00x
StringWithCString 57827 59514 +2.9% 0.97x (?)
SubstringComparable 1539 1534 -0.3% 1.00x (?)
SubstringEqualString 1425 1418 -0.5% 1.00x (?)
SubstringEquatable 3756 3740 -0.4% 1.00x
SubstringFromLongString 10 10 +0.0% 1.00x
SubstringFromLongStringGeneric 60 60 +0.0% 1.00x
SuffixAnyCollection 22 22 +0.0% 1.00x
SuffixAnyCollectionLazy 14873 14924 +0.3% 1.00x (?)
SuffixAnySeqCRangeIter 4891 4891 +0.0% 1.00x
SuffixAnySeqCRangeIterLazy 4891 4891 +0.0% 1.00x
SuffixAnySeqCntRange 16 16 +0.0% 1.00x
SuffixAnySeqCntRangeLazy 16 16 +0.0% 1.00x
SuffixAnySequence 6637 6652 +0.2% 1.00x (?)
SuffixAnySequenceLazy 6507 6537 +0.5% 1.00x (?)
SuffixArray 8 8 +0.0% 1.00x
SuffixArrayLazy 8 8 +0.0% 1.00x
SuffixCountableRange 10 10 +0.0% 1.00x
SuffixCountableRangeLazy 10 10 +0.0% 1.00x
SuffixSequence 4409 4385 -0.5% 1.01x
SuffixSequenceLazy 4408 4385 -0.5% 1.01x
SuperChars 80851 80683 -0.2% 1.00x (?)
TwoSum 963 970 +0.7% 0.99x (?)
TypeFlood 0 0 +0.0% 1.00x
UTF8Decode 253 253 +0.0% 1.00x
Walsh 356 354 -0.6% 1.01x (?)
XorLoop 347 347 +0.0% 1.00x
accessGlobal 3 3 +0.0% 1.00x
accessInMatSet 18 18 +0.0% 1.00x
accessIndependent 2 2 +0.0% 1.00x

Unoptimized (Onone)

Regression (5)
TEST OLD NEW DELTA SPEEDUP
NopDeinit 171683 185164 +7.9% 0.93x
TypeFlood 156 167 +7.1% 0.93x (?)
ObjectiveCBridgeFromNSArrayAnyObject 23501 24951 +6.2% 0.94x
StringHasPrefix 1636 1736 +6.1% 0.94x
MapReduceLazySequence 25233 26671 +5.7% 0.95x
Improvement (2)
TEST OLD NEW DELTA SPEEDUP
ObjectiveCBridgeFromNSSetAnyObjectToStringForced 76554 70930 -7.3% 1.08x (?)
AngryPhonebook 5221 4922 -5.7% 1.06x (?)
No Changes (314)
TEST OLD NEW DELTA SPEEDUP
AnyHashableWithAClass 84376 84519 +0.2% 1.00x
Array2D 603261 603344 +0.0% 1.00x (?)
ArrayAppend 3669 3596 -2.0% 1.02x
ArrayAppendArrayOfInt 653 653 +0.0% 1.00x
ArrayAppendAscii 51751 50766 -1.9% 1.02x
ArrayAppendFromGeneric 657 655 -0.3% 1.00x
ArrayAppendGenericStructs 1293 1293 +0.0% 1.00x
ArrayAppendLatin1 73532 72618 -1.2% 1.01x
ArrayAppendLazyMap 220951 213451 -3.4% 1.04x
ArrayAppendOptionals 1285 1290 +0.4% 1.00x (?)
ArrayAppendRepeatCol 210678 216552 +2.8% 0.97x (?)
ArrayAppendReserved 3538 3430 -3.1% 1.03x
ArrayAppendSequence 73164 72508 -0.9% 1.01x
ArrayAppendStrings 13652 13729 +0.6% 0.99x (?)
ArrayAppendToFromGeneric 655 655 +0.0% 1.00x
ArrayAppendToGeneric 655 657 +0.3% 1.00x (?)
ArrayAppendUTF16 74681 73581 -1.5% 1.01x
ArrayInClass 6640 6646 +0.1% 1.00x
ArrayLiteral 1737 1744 +0.4% 1.00x (?)
ArrayOfGenericPOD 2986 3078 +3.1% 0.97x
ArrayOfGenericRef 10080 10028 -0.5% 1.01x (?)
ArrayOfPOD 1892 1892 +0.0% 1.00x
ArrayOfRef 9098 9020 -0.9% 1.01x
ArrayPlusEqualArrayOfInt 654 654 +0.0% 1.00x
ArrayPlusEqualFiveElementCollection 299969 296141 -1.3% 1.01x (?)
ArrayPlusEqualSingleElementCollection 295004 292419 -0.9% 1.01x (?)
ArrayPlusEqualThreeElements 10915 10813 -0.9% 1.01x (?)
ArraySubscript 4182 4203 +0.5% 1.00x (?)
ArrayValueProp 3562 3592 +0.8% 0.99x (?)
ArrayValueProp2 18267 18314 +0.3% 1.00x (?)
ArrayValueProp3 3967 3960 -0.2% 1.00x (?)
ArrayValueProp4 3878 3862 -0.4% 1.00x (?)
BitCount 1719 1724 +0.3% 1.00x (?)
ByteSwap 4156 4147 -0.2% 1.00x (?)
CStringLongAscii 4419 4532 +2.6% 0.98x
CStringLongNonAscii 2262 2301 +1.7% 0.98x
CStringShortAscii 8575 8605 +0.3% 1.00x (?)
Calculator 1162 1163 +0.1% 1.00x (?)
CaptureProp 109162 110750 +1.5% 0.99x
CharIndexing_ascii_unicodeScalars 475880 472192 -0.8% 1.01x (?)
CharIndexing_ascii_unicodeScalars_Backwards 548205 532505 -2.9% 1.03x (?)
CharIndexing_chinese_unicodeScalars 357194 355536 -0.5% 1.00x (?)
CharIndexing_chinese_unicodeScalars_Backwards 409165 400487 -2.1% 1.02x (?)
CharIndexing_japanese_unicodeScalars 586712 564338 -3.8% 1.04x
CharIndexing_japanese_unicodeScalars_Backwards 651252 661408 +1.6% 0.98x (?)
CharIndexing_korean_unicodeScalars 458149 458211 +0.0% 1.00x (?)
CharIndexing_korean_unicodeScalars_Backwards 522291 525762 +0.7% 0.99x (?)
CharIndexing_punctuatedJapanese_unicodeScalars 81981 81180 -1.0% 1.01x (?)
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 93182 92187 -1.1% 1.01x (?)
CharIndexing_punctuated_unicodeScalars 103312 103213 -0.1% 1.00x (?)
CharIndexing_punctuated_unicodeScalars_Backwards 117707 118274 +0.5% 1.00x (?)
CharIndexing_russian_unicodeScalars 392912 391656 -0.3% 1.00x (?)
CharIndexing_russian_unicodeScalars_Backwards 446108 447362 +0.3% 1.00x (?)
CharIndexing_tweet_unicodeScalars 936892 948635 +1.3% 0.99x (?)
CharIndexing_tweet_unicodeScalars_Backwards 1065737 1064951 -0.1% 1.00x (?)
CharIndexing_utf16_unicodeScalars 534797 534638 -0.0% 1.00x (?)
CharIndexing_utf16_unicodeScalars_Backwards 603122 598084 -0.8% 1.01x (?)
CharIteration_ascii_unicodeScalars 180622 180004 -0.3% 1.00x
CharIteration_ascii_unicodeScalars_Backwards 328513 321006 -2.3% 1.02x
CharIteration_chinese_unicodeScalars 136331 136237 -0.1% 1.00x (?)
CharIteration_chinese_unicodeScalars_Backwards 242001 241811 -0.1% 1.00x (?)
CharIteration_japanese_unicodeScalars 215700 215944 +0.1% 1.00x (?)
CharIteration_japanese_unicodeScalars_Backwards 384108 383530 -0.2% 1.00x (?)
CharIteration_korean_unicodeScalars 174967 174428 -0.3% 1.00x (?)
CharIteration_korean_unicodeScalars_Backwards 312448 310220 -0.7% 1.01x (?)
CharIteration_punctuatedJapanese_unicodeScalars 32006 31967 -0.1% 1.00x
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 56005 55996 -0.0% 1.00x (?)
CharIteration_punctuated_unicodeScalars 40209 40115 -0.2% 1.00x (?)
CharIteration_punctuated_unicodeScalars_Backwards 71266 71419 +0.2% 1.00x (?)
CharIteration_russian_unicodeScalars 149847 150033 +0.1% 1.00x (?)
CharIteration_russian_unicodeScalars_Backwards 268260 270393 +0.8% 0.99x (?)
CharIteration_tweet_unicodeScalars 355465 357005 +0.4% 1.00x
CharIteration_tweet_unicodeScalars_Backwards 637241 637400 +0.0% 1.00x (?)
CharIteration_utf16_unicodeScalars 212759 213125 +0.2% 1.00x (?)
CharIteration_utf16_unicodeScalars_Backwards 416789 416324 -0.1% 1.00x (?)
CharacterLiteralsLarge 6201 6207 +0.1% 1.00x (?)
CharacterLiteralsSmall 653 658 +0.8% 0.99x (?)
Chars 48406 48392 -0.0% 1.00x (?)
ClassArrayGetter 987 986 -0.1% 1.00x
DeadArray 114646 113126 -1.3% 1.01x (?)
Dictionary 3035 3070 +1.2% 0.99x (?)
Dictionary2 3509 3505 -0.1% 1.00x (?)
Dictionary2OfObjects 6128 6092 -0.6% 1.01x (?)
Dictionary3 1321 1315 -0.5% 1.00x (?)
Dictionary3OfObjects 2340 2326 -0.6% 1.01x (?)
DictionaryBridge 2637 2626 -0.4% 1.00x (?)
DictionaryGroup 4998 4969 -0.6% 1.01x
DictionaryGroupOfObjects 8115 8128 +0.2% 1.00x (?)
DictionaryLiteral 8364 8347 -0.2% 1.00x (?)
DictionaryOfObjects 6621 6653 +0.5% 1.00x (?)
DictionaryRemove 21361 21534 +0.8% 0.99x
DictionaryRemoveOfObjects 59699 59454 -0.4% 1.00x (?)
DictionarySwap 5253 5318 +1.2% 0.99x (?)
DictionarySwapOfObjects 23182 23060 -0.5% 1.01x (?)
DropFirstAnyCollection 18766 18979 +1.1% 0.99x
DropFirstAnyCollectionLazy 137678 137206 -0.3% 1.00x (?)
DropFirstAnySeqCRangeIter 28289 28464 +0.6% 0.99x (?)
DropFirstAnySeqCRangeIterLazy 28099 28784 +2.4% 0.98x
DropFirstAnySeqCntRange 18966 18904 -0.3% 1.00x (?)
DropFirstAnySeqCntRangeLazy 18729 19180 +2.4% 0.98x
DropFirstAnySequence 12779 12889 +0.9% 0.99x (?)
DropFirstAnySequenceLazy 12679 12917 +1.9% 0.98x
DropFirstArray 6153 6311 +2.6% 0.97x
DropFirstArrayLazy 44634 44448 -0.4% 1.00x (?)
DropFirstCountableRange 339 340 +0.3% 1.00x
DropFirstCountableRangeLazy 37470 37887 +1.1% 0.99x (?)
DropFirstSequence 11682 11775 +0.8% 0.99x (?)
DropFirstSequenceLazy 11543 11823 +2.4% 0.98x
DropLastAnyCollection 6259 6320 +1.0% 0.99x (?)
DropLastAnyCollectionLazy 45785 45864 +0.2% 1.00x (?)
DropLastAnySeqCRangeIter 43183 43269 +0.2% 1.00x (?)
DropLastAnySeqCRangeIterLazy 43734 43062 -1.5% 1.02x
DropLastAnySeqCntRange 6254 6354 +1.6% 0.98x
DropLastAnySeqCntRangeLazy 6329 6382 +0.8% 0.99x (?)
DropLastAnySequence 28913 29288 +1.3% 0.99x
DropLastAnySequenceLazy 29053 28989 -0.2% 1.00x
DropLastArray 2082 2107 +1.2% 0.99x
DropLastArrayLazy 14903 14827 -0.5% 1.01x
DropLastCountableRange 118 118 +0.0% 1.00x
DropLastCountableRangeLazy 12481 12520 +0.3% 1.00x (?)
DropLastSequence 28733 28518 -0.7% 1.01x (?)
DropLastSequenceLazy 28925 29188 +0.9% 0.99x
DropWhileAnyCollection 24524 24571 +0.2% 1.00x (?)
DropWhileAnyCollectionLazy 27244 27121 -0.5% 1.00x (?)
DropWhileAnySeqCRangeIter 30561 30679 +0.4% 1.00x (?)
DropWhileAnySeqCRangeIterLazy 26741 27150 +1.5% 0.98x (?)
DropWhileAnySeqCntRange 24794 24672 -0.5% 1.00x
DropWhileAnySeqCntRangeLazy 26930 27185 +0.9% 0.99x
DropWhileAnySequence 15106 15168 +0.4% 1.00x (?)
DropWhileAnySequenceLazy 12187 12677 +4.0% 0.96x
DropWhileArray 9761 9844 +0.9% 0.99x
DropWhileArrayLazy 16776 16770 -0.0% 1.00x (?)
DropWhileCountableRange 6006 5971 -0.6% 1.01x
DropWhileCountableRangeLazy 25701 26450 +2.9% 0.97x
DropWhileSequence 14155 14499 +2.4% 0.98x
DropWhileSequenceLazy 10947 11394 +4.1% 0.96x
EqualStringSubstring 660 666 +0.9% 0.99x
EqualSubstringString 660 663 +0.5% 1.00x (?)
EqualSubstringSubstring 776 774 -0.3% 1.00x
EqualSubstringSubstringGenericEquatable 415 416 +0.2% 1.00x
ErrorHandling 6801 6751 -0.7% 1.01x (?)
Hanoi 18249 18159 -0.5% 1.00x
HashTest 18114 18230 +0.6% 0.99x (?)
Histogram 8981 9081 +1.1% 0.99x (?)
Integrate 697 729 +4.6% 0.96x
IterateData 12821 12818 -0.0% 1.00x (?)
Join 1200 1195 -0.4% 1.00x
LazilyFilteredArrays 1684759 1678083 -0.4% 1.00x
LazilyFilteredRange 676556 665567 -1.6% 1.02x
LessSubstringSubstring 781 776 -0.6% 1.01x (?)
LessSubstringSubstringGenericComparable 436 437 +0.2% 1.00x
LinkedList 40461 40483 +0.1% 1.00x
MapReduce 37791 37491 -0.8% 1.01x (?)
MapReduceAnyCollection 37297 37425 +0.3% 1.00x (?)
MapReduceAnyCollectionShort 49945 49888 -0.1% 1.00x (?)
MapReduceClass 42691 42661 -0.1% 1.00x (?)
MapReduceClassShort 53704 53698 -0.0% 1.00x (?)
MapReduceLazyCollection 32624 34169 +4.7% 0.95x (?)
MapReduceLazyCollectionShort 43552 43654 +0.2% 1.00x (?)
MapReduceSequence 40526 40696 +0.4% 1.00x (?)
MapReduceShort 49986 49940 -0.1% 1.00x (?)
MapReduceShortString 275 276 +0.4% 1.00x (?)
MapReduceString 2608 2617 +0.3% 1.00x (?)
Memset 43720 43717 -0.0% 1.00x (?)
MonteCarloE 135458 134836 -0.5% 1.00x
MonteCarloPi 52509 52513 +0.0% 1.00x (?)
NSDictionaryCastToSwift 6538 6568 +0.5% 1.00x (?)
NSError 706 704 -0.3% 1.00x (?)
NSStringConversion 398 397 -0.3% 1.00x
ObjectAllocation 1486 1471 -1.0% 1.01x (?)
ObjectiveCBridgeFromNSArrayAnyObjectForced 6742 6661 -1.2% 1.01x
ObjectiveCBridgeFromNSArrayAnyObjectToString 39939 39603 -0.8% 1.01x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 33519 33332 -0.6% 1.01x (?)
ObjectiveCBridgeFromNSDictionaryAnyObject 124251 121402 -2.3% 1.02x (?)
ObjectiveCBridgeFromNSDictionaryAnyObjectForced 7474 7671 +2.6% 0.97x (?)
ObjectiveCBridgeFromNSDictionaryAnyObjectToString 93846 92896 -1.0% 1.01x (?)
ObjectiveCBridgeFromNSDictionaryAnyObjectToStringForced 100880 104883 +4.0% 0.96x (?)
ObjectiveCBridgeFromNSSetAnyObject 68735 68882 +0.2% 1.00x
ObjectiveCBridgeFromNSSetAnyObjectForced 7446 7381 -0.9% 1.01x (?)
ObjectiveCBridgeFromNSSetAnyObjectToString 72775 73251 +0.7% 0.99x (?)
ObjectiveCBridgeFromNSString 3856 3903 +1.2% 0.99x (?)
ObjectiveCBridgeFromNSStringForced 2185 2213 +1.3% 0.99x (?)
ObjectiveCBridgeStubDataAppend 3996 3907 -2.2% 1.02x (?)
ObjectiveCBridgeStubDateAccess 1031 1033 +0.2% 1.00x (?)
ObjectiveCBridgeStubDateMutation 485 485 +0.0% 1.00x
ObjectiveCBridgeStubFromArrayOfNSString 25098 24751 -1.4% 1.01x (?)
ObjectiveCBridgeStubFromNSDate 4083 4121 +0.9% 0.99x (?)
ObjectiveCBridgeStubFromNSDateRef 4478 4475 -0.1% 1.00x (?)
ObjectiveCBridgeStubFromNSString 582 568 -2.4% 1.02x
ObjectiveCBridgeStubFromNSStringRef 181 181 +0.0% 1.00x
ObjectiveCBridgeStubNSDataAppend 2645 2658 +0.5% 1.00x (?)
ObjectiveCBridgeStubNSDateMutationRef 16015 15670 -2.2% 1.02x (?)
ObjectiveCBridgeStubNSDateRefAccess 1887 1900 +0.7% 0.99x (?)
ObjectiveCBridgeStubToArrayOfNSString 29438 29080 -1.2% 1.01x (?)
ObjectiveCBridgeStubToNSDate 15473 15147 -2.1% 1.02x (?)
ObjectiveCBridgeStubToNSDateRef 3323 3331 +0.2% 1.00x (?)
ObjectiveCBridgeStubToNSString 1569 1564 -0.3% 1.00x (?)
ObjectiveCBridgeStubToNSStringRef 155 155 +0.0% 1.00x
ObjectiveCBridgeStubURLAppendPath 224570 228034 +1.5% 0.98x (?)
ObjectiveCBridgeStubURLAppendPathRef 223841 222896 -0.4% 1.00x (?)
ObjectiveCBridgeToNSArray 28851 28754 -0.3% 1.00x (?)
ObjectiveCBridgeToNSDictionary 45393 44874 -1.1% 1.01x (?)
ObjectiveCBridgeToNSSet 39667 39828 +0.4% 1.00x (?)
ObjectiveCBridgeToNSString 1302 1300 -0.2% 1.00x (?)
ObserverClosure 6914 6831 -1.2% 1.01x
ObserverForwarderStruct 4860 4842 -0.4% 1.00x (?)
ObserverPartiallyAppliedMethod 8508 8514 +0.1% 1.00x (?)
ObserverUnappliedMethod 8493 8519 +0.3% 1.00x (?)
OpenClose 392 392 +0.0% 1.00x
Phonebook 21788 21682 -0.5% 1.00x (?)
PolymorphicCalls 5228 5387 +3.0% 0.97x
PopFrontArray 9967 9899 -0.7% 1.01x (?)
PopFrontArrayGeneric 8880 8880 +0.0% 1.00x
PopFrontUnsafePointer 98280 97905 -0.4% 1.00x (?)
PrefixAnyCollection 18833 18808 -0.1% 1.00x (?)
PrefixAnyCollectionLazy 137778 136476 -0.9% 1.01x (?)
PrefixAnySeqCRangeIter 22639 22748 +0.5% 1.00x (?)
PrefixAnySeqCRangeIterLazy 22531 22500 -0.1% 1.00x (?)
PrefixAnySeqCntRange 18957 18845 -0.6% 1.01x (?)
PrefixAnySeqCntRangeLazy 18728 19203 +2.5% 0.98x
PrefixAnySequence 10632 10739 +1.0% 0.99x (?)
PrefixAnySequenceLazy 10637 10805 +1.6% 0.98x
PrefixArray 6167 6303 +2.2% 0.98x
PrefixArrayLazy 44652 44462 -0.4% 1.00x (?)
PrefixCountableRange 339 340 +0.3% 1.00x
PrefixCountableRangeLazy 37489 37935 +1.2% 0.99x (?)
PrefixSequence 9516 9554 +0.4% 1.00x
PrefixSequenceLazy 9486 9643 +1.7% 0.98x
PrefixWhileAnyCollection 36095 35682 -1.1% 1.01x
PrefixWhileAnyCollectionLazy 22423 22520 +0.4% 1.00x (?)
PrefixWhileAnySeqCRangeIter 40803 40139 -1.6% 1.02x
PrefixWhileAnySeqCRangeIterLazy 22249 22249 +0.0% 1.00x
PrefixWhileAnySeqCntRange 36483 35666 -2.2% 1.02x
PrefixWhileAnySeqCntRangeLazy 22095 22497 +1.8% 0.98x
PrefixWhileAnySequence 29614 29783 +0.6% 0.99x
PrefixWhileAnySequenceLazy 11209 11204 -0.0% 1.00x (?)
PrefixWhileArray 16747 16836 +0.5% 0.99x
PrefixWhileArrayLazy 14561 14567 +0.0% 1.00x (?)
PrefixWhileCountableRange 17203 17174 -0.2% 1.00x (?)
PrefixWhileCountableRangeLazy 21347 21588 +1.1% 0.99x
PrefixWhileSequence 28251 28460 +0.7% 0.99x
PrefixWhileSequenceLazy 10256 10651 +3.9% 0.96x
Prims 10071 10125 +0.5% 0.99x (?)
ProtocolDispatch 7007 6999 -0.1% 1.00x (?)
ProtocolDispatch2 493 493 +0.0% 1.00x
RC4 19717 20700 +5.0% 0.95x
RGBHistogram 34171 34387 +0.6% 0.99x (?)
RGBHistogramOfObjects 108058 108419 +0.3% 1.00x (?)
RangeAssignment 5722 5760 +0.7% 0.99x
RecursiveOwnedParameter 11210 11157 -0.5% 1.00x
ReversedArray 43885 44378 +1.1% 0.99x (?)
ReversedBidirectional 76249 74895 -1.8% 1.02x (?)
ReversedDictionary 28444 28280 -0.6% 1.01x
SetExclusiveOr 21341 21403 +0.3% 1.00x (?)
SetExclusiveOr_OfObjects 48075 48295 +0.5% 1.00x
SetIntersect 10956 10915 -0.4% 1.00x (?)
SetIntersect_OfObjects 12590 12540 -0.4% 1.00x (?)
SetIsSubsetOf 1675 1677 +0.1% 1.00x
SetIsSubsetOf_OfObjects 1581 1578 -0.2% 1.00x
SetUnion 11776 11763 -0.1% 1.00x (?)
SetUnion_OfObjects 33526 33640 +0.3% 1.00x
SevenBoom 1598 1585 -0.8% 1.01x (?)
Sim2DArray 31917 31931 +0.0% 1.00x (?)
SortLargeExistentials 17873 17943 +0.4% 1.00x
SortLettersInPlace 3154 3140 -0.4% 1.00x
SortSortedStrings 1424 1412 -0.8% 1.01x
SortStrings 2514 2470 -1.8% 1.02x
SortStringsUnicode 9039 8987 -0.6% 1.01x
StackPromo 104260 101247 -2.9% 1.03x (?)
StaticArray 4592 4601 +0.2% 1.00x (?)
StrComplexWalk 6762 6764 +0.0% 1.00x (?)
StrToInt 101619 101411 -0.2% 1.00x (?)
StringAdder 3768 3768 +0.0% 1.00x
StringBuilder 6971 6928 -0.6% 1.01x (?)
StringBuilderLong 1103 1097 -0.5% 1.01x (?)
StringEdits 368325 374311 +1.6% 0.98x (?)
StringEqualPointerComparison 2434 2463 +1.2% 0.99x
StringFromLongWholeSubstring 13276 13347 +0.5% 0.99x (?)
StringFromLongWholeSubstringGeneric 208 206 -1.0% 1.01x
StringHasPrefixUnicode 16796 16437 -2.1% 1.02x
StringHasSuffix 1796 1861 +3.6% 0.97x
StringHasSuffixUnicode 63353 63256 -0.2% 1.00x (?)
StringInterpolation 13885 13804 -0.6% 1.01x (?)
StringMatch 32479 31812 -2.1% 1.02x
StringUTF16Builder 7881 7736 -1.8% 1.02x (?)
StringWalk 12482 13068 +4.7% 0.96x
StringWithCString 56185 57332 +2.0% 0.98x
SubstringComparable 4232 4232 +0.0% 1.00x
SubstringEqualString 6315 6351 +0.6% 0.99x (?)
SubstringEquatable 8055 8172 +1.5% 0.99x
SubstringFromLongString 12 12 +0.0% 1.00x
SubstringFromLongStringGeneric 111 110 -0.9% 1.01x
SuffixAnyCollection 6288 6304 +0.3% 1.00x (?)
SuffixAnyCollectionLazy 45682 45816 +0.3% 1.00x (?)
SuffixAnySeqCRangeIter 41353 41241 -0.3% 1.00x (?)
SuffixAnySeqCRangeIterLazy 41902 40936 -2.3% 1.02x
SuffixAnySeqCntRange 6268 6338 +1.1% 0.99x
SuffixAnySeqCntRangeLazy 6324 6371 +0.7% 0.99x
SuffixAnySequence 26685 26881 +0.7% 0.99x
SuffixAnySequenceLazy 26714 26901 +0.7% 0.99x
SuffixArray 2082 2107 +1.2% 0.99x
SuffixArrayLazy 14899 14833 -0.4% 1.00x (?)
SuffixCountableRange 118 118 +0.0% 1.00x
SuffixCountableRangeLazy 12475 12512 +0.3% 1.00x (?)
SuffixSequence 26321 26402 +0.3% 1.00x
SuffixSequenceLazy 26310 26730 +1.6% 0.98x
SuperChars 189298 188945 -0.2% 1.00x (?)
TwoSum 4231 4229 -0.0% 1.00x (?)
UTF8Decode 37296 37083 -0.6% 1.01x
Walsh 11949 11970 +0.2% 1.00x (?)
XorLoop 25077 25078 +0.0% 1.00x (?)
accessGlobal 184 191 +3.8% 0.96x
accessInMatSet 325 327 +0.6% 0.99x
accessIndependent 125 124 -0.8% 1.01x
Hardware Overview
  Model Name: Mac mini
  Model Identifier: Macmini7,1
  Processor Name: Intel Core i5
  Processor Speed: 2.8 GHz
  Number of Processors: 1
  Total Number of Cores: 2
  L2 Cache (per Core): 256 KB
  L3 Cache: 3 MB
  Memory: 8 GB

@xwu
Copy link
Collaborator

xwu commented Jul 19, 2017

Since masking shifts can more efficient than non-masking ones, and since it is not possible to implement the same generic method twice, once with an additional constraint, wouldn't there be performance implications to redesigning in this way?

IMO, it is fine to consider masking shift as the most primitive operation; for a binary integer of arbitrary width, it should simply always be the same operation as the non-masking shift. This can be achieved by redefining masking shift semantics without any change in the syntax or protocol design.

@dabrahams
Copy link
Contributor Author

dabrahams commented Jul 19, 2017

@xwu good questions. Fortunately I think I have answers.

W.r.t. performance implications, this only comes up if:

  1. you are writing generic code on BinaryInteger
  2. the shift amount is a non-constant
  3. you know you can afford the semantics of a masking shift when the integer is FixedWidth
  4. masking the shift using some constant not based on the type of the LHS would produce the wrong result.

I'm not even sure there is a use case like this, but if a use case does exist we should figure out a way to support it. The following might be a useful component of that solution, though admittedly it only generates good code for the fixed-width integers and thus suggests isFixedWidth should be a protocol requirement.

extension BinaryInteger {
  static var isFixedWidth: Bool {
    return isSigned
    ? Magnitude(extendingOrTruncating: ~Self()) != ~Self()
    : (~Self() << 1) < ~Self()
  }
}

With regard to defining the semantics as you suggest, I personally didn't see any way to specify them so they made sense, that didn't get into a horrible tangle. Try to write out the formal semantic requirements of &<< and &>> for BinaryIntegerand you'll see what I mean—or else you'll succeed, and so much the better!

@xwu
Copy link
Collaborator

xwu commented Jul 20, 2017

I've thought about the isFixedWidth idea. I wouldn't mind its addition to BinaryInteger. That said, by your "what useful algorithms does this enable" test, the utility is limited.

By this I mean that isFixedWidth could be enormously useful, for example, in implementing certain Rational<T> functions. For a fixed-width T, the use of full-width multiplication and division may be required for certain operands to avoid overflow trapping when attempting to compute the product of two instances of Rational<T>. However, just as your proposal would make it impossible to write &<< in the generic context when working with instances of typeT : BinaryInteger, it is currently impossible to use multipliedFullWidth in an algorithm that operates on instances of type T : BinaryInteger.

This is all to say that isFixedWidth is interesting, and I like it, but for its full utility we need to address the &<< vs. << problem for all operations for which there are fixed-width-specific considerations.

As to the semantics of &<< vs. <<, let me try this out:

  • A BinaryInteger represents, simultaneously, an integral numeric value and a sequence of bits which is the two's-complement representation of that value. The number of bits in the sequence is the same for every instance of a particular type T : BinaryInteger, but that number may be finite or infinite.
  • A FixedWidthInteger represents, simultaneously, an integral numeric value and a collection of bits which is the two's-complement representation of that value. The number of bits in the collection is the same for every instance of a particular type T : FixedWidthInteger, and that number must be finite (since it is a collection).
  • Some operations on BinaryInteger operate on the represented numeric value of operands; others operate on the represented sequence of bits. Specifically, all bitwise operators and bit shifting operators, as their names suggest, operate on the sequence of bits and not the numeric value.
  • A masking shift logically preprocesses the right-hand operand by masking its bits to produce a value in the range 0...(x-1) where x is the number of bits in the left-hand operand. (Unchanged.)

Note that this definition requires &<< to be a protocol requirement without a default implementation, as there is no possible default implementation of &<< on BinaryInteger directly. Any arbitrary-width integer conforming to BinaryInteger, though, can conform to that protocol by providing an implementation of &<< consistent with the above semantics; I expect that all such arbitrary-width integer types will model an infinite sequence of bits since operations like & and | demand this interpretation, and the desired behavior of &<< therefore falls out automatically.

@natecook1000
Copy link
Member

Thanks, @xwu—I think I'm mostly with you. Although within the current system we can't say a BinaryInteger has an infinite number of bits, it does help to model it that way.

It's helpful for me to make a distinction between what a masking shift does and what it's for. What it does is right in the name—it masks the RHS value to be in the range of 0..<lhs.bitWidth and then performs the shift. However, it's not made for the purpose of shifting bits by a masked value. Instead, it's for shifting bits without the branching that the smart shift operator performs, when you know the LHS value is "in bounds" for the type you're using.

That is to say, it isn't designed so we can write code like this:

let x: UInt8 = 2
let y = x &<< 10    // 10 & 0x7 == 2, so y == 2 << 2 == 8

Instead, it's so we can write code like this with the best possible performance, while still having defined behavior when LHS is outside the bounds that would be caught by a smart shift:

let x: UInt8 = 2
let y = x &<< 2      // or really shifted by some value we statically know is in 0..<8

I still don't think it's clear that there are any cases where the criteria Dave set forth above are met, so to me the "standard" shift operators make more sense at the BinaryInteger level. Their performance would be slightly better that at the FixedWidthInteger, since there's only the single branch to test for negative values, a case we'd need to handle for the masking shifts anyway. What do you see as the behavior for a negative masking shift on an arbitrarily-sized integer?

@dabrahams
Copy link
Contributor Author

dabrahams commented Jul 20, 2017

@xwu a few thoughts I'd like to add to what Nate said. I agree strongly that isFixedWidth has limited utility, because you still have no way of finding out what the mask width should be in that case. I think I just felt the need to post the implementation once I figured out how to write it 😉. If I were going to try to handle things in this vein, I think I'd want var maxBitWidth: Int?, which would be nil for types that were not fixed-width.

But I don't think I want to handle things this way, because of what it does to the semantic description of &<<. While your description of the semantics makes intuitive sense, it doesn't amount to what I asked for: documentation of the semantic requirements of &<< and &>> for BinaryInteger. Specifically, you need to be able to answer the question, given an arbitrary model x of BinaryInteger and an arbitrary integer n, what can a generic algorithm writer count on about the result of x &<< n? This is almost equivalent to answering the age-old question, “what useful algorithms does this enable?”

@xwu
Copy link
Collaborator

xwu commented Jul 20, 2017

@natecook1000 @dabrahams Very good points.

Nate, you bring up an interesting question about masking shift by a negative value. In playing with implementing a bignum type, I had to figure out what to do about exactly that under the current semantics. It is not a useful operation; the semantics would imply that the result should be infinitely large, since, after masking, any negative value would be infinitely large. Absent a representation for infinity, this should be an error. This supports the notion that &<< does not have sensible semantics for a bignum.

As to what useful algorithms I'm interested in, the answer is simply: For any arbitrary integer value x and n, I want some spelling for left-shifting x by n in generic code in such a way that: (1) for 0 <= n < x.bitWidth, the result is equal to x << n; and (2) is the most performant. If, of course, it is true that Dave's criteria are never met, then the point is moot.

@dabrahams
Copy link
Contributor Author

dabrahams commented Jul 20, 2017

@xwu if what you're really interested in is 0 ≤ n < x.bitWidth the answer is simple. However, x.bitWidth is an upper bound on the number of bits required to represent x, not the number of bits representable by type(of: x), i.e. (1.bitWidth could be 2), so I doubt this is really what you're after.

@xwu
Copy link
Collaborator

xwu commented Jul 20, 2017

@dabrahams Right, that's not quite what I'm after. The upperbound-ness of bitWidth is practical but a little tricky!

@dabrahams
Copy link
Contributor Author

Looking a little further, I'm not convinced that bitWidth is useful the way it's currently defined, at least for BinaryInteger and ( @natecook1000 ) it looks like it is used in the documentation of &<< as though it means something like the aforementioned maxBitWidth. IMO we should strongly consider replacing it.

@moiseev
Copy link
Contributor

moiseev commented Jul 21, 2017

@swift-ci Please Test Source Compatibility

moiseev pushed a commit to moiseev/swift-corelibs-foundation that referenced this pull request Jul 21, 2017
This expression became too complex due to the changes introduced in
swiftlang/swift#11044
@moiseev
Copy link
Contributor

moiseev commented Jul 21, 2017

apple/swift-corelibs-foundation#1124
@swift-ci Please test Linux platform

@natecook1000
Copy link
Member

I went spelunking in the SE-104 history to see how we arrived at this situation:

  • The initial proposal had both masking and smart shifts, but they were all only for shifting FixedWidthIntegers. In the second round, the masking shifts moved up to BinaryInteger, but obviously didn't get into the details we're discussing here.
  • There was once a minimumSignedRepresentationBitWidth property, which sounds like it would help this discussion or perhaps be more accurate than bitWidth for arbitrarily-sized integers.
  • None of the discussion of bitWidth in the proposals really reckons with these questions.

@dabrahams Do you mean getting rid of the instance-level bitWidth property? I'm really not sure what to make of that either at the BinaryInteger level.

@xwu
Copy link
Collaborator

xwu commented Jul 21, 2017

@natecook1000 @dabrahams Agree that the current semantics of instance-level bitWidth are unsatisfying. There's the fixed-width bitWidth on the one hand that has its uses, and then really what we want is another property to tell us the position of the leading one bit of the binary representation of the absolute value--however one wants to name that property. I'd be in favor of exploring spellings that avoid "bit width" at all, to better distinguish the two.

@dabrahams
Copy link
Contributor Author

@xwu because leadingZeroBitCount is a fundamental property, we just need something that represents... the bitWidth 😉. Then you can subtract them.

@xwu
Copy link
Collaborator

xwu commented Jul 21, 2017

@dabrahams It's turtles all the way down: leadingZeroBitCount is a property of fixed-width integers only (and IMO, correctly so*; this is to be contrasted with trailingZeroBitCount).

* The most sensible semantics for bitwise operations on arbitrary-width integers (an infinite sequence of bits, etc.) would have the hypothetical leading zero bit count and bit width both as infinity.

What I'm getting at is we need some way to spell the "bit scan reverse" (BSR) intrinsic (of the absolute value); the integer binary logarithm of the magnitude, if you will.

moiseev pushed a commit to moiseev/swift-corelibs-foundation that referenced this pull request Jul 24, 2017
This expression became too complex due to the changes introduced in
swiftlang/swift#11044
moiseev pushed a commit to moiseev/swift-corelibs-foundation that referenced this pull request Jul 24, 2017
This expression became too complex due to the changes introduced in
swiftlang/swift#11044
@moiseev
Copy link
Contributor

moiseev commented Jul 24, 2017

apple/swift-corelibs-foundation#1124
@swift-ci Please test Linux platform

@dabrahams
Copy link
Contributor Author

dabrahams commented Jul 24, 2017 via email

@moiseev
Copy link
Contributor

moiseev commented Jul 24, 2017

In many places instance bitWidth is used in the branches in generic code over BinaryInteger with the hope that optimizer will inline a constant there and eliminate those branches completely in a fully specialized code. Even though it's not a good enough reason to design an API based on the capabilities of the compiler, replacing instance bitWidth with words.count almost certainly will result in regressions.

@moiseev
Copy link
Contributor

moiseev commented Jul 24, 2017

Perhaps we can underscore it for now... in order to discourage usages, and see what to do with it at a later date.

@dabrahams
Copy link
Contributor Author

dabrahams commented Jul 24, 2017 via email

@moiseev
Copy link
Contributor

moiseev commented Jul 24, 2017

@dabrahams no reason to not try it then.

@moiseev
Copy link
Contributor

moiseev commented Jul 24, 2017

Huh. Words is not a Collection. So, no count for us to use. /cc @lorentey

@lorentey
Copy link
Member

@moiseev Collection conformance for Words requires compiler support for recursive constraints. (It works with 03f3a0c.)

With the current compiler, it may be possible to add _IndexableBase or even _Indexable conformance; unfortunately the count property is in neither of those protocols. (Plus the extra constraint causes weird bugs that I did not have time to track down yet.)

@lorentey
Copy link
Member

I took a second look on the latest master and it seems BinaryInteger.Words can now be constrained to Collection -- see #11178. 🎉

This enables the use of words.count as a potential replacement for bitWidth.

@dabrahams
Copy link
Contributor Author

dabrahams commented Jul 25, 2017 via email

@moiseev moiseev changed the title [NOMERGE] [stdlib] Rationalize bitshifting in protocols [stdlib] Rationalize bitshifting in protocols Jul 27, 2017
@moiseev moiseev merged commit 47e78c0 into master Jul 27, 2017
@moiseev moiseev deleted the rationalize-bitshifting branch July 27, 2017 21:50
benrimmington added a commit to swiftlang/swift-evolution that referenced this pull request Sep 3, 2017
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.

None yet

6 participants