Skip to content

Conversation

milseman
Copy link
Member

[benchmark] Add reserveCapacity String benchmark to builder.

Add StringBuilderSmallReservingCapacity variant to measure the excess
overhead caused by calls to reserve capacity. If a string is small,
and the capacity is small, this will demonstrate overhead if an
allocation happens.


[string] Skip allocation in reserveCapacity if smol

If the requested capacity is small enough to fit in our small string
representation, don't allocate a UTF-16 buffer, instead just return
early.

@milseman
Copy link
Member Author

@swift-ci please test

@milseman
Copy link
Member Author

@swift-ci please smoke benchmark

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 97a73bda0d156a2ade5aabb471b728e0b857b890

Copy link
Member Author

Choose a reason for hiding this comment

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

Note to self: use a spell checker. "accommodate"

Copy link
Member

Choose a reason for hiding this comment

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

It allocc

but it also accommoddatt

@milseman
Copy link
Member Author

@swift-ci please test linux platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 97a73bda0d156a2ade5aabb471b728e0b857b890

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 97a73bda0d156a2ade5aabb471b728e0b857b890

@swift-ci
Copy link
Contributor

Build comment file:

Optimized (O)

Regression (14)
TEST OLD NEW DELTA SPEEDUP
ObjectiveCBridgeFromNSSetAnyObjectForced 4907 6108 +24.5% 0.80x (?)
RandomIntegersLCG 2064 2403 +16.4% 0.86x
RandomDoubleLCG 4146 4610 +11.2% 0.90x
ObjectiveCBridgeFromNSArrayAnyObjectToString 44617 48704 +9.2% 0.92x
COWTree 5375 5833 +8.5% 0.92x (?)
CharIndexing_chinese_unicodeScalars 13027 14098 +8.2% 0.92x (?)
DataReplaceSmallBuffer 11967 12875 +7.6% 0.93x (?)
CharIndexing_punctuated_unicodeScalars 3892 4166 +7.0% 0.93x (?)
StringWordBuilderReservingCapacity 1778 1903 +7.0% 0.93x
DictionaryBridge 1238 1325 +7.0% 0.93x
CStringLongNonAscii 2319 2477 +6.8% 0.94x
CStringLongAscii 4323 4615 +6.8% 0.94x (?)
EqualSubstringString 46 49 +6.5% 0.94x
NSStringConversion 708 749 +5.8% 0.95x
Improvement (10)
TEST OLD NEW DELTA SPEEDUP
DataAppendDataSmallToSmall 7599 6742 -11.3% 1.13x
ObjectiveCBridgeFromNSArrayAnyObjectForced 5323 4837 -9.1% 1.10x
DataAppendDataMediumToSmall 7507 6842 -8.9% 1.10x
DropWhileSequence 2441 2226 -8.8% 1.10x (?)
DictionaryKeysContainsNative 35 32 -8.6% 1.09x (?)
CharIndexing_ascii_unicodeScalars 18636 17187 -7.8% 1.08x (?)
ObjectiveCBridgeStubFromNSString 1146 1061 -7.4% 1.08x
SortStringsUnicode 2697 2511 -6.9% 1.07x
ObjectiveCBridgeFromNSSetAnyObjectToString 70447 65830 -6.6% 1.07x (?)
ObjectiveCBridgeFromNSDictionaryAnyObject 119886 112879 -5.8% 1.06x (?)
No Changes (411)
TEST OLD NEW DELTA SPEEDUP
AngryPhonebook 3674 3684 +0.3% 1.00x (?)
AnyHashableWithAClass 88270 88310 +0.0% 1.00x (?)
Array2D 2864 2863 -0.0% 1.00x (?)
ArrayAppend 1076 1064 -1.1% 1.01x
ArrayAppendArrayOfInt 803 809 +0.7% 0.99x (?)
ArrayAppendAscii 4012 3995 -0.4% 1.00x
ArrayAppendAsciiSubstring 46155 45999 -0.3% 1.00x (?)
ArrayAppendFromGeneric 791 810 +2.4% 0.98x (?)
ArrayAppendGenericStructs 1464 1430 -2.3% 1.02x
ArrayAppendLatin1 41470 40866 -1.5% 1.01x
ArrayAppendLatin1Substring 199129 197367 -0.9% 1.01x
ArrayAppendLazyMap 1339 1341 +0.1% 1.00x (?)
ArrayAppendOptionals 1445 1447 +0.1% 1.00x (?)
ArrayAppendRepeatCol 1346 1350 +0.3% 1.00x (?)
ArrayAppendReserved 799 799 +0.0% 1.00x
ArrayAppendSequence 1122 1122 +0.0% 1.00x
ArrayAppendStrings 6352 6232 -1.9% 1.02x
ArrayAppendToFromGeneric 800 803 +0.4% 1.00x (?)
ArrayAppendToGeneric 793 804 +1.4% 0.99x (?)
ArrayAppendUTF16 41527 40723 -1.9% 1.02x
ArrayAppendUTF16Substring 197863 199756 +1.0% 0.99x
ArrayInClass 86 86 +0.0% 1.00x
ArrayLiteral 0 0 +0.0% 1.00x
ArrayOfGenericPOD2 151 151 +0.0% 1.00x
ArrayOfGenericRef 4394 4404 +0.2% 1.00x (?)
ArrayOfPOD 184 185 +0.5% 0.99x (?)
ArrayOfRef 4354 4487 +3.1% 0.97x (?)
ArrayPlusEqualArrayOfInt 795 799 +0.5% 0.99x (?)
ArrayPlusEqualFiveElementCollection 5472 5398 -1.4% 1.01x (?)
ArrayPlusEqualSingleElementCollection 1060 1065 +0.5% 1.00x (?)
ArrayPlusEqualThreeElements 1650 1652 +0.1% 1.00x (?)
ArraySubscript 1528 1527 -0.1% 1.00x (?)
ArrayValueProp 8 8 +0.0% 1.00x
ArrayValueProp2 8 8 +0.0% 1.00x
ArrayValueProp3 8 8 +0.0% 1.00x
ArrayValueProp4 8 8 +0.0% 1.00x
BinaryFloatingPointPropertiesBinade 31 31 +0.0% 1.00x
BinaryFloatingPointPropertiesNextUp 28 28 +0.0% 1.00x
BinaryFloatingPointPropertiesUlp 37 37 +0.0% 1.00x
BitCount 211 212 +0.5% 1.00x
ByteSwap 104 105 +1.0% 0.99x
CSVParsing 700332 699375 -0.1% 1.00x (?)
CSVParsingAlt 791855 789216 -0.3% 1.00x (?)
CSVParsingAltIndices 342603 344586 +0.6% 0.99x
CStringShortAscii 3473 3457 -0.5% 1.00x (?)
Calculator 1206 1223 +1.4% 0.99x
CaptureProp 4055 4059 +0.1% 1.00x (?)
ChainedFilterMap 1410 1410 +0.0% 1.00x
CharIndexing_ascii_unicodeScalars_Backwards 16227 16244 +0.1% 1.00x (?)
CharIndexing_chinese_unicodeScalars_Backwards 12296 12303 +0.1% 1.00x (?)
CharIndexing_japanese_unicodeScalars 22329 22329 +0.0% 1.00x
CharIndexing_japanese_unicodeScalars_Backwards 19437 19442 +0.0% 1.00x (?)
CharIndexing_korean_unicodeScalars 18072 18072 +0.0% 1.00x
CharIndexing_korean_unicodeScalars_Backwards 15750 15752 +0.0% 1.00x (?)
CharIndexing_punctuatedJapanese_unicodeScalars 3315 3316 +0.0% 1.00x
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 3191 3187 -0.1% 1.00x
CharIndexing_punctuated_unicodeScalars_Backwards 4006 4006 +0.0% 1.00x
CharIndexing_russian_unicodeScalars 15525 15518 -0.0% 1.00x (?)
CharIndexing_russian_unicodeScalars_Backwards 13537 13536 -0.0% 1.00x (?)
CharIndexing_tweet_unicodeScalars 36870 36838 -0.1% 1.00x
CharIndexing_tweet_unicodeScalars_Backwards 31724 31720 -0.0% 1.00x (?)
CharIndexing_utf16_unicodeScalars 26943 27007 +0.2% 1.00x
CharIndexing_utf16_unicodeScalars_Backwards 23322 23521 +0.9% 0.99x
CharIteration_ascii_unicodeScalars 21219 21489 +1.3% 0.99x
CharIteration_ascii_unicodeScalars_Backwards 15581 15589 +0.1% 1.00x
CharIteration_chinese_unicodeScalars 16070 16269 +1.2% 0.99x
CharIteration_chinese_unicodeScalars_Backwards 11804 11799 -0.0% 1.00x (?)
CharIteration_japanese_unicodeScalars 25420 25737 +1.2% 0.99x
CharIteration_japanese_unicodeScalars_Backwards 18656 18660 +0.0% 1.00x (?)
CharIteration_korean_unicodeScalars 20570 20843 +1.3% 0.99x
CharIteration_korean_unicodeScalars_Backwards 15108 15111 +0.0% 1.00x (?)
CharIteration_punctuatedJapanese_unicodeScalars 3829 3847 +0.5% 1.00x
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 2824 2825 +0.0% 1.00x
CharIteration_punctuated_unicodeScalars 4793 4828 +0.7% 0.99x
CharIteration_punctuated_unicodeScalars_Backwards 3533 3533 +0.0% 1.00x
CharIteration_russian_unicodeScalars 17690 17914 +1.3% 0.99x
CharIteration_russian_unicodeScalars_Backwards 12989 12984 -0.0% 1.00x (?)
CharIteration_tweet_unicodeScalars 42515 42421 -0.2% 1.00x
CharIteration_tweet_unicodeScalars_Backwards 30760 30776 +0.1% 1.00x (?)
CharIteration_utf16_unicodeScalars 28029 28030 +0.0% 1.00x (?)
CharIteration_utf16_unicodeScalars_Backwards 19174 19516 +1.8% 0.98x
CharacterLiteralsLarge 5988 5901 -1.5% 1.01x
CharacterLiteralsSmall 220 220 +0.0% 1.00x
CharacterPropertiesFetch 4564 4563 -0.0% 1.00x (?)
CharacterPropertiesPrecomputed 1166 1152 -1.2% 1.01x
CharacterPropertiesStashed 1487 1461 -1.7% 1.02x
CharacterPropertiesStashedMemo 1577 1581 +0.3% 1.00x (?)
Chars 1218 1216 -0.2% 1.00x (?)
ClassArrayGetter 15 15 +0.0% 1.00x
Combos 490 491 +0.2% 1.00x (?)
DataAccessBytes 1189 1188 -0.1% 1.00x (?)
DataAppendArray 6190 6176 -0.2% 1.00x (?)
DataAppendBytes 5926 5918 -0.1% 1.00x (?)
DataAppendDataLargeToLarge 69377 68827 -0.8% 1.01x (?)
DataAppendDataLargeToMedium 36560 36447 -0.3% 1.00x (?)
DataAppendDataLargeToSmall 35754 35820 +0.2% 1.00x (?)
DataAppendDataMediumToLarge 39728 39193 -1.3% 1.01x (?)
DataAppendDataMediumToMedium 8007 7780 -2.8% 1.03x
DataAppendDataSmallToLarge 38112 38640 +1.4% 0.99x (?)
DataAppendDataSmallToMedium 7645 7412 -3.0% 1.03x (?)
DataAppendSequence 21346 21300 -0.2% 1.00x (?)
DataCopyBytes 2511 2504 -0.3% 1.00x (?)
DataCount 37 37 +0.0% 1.00x
DataMutateBytes 4199 4282 +2.0% 0.98x (?)
DataReplaceLarge 42287 41429 -2.0% 1.02x
DataReplaceLargeBuffer 60465 61627 +1.9% 0.98x (?)
DataReplaceMedium 13659 13281 -2.8% 1.03x (?)
DataReplaceMediumBuffer 16186 16521 +2.1% 0.98x (?)
DataReplaceSmall 9399 9335 -0.7% 1.01x (?)
DataReset 3221 3198 -0.7% 1.01x (?)
DataSetCount 913 906 -0.8% 1.01x
DataSubscript 244 241 -1.2% 1.01x
DictOfArraysToArrayOfDicts 823 820 -0.4% 1.00x (?)
Dictionary 685 693 +1.2% 0.99x
Dictionary2 809 816 +0.9% 0.99x
Dictionary2OfObjects 2252 2251 -0.0% 1.00x (?)
Dictionary3 256 255 -0.4% 1.00x
Dictionary3OfObjects 769 775 +0.8% 0.99x
Dictionary4 326 331 +1.5% 0.98x
Dictionary4Legacy 729 734 +0.7% 0.99x (?)
Dictionary4OfObjects 443 446 +0.7% 0.99x
Dictionary4OfObjectsLegacy 941 936 -0.5% 1.01x
DictionaryCopy 107442 108601 +1.1% 0.99x
DictionaryFilter 112555 112340 -0.2% 1.00x (?)
DictionaryGroup 216 216 +0.0% 1.00x
DictionaryGroupOfObjects 2135 2143 +0.4% 1.00x (?)
DictionaryKeysContainsCocoa 38 39 +2.6% 0.97x (?)
DictionaryLiteral 1928 1920 -0.4% 1.00x (?)
DictionaryOfObjects 2531 2539 +0.3% 1.00x
DictionaryRemove 4529 4520 -0.2% 1.00x (?)
DictionaryRemoveOfObjects 27039 26808 -0.9% 1.01x
DictionarySubscriptDefaultMutation 288 286 -0.7% 1.01x
DictionarySubscriptDefaultMutationArray 637 621 -2.5% 1.03x (?)
DictionarySubscriptDefaultMutationArrayOfObjects 4024 4074 +1.2% 0.99x (?)
DictionarySubscriptDefaultMutationOfObjects 1765 1764 -0.1% 1.00x (?)
DictionarySwap 1048 1040 -0.8% 1.01x
DictionarySwapAt 6972 6710 -3.8% 1.04x
DictionarySwapAtOfObjects 52177 52136 -0.1% 1.00x (?)
DictionarySwapOfObjects 8843 8864 +0.2% 1.00x (?)
DoubleWidthDivision 0 0 +0.0% 1.00x
DropFirstAnyCollection 83 84 +1.2% 0.99x
DropFirstAnyCollectionLazy 65497 63659 -2.8% 1.03x (?)
DropFirstAnySeqCRangeIter 21531 21769 +1.1% 0.99x
DropFirstAnySeqCRangeIterLazy 21490 21773 +1.3% 0.99x
DropFirstAnySeqCntRange 41 41 +0.0% 1.00x
DropFirstAnySeqCntRangeLazy 41 41 +0.0% 1.00x
DropFirstAnySequence 4967 4991 +0.5% 1.00x
DropFirstAnySequenceLazy 4965 5006 +0.8% 0.99x
DropFirstArray 35 35 +0.0% 1.00x
DropFirstArrayLazy 35 35 +0.0% 1.00x
DropFirstCountableRange 35 35 +0.0% 1.00x
DropFirstCountableRangeLazy 35 35 +0.0% 1.00x
DropFirstSequence 2739 2740 +0.0% 1.00x (?)
DropFirstSequenceLazy 2788 2787 -0.0% 1.00x (?)
DropLastAnyCollection 31 31 +0.0% 1.00x
DropLastAnyCollectionLazy 21326 21316 -0.0% 1.00x (?)
DropLastAnySeqCRangeIter 3627 3644 +0.5% 1.00x (?)
DropLastAnySeqCRangeIterLazy 3623 3641 +0.5% 1.00x
DropLastAnySeqCntRange 13 13 +0.0% 1.00x
DropLastAnySeqCntRangeLazy 13 13 +0.0% 1.00x
DropLastAnySequence 5051 5040 -0.2% 1.00x (?)
DropLastAnySequenceLazy 5141 5148 +0.1% 1.00x (?)
DropLastCountableRange 11 11 +0.0% 1.00x
DropLastCountableRangeLazy 12 12 +0.0% 1.00x
DropLastSequence 629 634 +0.8% 0.99x (?)
DropLastSequenceLazy 627 632 +0.8% 0.99x
DropWhileAnyCollection 107 107 +0.0% 1.00x
DropWhileAnyCollectionLazy 126 125 -0.8% 1.01x
DropWhileAnySeqCRangeIter 17015 17258 +1.4% 0.99x
DropWhileAnySeqCRangeIterLazy 126 126 +0.0% 1.00x
DropWhileAnySeqCntRange 51 50 -2.0% 1.02x
DropWhileAnySeqCntRangeLazy 126 126 +0.0% 1.00x
DropWhileAnySequence 4850 4842 -0.2% 1.00x
DropWhileAnySequenceLazy 1859 1859 +0.0% 1.00x
DropWhileArrayLazy 88 88 +0.0% 1.00x
DropWhileCountableRange 36 36 +0.0% 1.00x
DropWhileCountableRangeLazy 105 105 +0.0% 1.00x
DropWhileSequenceLazy 88 88 +0.0% 1.00x
EqualStringSubstring 49 48 -2.0% 1.02x
EqualSubstringSubstring 48 48 +0.0% 1.00x
EqualSubstringSubstringGenericEquatable 48 48 +0.0% 1.00x
ErrorHandling 1599 1609 +0.6% 0.99x (?)
ExclusivityGlobal 5 5 +0.0% 1.00x
ExclusivityIndependent 2 2 +0.0% 1.00x
FatCompactMap 207123 206030 -0.5% 1.01x (?)
FilterEvenUsingReduce 1316 1308 -0.6% 1.01x (?)
FilterEvenUsingReduceInto 151 151 +0.0% 1.00x
FloatingPointPrinting_Double_description_small 23780 23997 +0.9% 0.99x (?)
FloatingPointPrinting_Double_description_uniform 23543 23672 +0.5% 0.99x (?)
FloatingPointPrinting_Double_interpolated 67712 67622 -0.1% 1.00x (?)
FloatingPointPrinting_Float80_description_small 31139 31158 +0.1% 1.00x (?)
FloatingPointPrinting_Float80_description_uniform 30189 30383 +0.6% 0.99x (?)
FloatingPointPrinting_Float80_interpolated 71404 71079 -0.5% 1.00x (?)
FloatingPointPrinting_Float_description_small 5539 5520 -0.3% 1.00x
FloatingPointPrinting_Float_description_uniform 5095 5129 +0.7% 0.99x
FloatingPointPrinting_Float_interpolated 42253 42057 -0.5% 1.00x (?)
FrequenciesUsingReduce 5092 5019 -1.4% 1.01x (?)
FrequenciesUsingReduceInto 1562 1599 +2.4% 0.98x (?)
Hanoi 2265 2240 -1.1% 1.01x
HashTest 1055 1065 +0.9% 0.99x (?)
Histogram 709 713 +0.6% 0.99x
Integrate 340 337 -0.9% 1.01x
IterateData 1838 1834 -0.2% 1.00x (?)
Join 163 166 +1.8% 0.98x
LazilyFilteredArrayContains 36718 35575 -3.1% 1.03x
LazilyFilteredArrays 67586 65503 -3.1% 1.03x (?)
LazilyFilteredRange 3874 3882 +0.2% 1.00x
LessSubstringSubstring 49 48 -2.0% 1.02x
LessSubstringSubstringGenericComparable 49 48 -2.0% 1.02x
LinkedList 7532 7545 +0.2% 1.00x
LuhnAlgoEager 325 324 -0.3% 1.00x (?)
LuhnAlgoLazy 323 318 -1.5% 1.02x
MapReduce 401 404 +0.7% 0.99x (?)
MapReduceAnyCollection 402 402 +0.0% 1.00x
MapReduceAnyCollectionShort 2325 2299 -1.1% 1.01x (?)
MapReduceClass 3033 3037 +0.1% 1.00x (?)
MapReduceClassShort 4584 4651 +1.5% 0.99x (?)
MapReduceLazyCollection 13 13 +0.0% 1.00x
MapReduceLazyCollectionShort 34 34 +0.0% 1.00x
MapReduceLazySequence 86 86 +0.0% 1.00x
MapReduceSequence 456 451 -1.1% 1.01x (?)
MapReduceShort 2077 2063 -0.7% 1.01x
MapReduceShortString 23 23 +0.0% 1.00x
MapReduceString 83 84 +1.2% 0.99x
Memset 219 217 -0.9% 1.01x (?)
MonteCarloE 10181 10183 +0.0% 1.00x (?)
MonteCarloPi 42782 42779 -0.0% 1.00x (?)
NSDictionaryCastToSwift 7608 7408 -2.6% 1.03x (?)
NSError 174 174 +0.0% 1.00x
NibbleSort 3701 3702 +0.0% 1.00x
NopDeinit 30210 30194 -0.1% 1.00x
ObjectAllocation 133 132 -0.8% 1.01x (?)
ObjectiveCBridgeFromNSArrayAnyObject 25283 26512 +4.9% 0.95x
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 43205 45348 +5.0% 0.95x (?)
ObjectiveCBridgeFromNSSetAnyObject 52200 53215 +1.9% 0.98x (?)
ObjectiveCBridgeFromNSString 1188 1228 +3.4% 0.97x (?)
ObjectiveCBridgeFromNSStringForced 2649 2664 +0.6% 0.99x
ObjectiveCBridgeStubDataAppend 11432 11404 -0.2% 1.00x (?)
ObjectiveCBridgeStubDateMutation 401 401 +0.0% 1.00x
ObjectiveCBridgeStubFromArrayOfNSString 34922 36645 +4.9% 0.95x (?)
ObjectiveCBridgeStubFromNSDate 7468 7446 -0.3% 1.00x (?)
ObjectiveCBridgeStubFromNSStringRef 182 174 -4.4% 1.05x
ObjectiveCBridgeStubNSDataAppend 2525 2506 -0.8% 1.01x (?)
ObjectiveCBridgeStubNSDateMutationRef 13621 13508 -0.8% 1.01x (?)
ObjectiveCBridgeStubToArrayOfNSString 40006 40553 +1.4% 0.99x (?)
ObjectiveCBridgeStubToNSDate 16060 15600 -2.9% 1.03x (?)
ObjectiveCBridgeStubToNSDateRef 3452 3476 +0.7% 0.99x (?)
ObjectiveCBridgeStubToNSString 2391 2394 +0.1% 1.00x (?)
ObjectiveCBridgeStubToNSStringRef 124 125 +0.8% 0.99x
ObjectiveCBridgeStubURLAppendPath 293570 291602 -0.7% 1.01x (?)
ObjectiveCBridgeStubURLAppendPathRef 289701 287746 -0.7% 1.01x (?)
ObjectiveCBridgeToNSArray 15747 15125 -3.9% 1.04x
ObjectiveCBridgeToNSDictionary 27456 26696 -2.8% 1.03x
ObjectiveCBridgeToNSSet 17089 16603 -2.8% 1.03x (?)
ObjectiveCBridgeToNSString 507 496 -2.2% 1.02x
ObserverClosure 2169 2165 -0.2% 1.00x (?)
ObserverForwarderStruct 1257 1260 +0.2% 1.00x (?)
ObserverPartiallyAppliedMethod 3746 3767 +0.6% 0.99x (?)
ObserverUnappliedMethod 2636 2606 -1.1% 1.01x (?)
OpenClose 353 344 -2.5% 1.03x (?)
PartialApplyDynamicType 0 0 +0.0% 1.00x
Phonebook 4662 4816 +3.3% 0.97x
PointerArithmetics 34385 34404 +0.1% 1.00x (?)
PolymorphicCalls 25 25 +0.0% 1.00x
PopFrontArray 1975 1966 -0.5% 1.00x (?)
PopFrontArrayGeneric 1975 1973 -0.1% 1.00x (?)
PopFrontUnsafePointer 8746 8854 +1.2% 0.99x (?)
PrefixAnyCollection 84 84 +0.0% 1.00x
PrefixAnyCollectionLazy 64266 63622 -1.0% 1.01x (?)
PrefixAnySeqCRangeIter 16709 16931 +1.3% 0.99x
PrefixAnySeqCRangeIterLazy 16792 16927 +0.8% 0.99x
PrefixAnySeqCntRange 28 28 +0.0% 1.00x
PrefixAnySeqCntRangeLazy 28 28 +0.0% 1.00x
PrefixAnySequence 4341 4319 -0.5% 1.01x (?)
PrefixAnySequenceLazy 4340 4316 -0.6% 1.01x (?)
PrefixArray 35 35 +0.0% 1.00x
PrefixArrayLazy 35 35 +0.0% 1.00x
PrefixCountableRange 35 35 +0.0% 1.00x
PrefixCountableRangeLazy 35 35 +0.0% 1.00x
PrefixSequence 2296 2289 -0.3% 1.00x (?)
PrefixSequenceLazy 2278 2344 +2.9% 0.97x (?)
PrefixWhileAnyCollection 154 154 +0.0% 1.00x
PrefixWhileAnyCollectionLazy 90 90 +0.0% 1.00x
PrefixWhileAnySeqCRangeIter 9120 9035 -0.9% 1.01x (?)
PrefixWhileAnySeqCRangeIterLazy 73 73 +0.0% 1.00x
PrefixWhileAnySeqCntRange 60 60 +0.0% 1.00x
PrefixWhileAnySeqCntRangeLazy 90 90 +0.0% 1.00x
PrefixWhileAnySequence 10172 10196 +0.2% 1.00x
PrefixWhileAnySequenceLazy 1395 1395 +0.0% 1.00x
PrefixWhileArray 88 88 +0.0% 1.00x
PrefixWhileArrayLazy 71 70 -1.4% 1.01x
PrefixWhileCountableRange 36 36 +0.0% 1.00x
PrefixWhileCountableRangeLazy 35 35 +0.0% 1.00x
PrefixWhileSequence 362 363 +0.3% 1.00x
PrefixWhileSequenceLazy 52 52 +0.0% 1.00x
Prims 907 913 +0.7% 0.99x (?)
PrimsSplit 914 923 +1.0% 0.99x (?)
QueueConcrete 1148 1148 +0.0% 1.00x
QueueGeneric 1147 1148 +0.1% 1.00x (?)
RC4 161 161 +0.0% 1.00x
RGBHistogram 3254 3243 -0.3% 1.00x (?)
RGBHistogramOfObjects 23842 23865 +0.1% 1.00x (?)
RandomDoubleDef 27956 28060 +0.4% 1.00x (?)
RandomIntegersDef 25550 25623 +0.3% 1.00x (?)
RandomShuffleDef 829534 831641 +0.3% 1.00x (?)
RandomShuffleLCG 150119 151711 +1.1% 0.99x (?)
RangeAssignment 353 352 -0.3% 1.00x (?)
RangeIterationSigned 200 200 +0.0% 1.00x
RangeReplaceableCollectionPlusDefault 1026 1014 -1.2% 1.01x
RecursiveOwnedParameter 115 115 +0.0% 1.00x
RemoveWhereFilterInts 47 47 +0.0% 1.00x
RemoveWhereFilterString 242 252 +4.1% 0.96x
RemoveWhereFilterStrings 438 437 -0.2% 1.00x (?)
RemoveWhereMoveInts 15 15 +0.0% 1.00x
RemoveWhereMoveStrings 720 721 +0.1% 1.00x (?)
RemoveWhereQuadraticInts 1298 1300 +0.2% 1.00x (?)
RemoveWhereQuadraticString 383 382 -0.3% 1.00x (?)
RemoveWhereQuadraticStrings 2764 2764 +0.0% 1.00x
RemoveWhereSwapInts 20 21 +5.0% 0.95x
RemoveWhereSwapStrings 951 950 -0.1% 1.00x
ReversedArray 58 58 +0.0% 1.00x
ReversedBidirectional 17185 16834 -2.0% 1.02x (?)
ReversedDictionary 269 267 -0.7% 1.01x (?)
RomanNumbers 86465 85930 -0.6% 1.01x
SequenceAlgosAnySequence 12056 12147 +0.8% 0.99x
SequenceAlgosArray 1566 1579 +0.8% 0.99x (?)
SequenceAlgosContiguousArray 1582 1581 -0.1% 1.00x (?)
SequenceAlgosList 1351 1351 +0.0% 1.00x
SequenceAlgosRange 2580 2580 +0.0% 1.00x
SequenceAlgosUnfoldSequence 1103 1104 +0.1% 1.00x
SetExclusiveOr 5209 5129 -1.5% 1.02x
SetExclusiveOr_OfObjects 11740 11901 +1.4% 0.99x (?)
SetIntersect 699 697 -0.3% 1.00x (?)
SetIntersect_OfObjects 1745 1748 +0.2% 1.00x (?)
SetIsSubsetOf 355 355 +0.0% 1.00x
SetIsSubsetOf_OfObjects 451 474 +5.1% 0.95x
SetUnion 4502 4467 -0.8% 1.01x (?)
SetUnion_OfObjects 10115 10321 +2.0% 0.98x
SevenBoom 908 909 +0.1% 1.00x (?)
Sim2DArray 600 600 +0.0% 1.00x
SortLargeExistentials 6129 6074 -0.9% 1.01x
SortLettersInPlace 1064 1067 +0.3% 1.00x (?)
SortSortedStrings 1081 1062 -1.8% 1.02x
SortStrings 2071 2061 -0.5% 1.00x
StackPromo 25284 25365 +0.3% 1.00x (?)
StaticArray 10 10 +0.0% 1.00x
StrComplexWalk 1795 1794 -0.1% 1.00x
StrToInt 3309 3223 -2.6% 1.03x
StringAdder 826 822 -0.5% 1.00x
StringBuilder 735 761 +3.5% 0.97x
StringBuilderLong 1281 1247 -2.7% 1.03x (?)
StringBuilderWithLongSubstring 1464 1467 +0.2% 1.00x (?)
StringComparison_abnormal 776 772 -0.5% 1.01x (?)
StringComparison_ascii 1299 1313 +1.1% 0.99x
StringComparison_emoji 812 824 +1.5% 0.99x
StringComparison_fastPrenormal 835 809 -3.1% 1.03x
StringComparison_latin1 651 632 -2.9% 1.03x
StringComparison_longSharedPrefix 943 935 -0.8% 1.01x
StringComparison_nonBMPSlowestPrenormal 1610 1604 -0.4% 1.00x (?)
StringComparison_slowerPrenormal 1724 1715 -0.5% 1.01x (?)
StringComparison_zalgo 124720 124958 +0.2% 1.00x (?)
StringEdits 170365 167206 -1.9% 1.02x (?)
StringEnumRawValueInitialization 935 945 +1.1% 0.99x
StringEqualPointerComparison 294 293 -0.3% 1.00x (?)
StringFromLongWholeSubstring 21 21 +0.0% 1.00x
StringFromLongWholeSubstringGeneric 22 22 +0.0% 1.00x
StringHasPrefixAscii 2265 2293 +1.2% 0.99x
StringHasPrefixUnicode 102152 102516 +0.4% 1.00x (?)
StringHasSuffixAscii 2379 2436 +2.4% 0.98x
StringHasSuffixUnicode 101494 101389 -0.1% 1.00x (?)
StringInterpolation 10169 9945 -2.2% 1.02x (?)
StringInterpolationManySmallSegments 20824 20511 -1.5% 1.02x
StringInterpolationSmall 6047 5954 -1.5% 1.02x
StringMatch 12315 12564 +2.0% 0.98x
StringRemoveDupes 512 520 +1.6% 0.98x (?)
StringUTF16Builder 2680 2693 +0.5% 1.00x (?)
StringUTF16SubstringBuilder 5972 5966 -0.1% 1.00x (?)
StringWalk 1443 1437 -0.4% 1.00x
StringWithCString 44892 44882 -0.0% 1.00x (?)
StringWordBuilder 2500 2591 +3.6% 0.96x
SubstringComparable 26 27 +3.8% 0.96x (?)
SubstringEqualString 627 620 -1.1% 1.01x
SubstringEquatable 1404 1429 +1.8% 0.98x
SubstringFromLongString 10 10 +0.0% 1.00x
SubstringFromLongStringGeneric 75 75 +0.0% 1.00x
SuffixAnyCollection 31 31 +0.0% 1.00x
SuffixAnyCollectionLazy 21248 21210 -0.2% 1.00x (?)
SuffixAnySeqCRangeIter 3852 3871 +0.5% 1.00x (?)
SuffixAnySeqCRangeIterLazy 3866 3869 +0.1% 1.00x (?)
SuffixAnySeqCntRange 20 20 +0.0% 1.00x
SuffixAnySeqCntRangeLazy 20 20 +0.0% 1.00x
SuffixAnySequence 5030 5032 +0.0% 1.00x (?)
SuffixAnySequenceLazy 5117 5137 +0.4% 1.00x
SuffixCountableRange 12 12 +0.0% 1.00x
SuffixCountableRangeLazy 11 11 +0.0% 1.00x
SuffixSequence 3737 3810 +2.0% 0.98x (?)
SuffixSequenceLazy 3749 3776 +0.7% 0.99x
SumUsingReduce 97 97 +0.0% 1.00x
SumUsingReduceInto 102 102 +0.0% 1.00x
SuperChars 14785 14758 -0.2% 1.00x (?)
TwoSum 1470 1490 +1.4% 0.99x (?)
TypeFlood 0 0 +0.0% 1.00x
UTF8Decode 304 304 +0.0% 1.00x
Walsh 434 443 +2.1% 0.98x
WordCountHistogramASCII 7753 7774 +0.3% 1.00x
WordCountHistogramUTF16 14670 14506 -1.1% 1.01x (?)
WordCountUniqueASCII 2168 2157 -0.5% 1.01x (?)
WordCountUniqueUTF16 7965 7912 -0.7% 1.01x (?)
WordSplitASCII 7058 6730 -4.6% 1.05x
WordSplitUTF16 8630 8749 +1.4% 0.99x (?)
XorLoop 403 399 -1.0% 1.01x (?)
Added (1)
TEST MIN MAX MEAN MAX_RSS
StringBuilderSmallReservingCapacity 786 787 786 7745536
Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

milseman added 2 commits May 18, 2018 19:25
Add StringBuilderSmallReservingCapacity variant to measure the excess
overhead caused by calls to reserve capacity. If a string is small,
and the capacity is small, this will demonstrate overhead if an
allocation happens.
If the requested capacity is small enough to fit in our small string
representation, don't allocate a UTF-16 buffer, instead just return
early.
@milseman milseman force-pushed the smol_reservations branch from 97a73bd to 1fe5fb7 Compare May 19, 2018 04:31
@milseman
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 97a73bda0d156a2ade5aabb471b728e0b857b890

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 97a73bda0d156a2ade5aabb471b728e0b857b890

@milseman milseman merged commit ee899f0 into swiftlang:master May 19, 2018
@milseman milseman deleted the smol_reservations branch May 19, 2018 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants