Skip to content

stdlib: some small Array improvements to prepare for COW representation #32055

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 3 commits into from
May 29, 2020

Conversation

eeckstein
Copy link
Contributor

This PR contains a set of Array changes which are needed - or beneficial - for the switch to the COW representation in Array types:

  • make sure that SetAlgebra.init(sequence) is on the fast path.
  • prevent storing into the empty array singleton when replacing an array sub-sequence
  • move the new-buffer creation function from Array to ArrayBuffer

For details see the commit messages.

@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci benchmark

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - dd79b1f733909855a0915d1660ffefb5b7217925

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
DataCreateEmpty 80 110 +37.5% 0.73x
EqualSubstringSubstring 22 30 +36.4% 0.73x
EqualSubstringSubstringGenericEquatable 22 30 +36.4% 0.73x
EqualSubstringString 22 30 +36.4% 0.73x
LessSubstringSubstringGenericComparable 22 30 +36.4% 0.73x
BinaryFloatingPointPropertiesUlp 21 28 +33.3% 0.75x
LessSubstringSubstring 23 30 +30.4% 0.77x
EqualStringSubstring 23 30 +30.4% 0.77x
PrefixWhileArrayLazy 20 26 +30.0% 0.77x (?)
ObjectiveCBridgeStubFromNSDate 3020 3810 +26.2% 0.79x (?)
ArrayAppendRepeatCol 400 500 +25.0% 0.80x (?)
PrefixWhileSequence 178 219 +23.0% 0.81x
RemoveWhereSwapInts 36 44 +22.2% 0.82x
RecursiveOwnedParameter 54 65 +20.4% 0.83x (?)
RangeOverlapsRange 60 72 +20.0% 0.83x (?)
ReversedArray2 94 110 +17.0% 0.85x (?)
RandomShuffleLCG2 416 480 +15.4% 0.87x (?)
DataSubscriptSmall 13 15 +15.4% 0.87x (?)
UTF8Decode_InitFromCustom_contiguous 143 164 +14.7% 0.87x (?)
UTF8Decode_InitDecoding 143 164 +14.7% 0.87x (?)
DropLastSequence 338 384 +13.6% 0.88x (?)
SuffixSequenceLazy 269 304 +13.0% 0.88x (?)
SuffixSequence 269 303 +12.6% 0.89x (?)
Array2D 4096 4608 +12.5% 0.89x (?)
RemoveWhereMoveInts 17 19 +11.8% 0.89x (?)
StringComparison_longSharedPrefix 321 356 +10.9% 0.90x (?)
CharacterLiteralsSmall 196 217 +10.7% 0.90x (?)
AngryPhonebook.Strasse 136 150 +10.3% 0.91x (?)
PrefixWhileAnySeqCRangeIter 177 195 +10.2% 0.91x (?)
ArrayPlusEqualFiveElementCollection 4403 4847 +10.1% 0.91x (?)
ReversedDictionary2 219 241 +10.0% 0.91x (?)
Data.hash.Medium 30 33 +10.0% 0.91x (?)
ArraySetElement 262 288 +9.9% 0.91x (?)
MapReduceSequence 369 404 +9.5% 0.91x (?)
Set.isSubset.Seq.Empty.Int 76 83 +9.2% 0.92x (?)
PrefixWhileAnySeqCntRange 179 194 +8.4% 0.92x (?)
ArraySubscript 812 880 +8.4% 0.92x
OpenClose 61 66 +8.2% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
ArrayAppendLazyMap 1750 850 -51.4% 2.06x
PrefixWhileSequenceLazy 40 26 -35.0% 1.54x
PrefixSequenceLazy 31 22 -29.0% 1.41x
PrefixSequence 31 22 -29.0% 1.41x
PointerArithmetics 23900 17400 -27.2% 1.37x
FlattenListFlatMap 4431 3486 -21.3% 1.27x (?)
DataCountSmall 19 15 -21.1% 1.27x
DropWhileSequenceLazy 62 49 -21.0% 1.27x
RangeIterationSigned 108 87 -19.4% 1.24x
RangeOverlapsClosedRange 114 93 -18.4% 1.23x
ArrayAppendAsciiSubstring 22860 18936 -17.2% 1.21x
ArrayAppendUTF16Substring 22932 19044 -17.0% 1.20x (?)
ArrayAppendLatin1Substring 23328 19404 -16.8% 1.20x (?)
DropWhileArrayLazy 58 49 -15.5% 1.18x (?)
FatCompactMap 620 530 -14.5% 1.17x (?)
Set.isDisjoint.Seq.Int.Empty 52 45 -13.5% 1.16x (?)
Chars2 3350 2900 -13.4% 1.16x (?)
Set.isSubset.Int.Empty 51 45 -11.8% 1.13x (?)
DataCountMedium 17 15 -11.8% 1.13x
CharIteration_tweet_unicodeScalars 4840 4280 -11.6% 1.13x (?)
CharIteration_ascii_unicodeScalars 2440 2160 -11.5% 1.13x (?)
BucketSort 154 138 -10.4% 1.12x (?)
ProtocolDispatch 217 196 -9.7% 1.11x (?)
Calculator 152 138 -9.2% 1.10x (?)
ArrayLiteral2 78 71 -9.0% 1.10x (?)
CharIteration_punctuated_unicodeScalars 560 520 -7.1% 1.08x
Set.subtracting.Empty.Int 28 26 -7.1% 1.08x (?)

