Skip to content

[stdlib] Make MutableCollection.partition(by:) implementation inlinable #36002

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
Feb 18, 2021

Conversation

lorentey
Copy link
Member

The default partition(by:) implementation cannot currently be specialized, which makes it ~64-100x slower than it could be for common cases. (E.g., Array<Int>.partition(by: { $0 >= foo}) is slower than .sort() by a factor of 2-32.)

Make the implementation inlinable.

The default `partition(by:)` implementation cannot currently be specialized, which makes it ~64-100x slower than it could be for common cases. (E.g., `Array<Int>.partition(by: { $0 >= foo})` is slower than `.sort()` by a factor of 2-32.)

Make the implementation inlinable.
@lorentey
Copy link
Member Author

@swift-ci test

@lorentey
Copy link
Member Author

@swift-ci benchmark

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 4f016c9

@lorentey
Copy link
Member Author

@swift-ci test linux platform

@swift-ci
Copy link
Contributor

Performance: -O

Regression OLD NEW DELTA RATIO
StringBuilderWithLongSubstring 1600 1770 +10.6% 0.90x (?)
Data.append.Sequence.809B.Count.RE.I 102 111 +8.8% 0.92x (?)
 
Improvement OLD NEW DELTA RATIO
FlattenListFlatMap 6105 5448 -10.8% 1.12x (?)
Data.init.Sequence.511B.Count.I 97 89 -8.2% 1.09x (?)

Code size: -O

Regression OLD NEW DELTA RATIO
NibbleSort.o 14025 14441 +3.0% 0.97x

Performance: -Osize

Regression OLD NEW DELTA RATIO
Breadcrumbs.UTF16ToIdxRange.longASCII 30 34 +13.3% 0.88x
DictionaryBridgeToObjC_Access 814 901 +10.7% 0.90x (?)
 
Improvement OLD NEW DELTA RATIO
String.data.Empty 44 40 -9.1% 1.10x (?)
NSStringConversion.UTF8 1080 984 -8.9% 1.10x (?)

Code size: -Osize

Regression OLD NEW DELTA RATIO
NibbleSort.o 13827 14125 +2.2% 0.98x

Performance: -Onone

Regression OLD NEW DELTA RATIO
ObjectiveCBridgeFromNSArrayAnyObjectForced 8180 9280 +13.4% 0.88x (?)
NSStringConversion.UTF8 3127 3425 +9.5% 0.91x (?)
 
Improvement OLD NEW DELTA RATIO
DictionaryBridgeToObjC_Access 1125 999 -11.2% 1.13x (?)
DataAppendArray 5700 5300 -7.0% 1.08x (?)

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 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 Linux Platform
Git Sha - 4f016c9

@natecook1000
Copy link
Member

@swift-ci Please test Linux platform

Copy link
Member

@natecook1000 natecook1000 left a comment

Choose a reason for hiding this comment

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

LGTM!

@lorentey lorentey merged commit 9acf214 into swiftlang:main Feb 18, 2021
@lorentey lorentey deleted the inline-partitioning-impl branch February 18, 2021 02:56
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