Skip to content

[stdlib] Dictionary.Keys, .Values: Implement custom iterators #19602

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
Sep 28, 2018

Conversation

lorentey
Copy link
Member

@lorentey lorentey commented Sep 28, 2018

Implement custom iterators for Dictionary's Keys and Values views.

IndexingIterator is pretty slow, especially for Cocoa indices, and especially with #19599. Defining these trivial iterators should be a nice speed boost for any code that walks over these views.

@lorentey
Copy link
Member Author

@swift-ci please test

@lorentey
Copy link
Member Author

@swift-ci please smoke benchmark

@lorentey
Copy link
Member Author

@swift-ci please test source compatibility

@lorentey
Copy link
Member Author

cc @airspeedswift

@swift-ci
Copy link
Contributor

Build comment file:

Performance: -O

TEST OLD NEW DELTA RATIO
Regression
StringComparison_fastPrenormal 840 919 +9.4% 0.91x
FloatingPointPrinting_Float_description_uniform 5182 5585 +7.8% 0.93x
Improvement
IterateData 1738 1564 -10.0% 1.11x (?)
CStringLongAscii 3538 3293 -6.9% 1.07x
UTF8Decode_InitFromData 1391 1295 -6.9% 1.07x (?)

Code size: -O

TEST OLD NEW DELTA RATIO
Regression
DictionarySwap.o 30403 33467 +10.1% 0.91x
Improvement
DictionaryKeysContains.o 20343 19395 -4.7% 1.05x
DictionaryBridgeToObjC.o 7543 7263 -3.7% 1.04x

Performance: -Osize

TEST OLD NEW DELTA RATIO
Regression
FloatingPointPrinting_Float_description_uniform 5193 5836 +12.4% 0.89x
Improvement
IterateData 1830 1626 -11.1% 1.13x
CStringLongAscii 3547 3295 -7.1% 1.08x

Code size: -Osize

TEST OLD NEW DELTA RATIO
Regression
DictionarySwap.o 26827 29091 +8.4% 0.92x
Improvement
DictionaryKeysContains.o 17735 17099 -3.6% 1.04x
DictionaryBridgeToObjC.o 7029 6917 -1.6% 1.02x

Performance: -Onone

TEST OLD NEW DELTA RATIO
Regression
StrToInt 82601 103552 +25.4% 0.80x
Improvement
DictionaryBridgeToObjC_Access 1859 1260 -32.2% 1.48x
CharIndexing_punctuated_unicodeScalars_Backwards 92817 76466 -17.6% 1.21x
CharIndexing_japanese_unicodeScalars 450228 376360 -16.4% 1.20x
CharIndexing_punctuated_unicodeScalars 83261 70008 -15.9% 1.19x
CharIndexing_tweet_unicodeScalars 738707 621306 -15.9% 1.19x
CharIndexing_tweet_unicodeScalars_Backwards 850535 717851 -15.6% 1.18x
CharIndexing_korean_unicodeScalars 359722 304015 -15.5% 1.18x
CharIndexing_ascii_unicodeScalars 370974 313740 -15.4% 1.18x
CharIndexing_chinese_unicodeScalars 279992 237081 -15.3% 1.18x
DropFirstArrayLazy 34391 31161 -9.4% 1.10x
PrefixArrayLazy 34214 31078 -9.2% 1.10x
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

Source compat failure (fluent) is unrelated; see #19594.

@lorentey lorentey merged commit e080bab into swiftlang:master Sep 28, 2018
@lorentey lorentey deleted the dict-iterators branch September 28, 2018 03:18
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