Skip to content

stdlib: move Dictionary's find functions into __RawDictionaryStorage. #29353

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 1 commit into from
Jan 24, 2020

Conversation

eeckstein
Copy link
Contributor

The find functions do not require the generic Value parameter. Moving them to __RawDictionaryStorage allows to define them with only one generic parameter: the Key.
This allows the optimizer to share specializations for dictionaries which have the same Key, but a different Value.
Also, prevent inlining of the find-functions to save some additional code size.

The find functions do not require the generic Value parameter. Moving them to __RawDictionaryStorage allows to define them with only one generic parameter: the Key.
This allows the optimizer to share specializations for dictionaries which have the same Key, but a different Value.
Also, prevent inlining of the find-functions to save some additional code size.
@eeckstein eeckstein requested a review from lorentey January 22, 2020 14:30
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci benchmark

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
Dictionary4OfObjects 307 411 +33.9% 0.75x
DictionarySwap 1040 1284 +23.5% 0.81x
DictionarySwapOfObjects 7920 9360 +18.2% 0.85x
ObjectiveCBridgeStringHash 68 78 +14.7% 0.87x (?)
Prims.NonStrongRef.Unmanaged 215 244 +13.5% 0.88x
Prims.NonStrongRef.UnownedUnsafe 263 298 +13.3% 0.88x (?)
DictionarySwapAtOfObjects 7161 8019 +12.0% 0.89x
DictionarySubscriptDefaultMutationOfObjects 1540 1720 +11.7% 0.90x (?)
ObjectiveCBridgeStubFromArrayOfNSString2 3290 3670 +11.6% 0.90x (?)
Histogram 478 529 +10.7% 0.90x
WordCountHistogramASCII 3800 4200 +10.5% 0.90x (?)
WordCountHistogramUTF16 4300 4700 +9.3% 0.91x
DictionaryGroupOfObjects 1728 1872 +8.3% 0.92x
RemoveWhereSwapInts 62 67 +8.1% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
LazilyFilteredArrayContains 35600 29500 -17.1% 1.21x
ArrayAppendLazyMap 7210 6300 -12.6% 1.14x (?)
FloatingPointPrinting_Float_description_uniform 6200 5600 -9.7% 1.11x
StringUTF16Builder 370 340 -8.1% 1.09x (?)
StringBuilderSmallReservingCapacity 361 335 -7.2% 1.08x (?)
EqualSubstringSubstring 42 39 -7.1% 1.08x (?)
LessSubstringSubstring 42 39 -7.1% 1.08x (?)
EqualSubstringSubstringGenericEquatable 42 39 -7.1% 1.08x (?)
EqualSubstringString 42 39 -7.1% 1.08x (?)
LessSubstringSubstringGenericComparable 42 39 -7.1% 1.08x
EqualStringSubstring 43 40 -7.0% 1.07x (?)
StringBuilder 344 321 -6.7% 1.07x (?)
DictionarySwapAt 1080 1008 -6.7% 1.07x (?)

Code size: -O

Regression OLD NEW DELTA RATIO
DictionaryLiteral.o 1173 1310 +11.7% 0.90x
DictionaryCopy.o 10454 11350 +8.6% 0.92x
DictionaryOfAnyHashableStrings.o 9071 9650 +6.4% 0.94x
DictionaryBridgeToObjC.o 5015 5255 +4.8% 0.95x
DictionarySwap.o 20925 21421 +2.4% 0.98x
Hash.o 22990 23230 +1.0% 0.99x
 
Improvement OLD NEW DELTA RATIO
DictionaryGroup.o 14195 11611 -18.2% 1.22x
DictTest4.o 21842 18170 -16.8% 1.20x
DictTest4Legacy.o 22756 18972 -16.6% 1.20x
DictionaryKeysContains.o 9689 8185 -15.5% 1.18x
DictionaryCompactMapValues.o 17441 15185 -12.9% 1.15x
DictTest3.o 20973 18445 -12.1% 1.14x
DictTest.o 18700 16588 -11.3% 1.13x
DictionaryRemove.o 15528 13976 -10.0% 1.11x
DictTest2.o 14333 13341 -6.9% 1.07x
PrimsNonStrongRef.o 92495 86887 -6.1% 1.06x
DictionarySubscriptDefault.o 24699 23299 -5.7% 1.06x
Histogram.o 3918 3742 -4.5% 1.05x
Prims.o 13275 12739 -4.0% 1.04x
PrimsSplit.o 13327 12791 -4.0% 1.04x
TwoSum.o 5160 4968 -3.7% 1.04x
RGBHistogram.o 24253 23365 -3.7% 1.04x
StringRemoveDupes.o 6342 6150 -3.0% 1.03x
WordCount.o 39913 38769 -2.9% 1.03x
ReduceInto.o 14810 14596 -1.4% 1.01x
DictOfArraysToArrayOfDicts.o 20432 20144 -1.4% 1.01x

Performance: -Osize

Regression OLD NEW DELTA RATIO
DictionarySwap 1112 1288 +15.8% 0.86x
StringRemoveDupes 357 412 +15.4% 0.87x
ObjectiveCBridgeStringHash 68 78 +14.7% 0.87x (?)
Dictionary4OfObjects 462 528 +14.3% 0.88x
Prims.NonStrongRef.UnownedSafe 699 793 +13.4% 0.88x (?)
CharacterLiteralsLarge 100 111 +11.0% 0.90x
FlattenListLoop 4025 4448 +10.5% 0.90x (?)
Prims.NonStrongRef.UnownedUnsafe 289 319 +10.4% 0.91x (?)
WordCountHistogramASCII 4000 4400 +10.0% 0.91x (?)
WordCountHistogramUTF16 4500 4900 +8.9% 0.92x (?)
RemoveWhereSwapInts 60 65 +8.3% 0.92x (?)
ArrayPlusEqualFiveElementCollection 7696 8325 +8.2% 0.92x (?)
RemoveWhereMoveInts 37 40 +8.1% 0.93x (?)
FloatingPointPrinting_Float_description_small 5508 5940 +7.8% 0.93x (?)
Array2D 6992 7520 +7.6% 0.93x
 
Improvement OLD NEW DELTA RATIO
Dict.CopyKeyValue.28k 3263 1868 -42.8% 1.75x
Dict.CopyKeyValue.16k 1679 969 -42.3% 1.73x
Dict.CopyKeyValue.20k 1839 1081 -41.2% 1.70x
Dict.CopyKeyValue.24k 2047 1216 -40.6% 1.68x
TwoSum 1530 1144 -25.2% 1.34x
RGBHistogram 2910 2250 -22.7% 1.29x
ArrayAppendLazyMap 8130 6990 -14.0% 1.16x (?)
FrequenciesUsingReduceInto 1052 913 -13.2% 1.15x (?)
DictionaryOfAnyHashableStrings_insert 5264 4760 -9.6% 1.11x (?)
DictionarySubscriptDefaultMutation 369 335 -9.2% 1.10x (?)
Dictionary 620 565 -8.9% 1.10x
PrefixAnySequenceLazy 1723 1581 -8.2% 1.09x (?)
Dictionary2 985 905 -8.1% 1.09x
Dictionary2OfObjects 2540 2335 -8.1% 1.09x (?)
DictionarySwapAt 1100 1016 -7.6% 1.08x (?)
EqualSubstringSubstring 43 40 -7.0% 1.07x
LessSubstringSubstring 43 40 -7.0% 1.07x
EqualStringSubstring 43 40 -7.0% 1.07x (?)
EqualSubstringSubstringGenericEquatable 43 40 -7.0% 1.07x (?)
LessSubstringSubstringGenericComparable 43 40 -7.0% 1.07x (?)
StringBuilderSmallReservingCapacity 348 325 -6.6% 1.07x (?)

Code size: -Osize

