Skip to content

[stdlib] Unchecked subscript on UnsafeBufferPointer #20621

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
Nov 26, 2018

Conversation

milseman
Copy link
Member

Add a use an unchecked subscript on UnsafeBufferPointer, which skips
debugPrecondition checks (in case we're not inlined) as well as a
force-unwrap check.

@milseman
Copy link
Member Author

@swift-ci please benchmark

@milseman
Copy link
Member Author

@swift-ci please test source compatibility

@milseman
Copy link
Member Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build comment file:

Performance: -O

TEST OLD NEW DELTA RATIO
Regression
EqualStringSubstring 10 11 +10.0% 0.91x
Improvement
ObjectiveCBridgeStringHash 69 41 -40.6% 1.68x
ObjectiveCBridgeStringCStringUsingEncoding 564 437 -22.5% 1.29x
ObjectiveCBridgeStringGetASCIIContents 295 238 -19.3% 1.24x
CharIteration_korean_unicodeScalars 3409 2984 -12.5% 1.14x
ObjectiveCBridgeStringCompare2 763 679 -11.0% 1.12x
ObjectiveCBridgeStringCompare 809 722 -10.8% 1.12x
ObjectiveCBridgeStringIsEqual 159 144 -9.4% 1.10x
ObjectiveCBridgeStringRangeOfString 773 705 -8.8% 1.10x
StringEqualPointerComparison 589 538 -8.7% 1.09x
CharIteration_chinese_unicodeScalars 2599 2385 -8.2% 1.09x (?)
NormalizedIterator_ascii 176 164 -6.8% 1.07x

Performance: -Osize

TEST OLD NEW DELTA RATIO
Regression
NopDeinit 40207 55250 +37.4% 0.73x
CharIteration_ascii_unicodeScalars 2275 2453 +7.8% 0.93x
Improvement
ObjectiveCBridgeStringHash 69 41 -40.6% 1.68x
ObjectiveCBridgeStringCStringUsingEncoding 549 439 -20.0% 1.25x
ObjectiveCBridgeStringGetASCIIContents 293 238 -18.8% 1.23x
IterateData 1406 1218 -13.4% 1.15x
ObjectiveCBridgeStringIsEqual 160 141 -11.9% 1.13x
ObjectiveCBridgeStringCompare 801 713 -11.0% 1.12x
ObjectiveCBridgeStringCompare2 766 683 -10.8% 1.12x
ObjectiveCBridgeStringRangeOfString 786 707 -10.1% 1.11x
StringEqualPointerComparison 564 512 -9.2% 1.10x
StringComparison_nonBMPSlowestPrenormal 1341 1245 -7.2% 1.08x
NormalizedIterator_ascii 176 164 -6.8% 1.07x

Performance: -Onone

TEST OLD NEW DELTA RATIO
Improvement
ObjectiveCBridgeStringHash 69 43 -37.7% 1.60x
Histogram 5656 4482 -20.8% 1.26x
ObjectiveCBridgeStringCStringUsingEncoding 552 446 -19.2% 1.24x
ObjectiveCBridgeStringGetASCIIContents 296 244 -17.6% 1.21x
ObjectiveCBridgeStringCompare2 771 680 -11.8% 1.13x
ObjectiveCBridgeStringCompare 810 716 -11.6% 1.13x
ObjectiveCBridgeStringIsEqual 162 144 -11.1% 1.12x
ObjectiveCBridgeStringRangeOfString 774 705 -8.9% 1.10x
StrComplexWalk 7895 7272 -7.9% 1.09x

Code size: -swiftlibs

TEST OLD NEW DELTA RATIO
Improvement
libswiftSwiftPrivate.dylib 45056 40960 -9.1% 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: 8-Core Intel Xeon E5
  Processor Speed: 3 GHz
  Number of Processors: 1
  Total Number of Cores: 8
  L2 Cache (per Core): 256 KB
  L3 Cache: 25 MB
  Memory: 64 GB
--------------

Add a use an unchecked subscript on UnsafeBufferPointer, which skips
debugPrecondition checks (in case we're not inlined) as well as a
force-unwrap check.
@milseman milseman force-pushed the unsafe_unchecked_buffer_pointer branch from 5204040 to 3a0ac02 Compare November 16, 2018 19:12
@milseman
Copy link
Member Author

@swift-ci please smoke test and merge

@milseman
Copy link
Member Author

@swift-ci please smoke test

@milseman milseman merged commit 8b9cc18 into swiftlang:master Nov 26, 2018
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