Code size: -O

Regression OLD NEW DELTA RATIO
Breadcrumbs.o 37447 42543 +13.6% 0.88x
Prims.o 12907 13499 +4.6% 0.96x
PrimsSplit.o 12959 13551 +4.6% 0.96x
BucketSort.o 8451 8795 +4.1% 0.96x
Array2D.o 3012 3115 +3.4% 0.97x
RomanNumbers.o 6356 6548 +3.0% 0.97x
DictOfArraysToArrayOfDicts.o 22512 23088 +2.6% 0.98x
main.o 54243 55611 +2.5% 0.98x
DriverUtils.o 139275 142139 +2.1% 0.98x
Phonebook.o 9175 9359 +2.0% 0.98x
Queue.o 12229 12469 +2.0% 0.98x
MonteCarloE.o 2804 2839 +1.2% 0.99x
DictionaryGroup.o 12291 12435 +1.2% 0.99x
PrimsNonStrongRef.o 125520 126912 +1.1% 0.99x
 
Improvement OLD NEW DELTA RATIO
ExistentialPerformance.o 50652 38244 -24.5% 1.32x
StringWalk.o 40369 32929 -18.4% 1.23x
FloatingPointPrinting.o 5988 5028 -16.0% 1.19x
StringReplaceSubrange.o 5739 4827 -15.9% 1.19x
ArrayLiteral.o 3461 2917 -15.7% 1.19x
DataBenchmarks.o 67821 57205 -15.7% 1.19x
NSStringConversion.o 14252 12108 -15.0% 1.18x
RandomValues.o 2923 2507 -14.2% 1.17x
ObjectiveCBridgingStubs.o 16757 14373 -14.2% 1.17x
TypeFlood.o 971 835 -14.0% 1.16x
ProtocolDispatch.o 892 772 -13.5% 1.16x
InsertCharacter.o 5195 4507 -13.2% 1.15x
CaptureProp.o 1003 883 -12.0% 1.14x
StringBuilder.o 8289 7377 -11.0% 1.12x
CharacterLiteralsLarge.o 1154 1034 -10.4% 1.12x
DictionaryCopy.o 9510 8566 -9.9% 1.11x
ArrayAppend.o 25903 23367 -9.8% 1.11x
ObjectiveCNoBridgingStubs.o 9260 8364 -9.7% 1.11x
Diffing.o 8763 7931 -9.5% 1.10x
AngryPhonebook.o 10147 9219 -9.1% 1.10x
SetTests.o 133685 121717 -9.0% 1.10x
DictionaryLiteral.o 1382 1262 -8.7% 1.10x
NSError.o 1435 1315 -8.4% 1.09x
MonteCarloPi.o 1650 1514 -8.2% 1.09x
Prefix.o 17664 16224 -8.2% 1.09x
Fibonacci.o 1705 1569 -8.0% 1.09x
DropWhile.o 18020 16596 -7.9% 1.09x
Substring.o 16955 15643 -7.7% 1.08x
ByteSwap.o 1768 1632 -7.7% 1.08x
PrefixWhile.o 17670 16374 -7.3% 1.08x
DropFirst.o 19788 18364 -7.2% 1.08x
SevenBoom.o 1679 1559 -7.1% 1.08x
NSDictionaryCastToSwift.o 1682 1562 -7.1% 1.08x
SuperChars.o 1689 1569 -7.1% 1.08x
CharacterLiteralsSmall.o 1714 1594 -7.0% 1.08x
FlattenList.o 4346 4042 -7.0% 1.08x
Exclusivity.o 4818 4482 -7.0% 1.07x
Chars.o 1750 1630 -6.9% 1.07x
BitCount.o 1985 1849 -6.9% 1.07x
ProtocolDispatch2.o 1761 1641 -6.8% 1.07x
RangeIteration.o 1695 1583 -6.6% 1.07x
Ackermann.o 2068 1932 -6.6% 1.07x
Join.o 1615 1511 -6.4% 1.07x
StringTests.o 8065 7553 -6.3% 1.07x
PointerArithmetics.o 1798 1686 -6.2% 1.07x
StringComparison.o 39498 37050 -6.2% 1.07x
DeadArray.o 1937 1817 -6.2% 1.07x
PopFrontGeneric.o 2744 2576 -6.1% 1.07x
DictionaryBridgeToObjC.o 5599 5263 -6.0% 1.06x
UTF8Decode.o 25091 23603 -5.9% 1.06x
IterateData.o 2064 1944 -5.8% 1.06x
ChainedFilterMap.o 3637 3429 -5.7% 1.06x
ReduceInto.o 10932 10308 -5.7% 1.06x
DevirtualizeProtocolComposition.o 2038 1926 -5.5% 1.06x
Integrate.o 2510 2374 -5.4% 1.06x
RecursiveOwnedParameter.o 2270 2150 -5.3% 1.06x
PopFront.o 3923 3723 -5.1% 1.05x
StringInterpolation.o 7083 6723 -5.1% 1.05x
LinkedList.o 2439 2319 -4.9% 1.05x
Calculator.o 2777 2641 -4.9% 1.05x
OpaqueConsumingUsers.o 2527 2407 -4.7% 1.05x
Suffix.o 23853 22757 -4.6% 1.05x
ObjectiveCBridging.o 64823 61943 -4.4% 1.05x
CString.o 7015 6711 -4.3% 1.05x
StrComplexWalk.o 2778 2658 -4.3% 1.05x
ObserverForwarderStruct.o 2868 2748 -4.2% 1.04x
BinaryFloatingPointProperties.o 5676 5442 -4.1% 1.04x
DropLast.o 23599 22631 -4.1% 1.04x
Histogram.o 3302 3167 -4.1% 1.04x
XorLoop.o 2132 2045 -4.1% 1.04x
ArrayOfGenericPOD.o 5555 5331 -4.0% 1.04x
ArraySetElement.o 1240 1190 -4.0% 1.04x
ArrayOfPOD.o 2998 2878 -4.0% 1.04x
FindStringNaive.o 9635 9251 -4.0% 1.04x
ErrorHandling.o 3459 3323 -3.9% 1.04x
COWArrayGuaranteedParameterOverhead.o 1315 1265 -3.8% 1.04x
FloatingPointParsing.o 17521 16881 -3.7% 1.04x
MapReduce.o 27831 26823 -3.6% 1.04x
DictionaryBridge.o 3420 3300 -3.5% 1.04x
Hanoi.o 3120 3014 -3.4% 1.04x
AnyHashableWithAClass.o 3609 3489 -3.3% 1.03x
OpenClose.o 3664 3544 -3.3% 1.03x
StackPromo.o 2217 2145 -3.2% 1.03x
StrToInt.o 3705 3585 -3.2% 1.03x
SequenceAlgos.o 21999 21295 -3.2% 1.03x
ObserverUnappliedMethod.o 5105 4953 -3.0% 1.03x
ObserverClosure.o 2462 2390 -2.9% 1.03x
DictionaryKeysContains.o 8546 8299 -2.9% 1.03x
IntegerParsing.o 58109 56445 -2.9% 1.03x
Radix2CooleyTukey.o 7672 7464 -2.7% 1.03x
TwoSum.o 4448 4328 -2.7% 1.03x
ArrayInClass.o 4527 4405 -2.7% 1.03x
ObjectAllocation.o 4571 4451 -2.6% 1.03x
Sim2DArray.o 1320 1286 -2.6% 1.03x
LazyFilter.o 8088 7880 -2.6% 1.03x
DictionarySwap.o 18173 17709 -2.6% 1.03x
RandomShuffle.o 3632 3542 -2.5% 1.03x
ClassArrayGetter.o 3659 3571 -2.4% 1.02x
RandomTree.o 12375 12079 -2.4% 1.02x
SortIntPyramids.o 8973 8766 -2.3% 1.02x
NIOChannelPipeline.o 4931 4819 -2.3% 1.02x
DictionaryOfAnyHashableStrings.o 8458 8266 -2.3% 1.02x
StringMatch.o 5336 5216 -2.2% 1.02x
ObserverPartiallyAppliedMethod.o 2509 2453 -2.2% 1.02x
CharacterProperties.o 22561 22081 -2.1% 1.02x
HTTP2StateMachine.o 5792 5673 -2.1% 1.02x
DictTest2.o 10909 10685 -2.1% 1.02x
DictionarySubscriptDefault.o 19683 19299 -2.0% 1.02x
Memset.o 2215 2173 -1.9% 1.02x
NopDeinit.o 3847 3775 -1.9% 1.02x
DictionaryRemove.o 13264 13024 -1.8% 1.02x
DictionaryCompactMapValues.o 13333 13093 -1.8% 1.02x
RC4.o 3975 3911 -1.6% 1.02x
DictTest.o 14268 14044 -1.6% 1.02x
SortArrayInClass.o 2738 2696 -1.5% 1.02x
DictTest3.o 15701 15477 -1.4% 1.01x
DictTest4.o 16642 16418 -1.3% 1.01x
Codable.o 31391 30975 -1.3% 1.01x
DictTest4Legacy.o 17276 17052 -1.3% 1.01x
LuhnAlgoEager.o 12805 12669 -1.1% 1.01x
LuhnAlgoLazy.o 12805 12669 -1.1% 1.01x