Regression OLD NEW DELTA RATIO
Histogram.o 1782 2549 +43.0% 0.70x
DictionaryOfAnyHashableStrings.o 6311 7976 +26.4% 0.79x
TwoSum.o 2918 3505 +20.1% 0.83x
DictionaryCopy.o 7506 9010 +20.0% 0.83x
DictionarySubscriptDefault.o 15199 17523 +15.3% 0.87x
ReduceInto.o 8290 9398 +13.4% 0.88x
DictTest.o 11708 13216 +12.9% 0.89x
DictTest3.o 13181 14817 +12.4% 0.89x
DictionaryCompactMapValues.o 12743 14319 +12.4% 0.89x
ReversedCollections.o 7285 8105 +11.3% 0.90x
DictionarySwap.o 16397 18085 +10.3% 0.91x
DictionaryGroup.o 10035 11059 +10.2% 0.91x
DictionaryKeysContains.o 7415 8081 +9.0% 0.92x
DictTest2.o 9037 9769 +8.1% 0.93x
Prims.o 10619 11211 +5.6% 0.95x
PrimsSplit.o 10671 11263 +5.5% 0.95x
DictTest4Legacy.o 13812 14498 +5.0% 0.95x
StringRemoveDupes.o 3582 3750 +4.7% 0.96x
DictOfArraysToArrayOfDicts.o 16884 17672 +4.7% 0.96x
PrimsNonStrongRef.o 65519 68423 +4.4% 0.96x
DictionaryRemove.o 10656 11120 +4.4% 0.96x
WordCount.o 36139 37223 +3.0% 0.97x
RGBHistogram.o 20583 20992 +2.0% 0.98x
ObjectiveCBridging.o 55589 56585 +1.8% 0.98x
DriverUtils.o 116342 118242 +1.6% 0.98x
 
Improvement OLD NEW DELTA RATIO
DictTest4.o 13978 13728 -1.8% 1.02x

Performance: -Onone

Regression OLD NEW DELTA RATIO
StringInterpolationSmall 3080 3900 +26.6% 0.79x (?)
Set.subtracting.Seq.Int0 6112 7134 +16.7% 0.86x
DictionaryBridgeToObjC_Access 1134 1310 +15.5% 0.87x (?)
ObjectiveCBridgeStringHash 68 78 +14.7% 0.87x
Set.subtracting.Seq.Int25 6690 7603 +13.6% 0.88x (?)
ObjectiveCBridgeFromNSString 3095 3470 +12.1% 0.89x (?)
Set.subtracting.Seq.Int50 7095 7869 +10.9% 0.90x (?)
ArrayOfPOD 1037 1122 +8.2% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
DictionarySubscriptDefaultMutationArray 12504 4466 -64.3% 2.80x
DictionarySubscriptDefaultMutation 11788 4228 -64.1% 2.79x
FrequenciesUsingReduceInto 9914 3860 -61.1% 2.57x
DictionarySubscriptDefaultMutationOfObjects 15920 8300 -47.9% 1.92x
DictionarySubscriptDefaultMutationArrayOfObjects 18600 10340 -44.4% 1.80x
FrequenciesUsingReduce 15515 9470 -39.0% 1.64x
StringRemoveDupes 992 771 -22.3% 1.29x
DictionaryRemove 16780 13930 -17.0% 1.20x (?)
Dictionary3 667 571 -14.4% 1.17x
Dictionary4 1024 925 -9.7% 1.11x
Histogram 8421 7619 -9.5% 1.11x (?)
Dictionary4Legacy 1276 1182 -7.4% 1.08x (?)
ClassArrayGetter2 4260 3970 -6.8% 1.07x (?)
Dictionary4OfObjects 1466 1367 -6.8% 1.07x (?)

Code size: -swiftlibs

Improvement OLD NEW DELTA RATIO
libswiftCore.dylib 3813376 3751936 -1.6% 1.02x
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 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

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - ef00751

@varungandhi-apple
Copy link
Contributor

@swift-ci test

@eeckstein eeckstein merged commit 7b12c2e into swiftlang:master Jan 24, 2020
@eeckstein eeckstein deleted the dict-code-size branch January 24, 2020 21:37
Copy link
Member

@lorentey lorentey left a comment

Choose a reason for hiding this comment

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

Sorry for missing this; it's great! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants