Skip to content

[stdlib] Set, Dictionary: Replace _Variant enums with _BridgeStorage #19688

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 18 commits into from
Oct 8, 2018

Conversation

lorentey
Copy link
Member

@lorentey lorentey commented Oct 3, 2018

This is a followup to #19611, taking it to its logical conclusion.

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

@swift-ci please smoke benchmark

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

@swift-ci please test

@swift-ci

This comment has been minimized.

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

/home/buildnode/jenkins/workspace/swift-PR-Linux/branch-master/swift/stdlib/public/core/DictionaryVariant.swift:38:64: error: use of undeclared type '_NSDictionary'
12:21:03     internal var object: _BridgeStorage<_RawDictionaryStorage, _NSDictionary>
12:21:03                                                                ^~~~~~~~~~~~~

D'oh.

@swift-ci

This comment has been minimized.

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

The results are a weird mix. 🤔 And what's up with Dictionary.Values.swapAt(_:, _:)?

@swift-ci

This comment has been minimized.

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

/Users/buildnode/jenkins/workspace/swift-PR-osx/branch-master/swift/validation-test/stdlib/Inputs/DictionaryKeyValueTypesObjC.swift:24:9: error: pattern cannot match values of type 'Dictionary<KeyTy, ValueTy>._Variant'

Yeah, the tests are poking things they shouldn't.

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

@swift-ci smoke benchmark

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

@swift-ci smoke test

@swift-ci

This comment has been minimized.

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

@swift-ci test

@swift-ci

This comment has been minimized.

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

Remaining slowdowns affect small dictionaries/sets only. There may be a small inefficiency somewhere.

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

@swift-ci please smoke test linux platform

@swift-ci

This comment has been minimized.

@lorentey
Copy link
Member Author

lorentey commented Oct 3, 2018

@swift-ci smoke test

1 similar comment
@lorentey
Copy link
Member Author

lorentey commented Oct 4, 2018

@swift-ci smoke test

@lorentey
Copy link
Member Author

lorentey commented Oct 4, 2018

@swift-ci smoke benchmark

@swift-ci
Copy link
Contributor

swift-ci commented Oct 4, 2018

Build comment file:

Build failed before running benchmark.


@lorentey
Copy link
Member Author

lorentey commented Oct 4, 2018

/Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/stdlib/public/core/Dictionary.swift:1860:16: error: invalid redeclaration of '_isNative'
10:22:55   internal var _isNative: Bool {
10:22:55                ^
10:22:55 /Users/buildnode/jenkins/workspace/swift-PR-osx-smoke-test/branch-master/swift/stdlib/public/core/Dictionary.swift:1848:16: note: '_isNative' previously declared here
10:22:55   internal var _isNative: Bool {
10:22:55                ^

Uh, what?

@lorentey
Copy link
Member Author

lorentey commented Oct 4, 2018

Oh, it's a merge failure.

@lorentey lorentey force-pushed the hashed-bridgeobject branch from 563fbb5 to 853720c Compare October 4, 2018 15:51
@lorentey
Copy link
Member Author

lorentey commented Oct 4, 2018

@swift-ci smoke test

@lorentey
Copy link
Member Author

lorentey commented Oct 4, 2018

@swift-ci smoke benchmark

@swift-ci
Copy link
Contributor

swift-ci commented Oct 4, 2018

Build comment file:

Performance: -O

TEST OLD NEW DELTA RATIO
Regression
AnyHashableWithAClass 89161 124959 +40.1% 0.71x
DictionaryBridgeToObjC_Bridge 19 21 +10.5% 0.90x (?)
LazilyFilteredArrayContains 33415 35996 +7.7% 0.93x
Improvement
DictionaryCopy 75634 51836 -31.5% 1.46x
SetUnionInt25 153 106 -30.7% 1.44x
DictionarySubscriptDefaultMutation 347 246 -29.1% 1.41x
DictionaryFilter 61303 44603 -27.2% 1.37x
DictionaryRemove 4109 3141 -23.6% 1.31x
DictionarySubscriptDefaultMutationArray 744 576 -22.6% 1.29x
SetUnionInt50 126 99 -21.4% 1.27x
SetSymmetricDifferenceInt25 254 200 -21.3% 1.27x
CountAlgoString 3287 2615 -20.4% 1.26x
SetUnionInt0 312 254 -18.6% 1.23x
DictionarySwap 1088 896 -17.6% 1.21x
SetUnion 3136 2637 -15.9% 1.19x
SetExclusiveOr 3834 3232 -15.7% 1.19x
SetIntersectionInt100 387 327 -15.5% 1.18x
SetSymmetricDifferenceInt0 382 323 -15.4% 1.18x
SetSymmetricDifferenceInt50 267 226 -15.4% 1.18x
Histogram 621 533 -14.2% 1.17x
SetIntersectionInt50 234 202 -13.7% 1.16x
SetSymmetricDifferenceInt100 262 230 -12.2% 1.14x
Dictionary3 183 161 -12.0% 1.14x
Dictionary 408 362 -11.3% 1.13x
SetSubtractingInt100 192 172 -10.4% 1.12x
StringRemoveDupes 431 391 -9.3% 1.10x
Dictionary4OfObjects 348 316 -9.2% 1.10x
Dictionary4 280 255 -8.9% 1.10x
RGBHistogram 2307 2106 -8.7% 1.10x
SetSubtractingInt50 157 144 -8.3% 1.09x
DictionarySubscriptDefaultMutationOfObjects 1645 1517 -7.8% 1.08x

Code size: -O

TEST OLD NEW DELTA RATIO
Regression
DictTest4.o 24228 26020 +7.4% 0.93x
DictTest4Legacy.o 25218 26946 +6.9% 0.94x
DictTest3.o 27032 28520 +5.5% 0.95x
TestsUtils.o 23941 25125 +4.9% 0.95x
DictTest2.o 18824 19720 +4.8% 0.95x
DictTest.o 50391 51175 +1.6% 0.98x
Improvement
ReduceInto.o 29399 27975 -4.8% 1.05x
NSDictionaryCastToSwift.o 2065 1984 -3.9% 1.04x
DictionaryLiteral.o 1392 1344 -3.4% 1.04x
DictionaryBridgeToObjC.o 7199 6959 -3.3% 1.03x
DictionarySubscriptDefault.o 31331 30307 -3.3% 1.03x
HashQuadratic.o 5992 5800 -3.2% 1.03x
DictionarySwap.o 28342 27590 -2.7% 1.03x
DictionaryBridge.o 3715 3634 -2.2% 1.02x
DictionaryCompactMapValues.o 23002 22510 -2.1% 1.02x
DictionaryKeysContains.o 16515 16195 -1.9% 1.02x
DictionaryRemove.o 15510 15214 -1.9% 1.02x
CharacterProperties.o 18841 18489 -1.9% 1.02x
ReversedCollections.o 11171 10979 -1.7% 1.02x
SetTests.o 60745 59705 -1.7% 1.02x
StringEdits.o 14525 14300 -1.5% 1.02x
Histogram.o 4252 4188 -1.5% 1.02x
Hash.o 29683 29251 -1.5% 1.01x
CountAlgo.o 21124 20821 -1.4% 1.01x
RGBHistogram.o 25317 24997 -1.3% 1.01x

Performance: -Osize

TEST OLD NEW DELTA RATIO
Regression
AnyHashableWithAClass 110261 132541 +20.2% 0.83x
WordCountUniqueASCII 1573 1871 +18.9% 0.84x
SetIsSubsetInt50 154 177 +14.9% 0.87x
SetIntersect 614 699 +13.8% 0.88x
SetIntersectionInt0 61 69 +13.1% 0.88x
DictionaryBridgeToObjC_Bridge 19 21 +10.5% 0.90x (?)
Improvement
DictionaryCopy 77097 54719 -29.0% 1.41x
DictionaryFilter 63928 45919 -28.2% 1.39x
DictionaryRemove 4443 3424 -22.9% 1.30x
DictionarySubscriptDefaultMutation 359 286 -20.3% 1.26x
DictionarySubscriptDefaultMutationArray 761 607 -20.2% 1.25x
SetSubtractingInt100 201 162 -19.4% 1.24x
SetUnionInt25 140 113 -19.3% 1.24x
SetSubtractingInt50 161 130 -19.3% 1.24x
CountAlgoString 3106 2626 -15.5% 1.18x
Histogram 626 533 -14.9% 1.17x
SetUnionInt50 115 98 -14.8% 1.17x
SetUnionInt0 303 265 -12.5% 1.14x
SetSymmetricDifferenceInt25 237 208 -12.2% 1.14x
SetUnion 3032 2661 -12.2% 1.14x
SetSymmetricDifferenceInt50 250 221 -11.6% 1.13x
SetExclusiveOr 3777 3345 -11.4% 1.13x
Dictionary3 184 163 -11.4% 1.13x
Dictionary3OfObjects 773 686 -11.3% 1.13x
SetSymmetricDifferenceInt0 378 336 -11.1% 1.12x
Dictionary 420 375 -10.7% 1.12x
SetSymmetricDifferenceInt100 249 223 -10.4% 1.12x
StringRemoveDupes 439 396 -9.8% 1.11x
FloatingPointPrinting_Float_description_uniform 5594 5148 -8.0% 1.09x
TwoSum 1259 1165 -7.5% 1.08x
DictionarySwapAt 1109 1028 -7.3% 1.08x

Code size: -Osize

TEST OLD NEW DELTA RATIO
Regression
main.o 41785 43561 +4.3% 0.96x
DictTest4.o 20875 21275 +1.9% 0.98x
DictTest2.o 15730 16018 +1.8% 0.98x
DictTest4Legacy.o 22233 22569 +1.5% 0.99x
WordCount.o 54376 55160 +1.4% 0.99x
Improvement
ReduceInto.o 18283 17083 -6.6% 1.07x
NSError.o 1763 1683 -4.5% 1.05x
SevenBoom.o 2111 2019 -4.4% 1.05x
DictionarySubscriptDefault.o 28323 27227 -3.9% 1.04x
NSDictionaryCastToSwift.o 1941 1877 -3.3% 1.03x
HashQuadratic.o 5528 5352 -3.2% 1.03x
Histogram.o 4176 4048 -3.1% 1.03x
DictionaryCompactMapValues.o 21634 21022 -2.8% 1.03x
DictionaryBridgeToObjC.o 6749 6605 -2.1% 1.02x
DictionaryBridge.o 3751 3671 -2.1% 1.02x
DictionaryCopy.o 8313 8137 -2.1% 1.02x
DictionaryLiteral.o 1525 1493 -2.1% 1.02x
RGBHistogram.o 23381 22933 -1.9% 1.02x
DriverUtils.o 145753 143385 -1.6% 1.02x
Hash.o 22623 22271 -1.6% 1.02x
ReversedCollections.o 11597 11421 -1.5% 1.02x
DictionaryKeysContains.o 15163 14971 -1.3% 1.01x
DictionarySwap.o 25971 25659 -1.2% 1.01x
CharacterProperties.o 18842 18634 -1.1% 1.01x
DictionaryGroup.o 16167 15991 -1.1% 1.01x
SetTests.o 53273 52705 -1.1% 1.01x

Performance: -Onone

TEST OLD NEW DELTA RATIO
Regression
AnyHashableWithAClass 106177 126639 +19.3% 0.84x
Improvement
SetIsSubsetInt100 1021 929 -9.0% 1.10x
SortStringsUnicode 2892 2651 -8.3% 1.09x (?)
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

@lorentey
Copy link
Member Author

lorentey commented Oct 4, 2018

This is looking good! I need to look at AnyHashableWithAClass and confess my ABI changes, but other than those two issues this seems ready to land.

The optimizer dislikes nested switch statements; flatten them out to simplify optimization and to hopefully speed things up a little.
@lorentey
Copy link
Member Author

lorentey commented Oct 5, 2018

AnyHashableWithAClass doesn't touch sets or dictionaries. I don't see how it could be regressed by these changes, so I'm going to ignore it for now.

@lorentey lorentey force-pushed the hashed-bridgeobject branch from 853720c to c47b922 Compare October 5, 2018 13:07
@lorentey
Copy link
Member Author

lorentey commented Oct 5, 2018

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Oct 5, 2018

Build failed
Swift Test Linux Platform
Git Sha - c47b922

@swift-ci
Copy link
Contributor

swift-ci commented Oct 5, 2018

Build failed
Swift Test OS X Platform
Git Sha - c47b922

@lorentey
Copy link
Member Author

lorentey commented Oct 5, 2018

Oh yeah, this also requires a small update to LLDB's data formatters.

@lorentey
Copy link
Member Author

lorentey commented Oct 5, 2018

Please test with the following PR:
apple/swift-lldb#959
@swift-ci please test linux platform

@lorentey
Copy link
Member Author

lorentey commented Oct 6, 2018

Please test with the following PR:
apple/swift-lldb#959
@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Oct 6, 2018

Build failed
Swift Test Linux Platform
Git Sha - aba15a1

@lorentey
Copy link
Member Author

lorentey commented Oct 6, 2018

Hm, I don't think that Linux type checker crash is my fault.

@swift-ci
Copy link
Contributor

swift-ci commented Oct 6, 2018

Build failed
Swift Test OS X Platform
Git Sha - aba15a1

@lorentey
Copy link
Member Author

lorentey commented Oct 7, 2018

apple/swift-lldb#959
@swift-ci please test

@lorentey lorentey merged commit 4967393 into swiftlang:master Oct 8, 2018
@lorentey lorentey deleted the hashed-bridgeobject branch October 8, 2018 11:07
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