Performance: -Osize

Regression OLD NEW DELTA RATIO
ArrayAppendSequence 500 1290 +158.0% 0.39x
PrefixWhileCountableRange 13 26 +100.0% 0.50x
RecursiveOwnedParameter 55 109 +98.2% 0.50x
PrefixWhileAnySeqCRangeIterLazy 81 135 +66.7% 0.60x
PrefixWhileAnySeqCntRangeLazy 81 135 +66.7% 0.60x
Data.init.Sequence.64kB.Count.RE 29 43 +48.3% 0.67x
Data.append.Sequence.64kB.Count.RE.I 30 44 +46.7% 0.68x
Data.append.Sequence.64kB.Count.RE 30 44 +46.7% 0.68x
FindString.Loop1.Array 299 435 +45.5% 0.69x
Data.init.Sequence.64kB.Count.RE.I 30 43 +43.3% 0.70x
StringEqualPointerComparison 108 152 +40.7% 0.71x
PrefixWhileAnyCollection 99 139 +40.4% 0.71x
PolymorphicCalls 10 14 +40.0% 0.71x
EqualSubstringSubstring 22 30 +36.4% 0.73x
EqualSubstringSubstringGenericEquatable 22 30 +36.4% 0.73x
EqualSubstringString 22 30 +36.4% 0.73x
DropFirstAnySeqCRangeIterLazy 111 147 +32.4% 0.76x
DropFirstAnySeqCntRangeLazy 111 147 +32.4% 0.76x
LessSubstringSubstring 23 30 +30.4% 0.77x
EqualStringSubstring 23 30 +30.4% 0.77x (?)
LessSubstringSubstringGenericComparable 23 30 +30.4% 0.77x
CharIndexing_japanese_unicodeScalars_Backwards 8600 11080 +28.8% 0.78x
Data.init.Sequence.809B.Count.RE 59 76 +28.8% 0.78x
Data.init.Sequence.809B.Count.RE.I 59 76 +28.8% 0.78x
CharIndexing_ascii_unicodeScalars_Backwards 5880 7520 +27.9% 0.78x
Data.append.Sequence.809B.Count.RE 71 90 +26.8% 0.79x (?)
CharIndexing_chinese_unicodeScalars_Backwards 5440 6880 +26.5% 0.79x
CharIndexing_tweet_unicodeScalars_Backwards 11800 14800 +25.4% 0.80x
CharIteration_tweet_unicodeScalars_Backwards 6680 8360 +25.1% 0.80x
DropLastAnyCollection 36 45 +25.0% 0.80x
SuffixCountableRange 4 5 +25.0% 0.80x (?)
SuffixArrayLazy 4 5 +25.0% 0.80x (?)
DropLastCountableRange 4 5 +25.0% 0.80x (?)
CharIndexing_russian_unicodeScalars_Backwards 6280 7840 +24.8% 0.80x
Data.append.Sequence.809B.Count.RE.I 73 91 +24.7% 0.80x
CharIteration_ascii_unicodeScalars_Backwards 3400 4200 +23.5% 0.81x
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 1360 1680 +23.5% 0.81x
DataAppendSequence 7300 9000 +23.3% 0.81x
UTF8Decode_InitFromCustom_noncontiguous 267 328 +22.8% 0.81x
CharIteration_russian_unicodeScalars_Backwards 3520 4280 +21.6% 0.82x
UTF8Decode_InitFromCustom_noncontiguous_ascii 615 746 +21.3% 0.82x
CharIteration_chinese_unicodeScalars_Backwards 3200 3880 +21.2% 0.82x
CharIndexing_punctuated_unicodeScalars_Backwards 1520 1840 +21.1% 0.83x
CharIndexing_ascii_unicodeScalars 3280 3960 +20.7% 0.83x
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 800 960 +20.0% 0.83x
CharIteration_punctuated_unicodeScalars_Backwards 800 960 +20.0% 0.83x
CharIteration_japanese_unicodeScalars_Backwards 5440 6520 +19.9% 0.83x (?)
UTF8Decode_InitFromCustom_noncontiguous_ascii_as_ascii 696 832 +19.5% 0.84x
CharIndexing_korean_unicodeScalars_Backwards 7800 9320 +19.5% 0.84x
CharIteration_korean_unicodeScalars_Backwards 4320 5160 +19.4% 0.84x (?)
ObjectiveCBridgeStubDateAccess 130 152 +16.9% 0.86x
CharIndexing_tweet_unicodeScalars 6640 7760 +16.9% 0.86x
UTF8Decode_InitFromCustom_contiguous 143 166 +16.1% 0.86x (?)
MapReduceLazyCollectionShort 26 30 +15.4% 0.87x (?)
PrefixWhileAnyCollectionLazy 94 108 +14.9% 0.87x
DropWhileCountableRange 14 16 +14.3% 0.88x (?)
DropFirstCountableRange 14 16 +14.3% 0.88x (?)
ArrayPlusEqualFiveElementCollection 4329 4921 +13.7% 0.88x (?)
CharIndexing_punctuated_unicodeScalars 880 1000 +13.6% 0.88x
Data.hash.Medium 30 34 +13.3% 0.88x
DataCountSmall 15 17 +13.3% 0.88x
DataCountMedium 15 17 +13.3% 0.88x
StringComparison_longSharedPrefix 322 360 +11.8% 0.89x (?)
CharIteration_utf16_unicodeScalars_Backwards 5160 5760 +11.6% 0.90x (?)
AngryPhonebook.Armenian 156 174 +11.5% 0.90x (?)
DropWhileArrayLazy 44 49 +11.4% 0.90x
ProtocolDispatch 196 217 +10.7% 0.90x (?)
AngryPhonebook.Cyrillic 168 186 +10.7% 0.90x (?)
DropLastAnySeqCRangeIter 441 488 +10.7% 0.90x (?)
ArrayInClass 850 940 +10.6% 0.90x (?)
MapReduce 218 241 +10.6% 0.90x (?)
AngryPhonebook.Strasse 137 151 +10.2% 0.91x (?)
NormalizedIterator_fastPrenormal 630 690 +9.5% 0.91x (?)
Array2D 4240 4640 +9.4% 0.91x (?)
CharIndexing_utf16_unicodeScalars_Backwards 7320 8000 +9.3% 0.92x (?)
ArrayOfPOD 332 361 +8.7% 0.92x (?)
ObjectiveCBridgeStubNSDateRefAccess 512 556 +8.6% 0.92x (?)
FilterEvenUsingReduce 830 900 +8.4% 0.92x (?)
NormalizedIterator_latin1 216 234 +8.3% 0.92x (?)
CharIndexing_chinese_unicodeScalars 3400 3680 +8.2% 0.92x (?)
DropLastSequence 426 461 +8.2% 0.92x (?)
MapReduceAnyCollection 221 239 +8.1% 0.92x (?)
Breadcrumbs.MutatedUTF16ToIdx.Mixed 197 212 +7.6% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
ArrayAppendRepeatCol 850 420 -50.6% 2.02x
DropFirstArrayLazy 26 13 -50.0% 2.00x (?)
DropLastArray 9 5 -44.4% 1.80x
SumUsingReduceInto 440 281 -36.1% 1.57x
SumUsingReduce 440 282 -35.9% 1.56x
PrefixWhileArrayLazy 40 26 -35.0% 1.54x
BitCount 166 123 -25.9% 1.35x
CharIteration_punctuatedJapanese_unicodeScalars 640 480 -25.0% 1.33x
PrefixWhileCountableRangeLazy 26 20 -23.1% 1.30x
CharIteration_japanese_unicodeScalars 4480 3600 -19.6% 1.24x
RangeIterationSigned 108 87 -19.4% 1.24x
CharIteration_chinese_unicodeScalars 2640 2160 -18.2% 1.22x
PrefixWhileArray 56 46 -17.9% 1.22x
CharIteration_russian_unicodeScalars 3000 2520 -16.0% 1.19x (?)
CharIteration_korean_unicodeScalars 3320 2800 -15.7% 1.19x
DropWhileAnySeqCRangeIterLazy 166 140 -15.7% 1.19x (?)
DropWhileAnySeqCntRangeLazy 165 140 -15.2% 1.18x (?)
CharIteration_punctuated_unicodeScalars 600 520 -13.3% 1.15x (?)
StringHasPrefixAscii 1320 1150 -12.9% 1.15x (?)
Set.subtracting.Empty.Box 9 8 -11.1% 1.12x
DataSubscriptSmall 19 17 -10.5% 1.12x (?)
ParseInt.UInt64.Decimal 193 173 -10.4% 1.12x
ArrayAppendUTF16Substring 21096 19008 -9.9% 1.11x (?)
ArrayAppendAsciiSubstring 21096 19008 -9.9% 1.11x (?)
ArrayAppendLatin1Substring 21528 19404 -9.9% 1.11x (?)
Data.init.Sequence.64kB.Count0.RE.I 202 184 -8.9% 1.10x (?)
StringUTF16Builder 230 210 -8.7% 1.10x (?)
StringHasSuffixAscii 1400 1280 -8.6% 1.09x (?)
ObjectiveCBridgeStringIsEqualAllSwift 60 55 -8.3% 1.09x (?)
Data.init.Sequence.64kB.Count0.RE 201 185 -8.0% 1.09x (?)
SequenceAlgosArray 1960 1810 -7.7% 1.08x (?)
SequenceAlgosContiguousArray 1960 1810 -7.7% 1.08x (?)
Set.isDisjoint.Int.Empty 57 53 -7.0% 1.08x (?)
IterateData 1012 944 -6.7% 1.07x (?)
DropFirstCountableRangeLazy 15 14 -6.7% 1.07x (?)

Code size: -Osize

Regression OLD NEW DELTA RATIO
RemoveWhere.o 15855 16527 +4.2% 0.96x
Breadcrumbs.o 35829 36937 +3.1% 0.97x
BucketSort.o 8075 8267 +2.4% 0.98x
DictOfArraysToArrayOfDicts.o 20681 21121 +2.1% 0.98x
Queue.o 11977 12217 +2.0% 0.98x
SortIntPyramids.o 8918 9043 +1.4% 0.99x
DriverUtils.o 123504 125184 +1.4% 0.99x
ArrayAppend.o 22693 22973 +1.2% 0.99x
Prims.o 11788 11915 +1.1% 0.99x
 
Improvement OLD NEW DELTA RATIO
DictionaryLiteral.o 887 692 -22.0% 1.28x
TypeFlood.o 998 787 -21.1% 1.27x
ProtocolDispatch.o 951 756 -20.5% 1.26x
CaptureProp.o 1166 955 -18.1% 1.22x
CharacterLiteralsLarge.o 1181 986 -16.5% 1.20x
MonteCarloPi.o 1602 1391 -13.2% 1.15x
RecursiveOwnedParameter.o 1498 1303 -13.0% 1.15x
Fibonacci.o 1694 1483 -12.5% 1.14x
SuperChars.o 1681 1473 -12.4% 1.14x
Join.o 1618 1426 -11.9% 1.13x
Chars.o 1758 1550 -11.8% 1.13x
BitCount.o 1686 1491 -11.6% 1.13x
NSDictionaryCastToSwift.o 1698 1503 -11.5% 1.13x
SevenBoom.o 1841 1630 -11.5% 1.13x
NSError.o 1703 1508 -11.5% 1.13x
CharacterLiteralsSmall.o 1709 1514 -11.4% 1.13x
ByteSwap.o 1768 1573 -11.0% 1.12x
IterateData.o 1936 1725 -10.9% 1.12x
DeadArray.o 1942 1731 -10.9% 1.12x
RangeIteration.o 1676 1497 -10.7% 1.12x
Ackermann.o 2038 1830 -10.2% 1.11x
Sim2DArray.o 1333 1197 -10.2% 1.11x
PointerArithmetics.o 1806 1627 -9.9% 1.11x
ArrayLiteral.o 3154 2847 -9.7% 1.11x
ArraySetElement.o 1237 1117 -9.7% 1.11x
DevirtualizeProtocolComposition.o 2040 1848 -9.4% 1.10x
COWArrayGuaranteedParameterOverhead.o 1335 1212 -9.2% 1.10x
RandomValues.o 2678 2435 -9.1% 1.10x
ProtocolDispatch2.o 2143 1951 -9.0% 1.10x
LinkedList.o 2468 2257 -8.5% 1.09x
Integrate.o 2467 2272 -7.9% 1.09x
StackPromo.o 2129 1961 -7.9% 1.09x
XorLoop.o 2022 1864 -7.8% 1.08x
Calculator.o 2734 2523 -7.7% 1.08x
Histogram.o 2760 2549 -7.6% 1.08x
OpaqueConsumingUsers.o 2530 2351 -7.1% 1.08x
StrComplexWalk.o 2762 2567 -7.1% 1.08x
FloatingPointPrinting.o 5143 4788 -6.9% 1.07x
ObserverClosure.o 2729 2542 -6.9% 1.07x
InsertCharacter.o 4542 4235 -6.8% 1.07x
ObserverForwarderStruct.o 2928 2736 -6.6% 1.07x
Memset.o 1946 1821 -6.4% 1.07x
ArrayOfPOD.o 3318 3110 -6.3% 1.07x
ErrorHandling.o 3333 3125 -6.2% 1.07x
ObserverPartiallyAppliedMethod.o 2776 2605 -6.2% 1.07x
NopDeinit.o 4199 3943 -6.1% 1.06x
StringReplaceSubrange.o 5091 4784 -6.0% 1.06x
ExistentialPerformance.o 41696 39192 -6.0% 1.06x
ChainedFilterMap.o 3545 3334 -6.0% 1.06x
OpenClose.o 3685 3474 -5.7% 1.06x
TwoSum.o 3646 3438 -5.7% 1.06x
DictionaryBridge.o 3504 3309 -5.6% 1.06x
Hanoi.o 3141 2970 -5.4% 1.06x
StringWalk.o 34477 32621 -5.4% 1.06x
AnyHashableWithAClass.o 3648 3453 -5.3% 1.06x
NSStringConversion.o 12169 11542 -5.2% 1.05x
DictionaryBridgeToObjC.o 4471 4244 -5.1% 1.05x
Exclusivity.o 4546 4319 -5.0% 1.05x
StringBuilder.o 7902 7531 -4.7% 1.05x
DictionaryCopy.o 8095 7740 -4.4% 1.05x
ObjectAllocation.o 4493 4298 -4.3% 1.05x
SortArrayInClass.o 2842 2722 -4.2% 1.04x
NIOChannelPipeline.o 4577 4385 -4.2% 1.04x
StringMatch.o 5106 4898 -4.1% 1.04x
ClassArrayGetter.o 3504 3364 -4.0% 1.04x
RC4.o 3441 3305 -4.0% 1.04x
ObjectiveCNoBridgingStubs.o 8367 8045 -3.8% 1.04x
ArrayOfGenericPOD.o 5435 5227 -3.8% 1.04x
StrToInt.o 5242 5047 -3.7% 1.04x
DataBenchmarks.o 54243 52251 -3.7% 1.04x
ObserverUnappliedMethod.o 5233 5041 -3.7% 1.04x
StringTests.o 7598 7323 -3.6% 1.04x
StringInterpolation.o 6799 6556 -3.6% 1.04x
HTTP2StateMachine.o 5534 5339 -3.5% 1.04x
Diffing.o 8278 7987 -3.5% 1.04x
RangeReplaceableCollectionPlusDefault.o 4761 4596 -3.5% 1.04x
PopFrontGeneric.o 2709 2621 -3.2% 1.03x
Radix2CooleyTukey.o 7099 6888 -3.0% 1.03x
ReduceInto.o 9250 8978 -2.9% 1.03x
DictionaryKeysContains.o 8338 8108 -2.8% 1.03x
RangeAssignment.o 3166 3080 -2.7% 1.03x
Prefix.o 18589 18093 -2.7% 1.03x
DictionaryOfAnyHashableStrings.o 7332 7140 -2.6% 1.03x
DictTest2.o 8801 8577 -2.5% 1.03x
ArrayInClass.o 4640 4523 -2.5% 1.03x
DropWhile.o 17861 17413 -2.5% 1.03x
ObjectiveCBridgingStubs.o 14696 14336 -2.4% 1.03x
AngryPhonebook.o 9297 9073 -2.4% 1.02x
Combos.o 5274 5147 -2.4% 1.02x
DropFirst.o 18808 18360 -2.4% 1.02x
ArraySubscript.o 2793 2728 -2.3% 1.02x
SetTests.o 116583 113927 -2.3% 1.02x
RandomShuffle.o 3740 3655 -2.3% 1.02x
Substring.o 16245 15883 -2.2% 1.02x
BinaryFloatingPointProperties.o 5280 5166 -2.2% 1.02x
PopFront.o 3503 3431 -2.1% 1.02x
DictionaryRemove.o 10936 10712 -2.0% 1.02x
FloatingPointParsing.o 16792 16456 -2.0% 1.02x
CString.o 6545 6417 -2.0% 1.02x
PrefixWhile.o 16471 16151 -1.9% 1.02x
DictTest.o 12096 11872 -1.9% 1.02x
FindStringNaive.o 9097 8930 -1.8% 1.02x
StringRemoveDupes.o 4575 4495 -1.7% 1.02x
DictionaryCompactMapValues.o 12541 12330 -1.7% 1.02x
UTF8Decode.o 23195 22811 -1.7% 1.02x
DictTest3.o 13561 13337 -1.7% 1.02x
DictTest4.o 13880 13656 -1.6% 1.02x
DictionarySwap.o 16357 16101 -1.6% 1.02x
PolymorphicCalls.o 12582 12387 -1.5% 1.02x
RandomTree.o 11568 11400 -1.5% 1.01x
StringEnum.o 13234 13042 -1.5% 1.01x
StringComparison.o 35490 34978 -1.4% 1.01x
DictTest4Legacy.o 14578 14370 -1.4% 1.01x
SequenceAlgos.o 21433 21129 -1.4% 1.01x
LuhnAlgoEager.o 15256 15048 -1.4% 1.01x
LuhnAlgoLazy.o 15256 15048 -1.4% 1.01x
CharacterProperties.o 22097 21825 -1.2% 1.01x
LazyFilter.o 7882 7786 -1.2% 1.01x
ObjectiveCBridging.o 59266 58642 -1.1% 1.01x
ChaCha.o 11475 11355 -1.0% 1.01x
MonteCarloE.o 2902 2873 -1.0% 1.01x

Performance: -Onone

Regression OLD NEW DELTA RATIO
EqualSubstringSubstringGenericEquatable 27 34 +25.9% 0.79x
LessSubstringSubstringGenericComparable 27 34 +25.9% 0.79x
LessSubstringSubstring 28 35 +25.0% 0.80x
EqualSubstringSubstring 28 34 +21.4% 0.82x
EqualStringSubstring 28 34 +21.4% 0.82x (?)
EqualSubstringString 28 34 +21.4% 0.82x (?)
UTF8Decode_InitDecoding 149 173 +16.1% 0.86x (?)
UTF8Decode_InitFromCustom_contiguous 154 178 +15.6% 0.87x
AngryPhonebook.Strasse 136 150 +10.3% 0.91x (?)
COWArrayGuaranteedParameterOverhead 6050 6650 +9.9% 0.91x (?)
ArrayAppend 2680 2930 +9.3% 0.91x (?)
Data.hash.Medium 36 39 +8.3% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
StringFromLongWholeSubstring 10 9 -10.0% 1.11x (?)
UTF8Decode_InitFromBytes 181 165 -8.8% 1.10x (?)
FindString.Rec3.String 606 561 -7.4% 1.08x (?)
FindString.Rec3.Substring 617 575 -6.8% 1.07x (?)
ObjectiveCBridgeStubDateAccess 4055 3784 -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: 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

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test linux

eeckstein added 3 commits May 29, 2020 08:46
In order to fully optimize OptionSet literals, it's important that this function is inlined and fully optimized.
So far this was done by chance, but with COW representation it needs a hint to the optimizer.
… an array sub-sequence.

In the corner case of a 0 sized replacement in an empty array, we did write the 0 count back to the array singleton.
This is not a big problem right now, because it would just overwrite a 0 with a 0, but it shouldn't be done.
But with COW representation in Array, it would break the sanity checks.
This has two advantages:
1. It does not force the Array in memory (to pass it as inout self to the non-inlinable _createNewBuffer).
2. The new _consumeAndCreateNew is annotated to consume self. This helps to reduce unnecessary retains/releases.

The change applies for Array and ContiguousArray.
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

2 similar comments
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test macOS

1 similar comment
@eeckstein
Copy link
Contributor Author

@swift-ci smoke test macOS

@eeckstein
Copy link
Contributor Author

@swift-ci smoke test linux

@eeckstein eeckstein merged commit b4a202c into swiftlang:master May 29, 2020
@eeckstein eeckstein deleted the array-changes branch May 29, 2020 14:15
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.

2 participants