Skip to content

[stdlib] implement _copyContents for UnsafeRawBufferPointer #38828

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 2 commits into from
Aug 21, 2021

Conversation

glessard
Copy link
Contributor

@glessard glessard commented Aug 10, 2021

Implements _copyContents for Unsafe[Mutable]RawBufferPointer, which enables a fast path when filling up Array or UnsafeMutableBufferPointer<UInt8>.

Resolves SR-9604 (rdar://52529574).

@glessard glessard marked this pull request as draft August 10, 2021 21:04
@glessard
Copy link
Contributor Author

Waiting on #38827 for benchmarking.

@glessard
Copy link
Contributor Author

@swift-ci please benchmark

@swift-ci
Copy link
Contributor

Performance (x86_64): -O

Regression OLD NEW DELTA RATIO
DictionaryOfAnyHashableStrings_insert 3192 5558 +74.1% 0.57x
Set.isDisjoint.Box25 355 505 +42.3% 0.70x (?)
Set.isDisjoint.Int50 266 335 +25.9% 0.79x (?)
StringFromLongWholeSubstring 4 5 +25.0% 0.80x
DictionaryKeysContainsNative 22 27 +22.7% 0.81x (?)
String.data.Medium 100 111 +11.0% 0.90x (?)
StringRemoveDupes 258 285 +10.5% 0.91x (?)
SetSubtractingInt50 111 120 +8.1% 0.93x (?)
DataToStringLargeUnicode 6200 6700 +8.1% 0.93x (?)
String.data.LargeUnicode 106 114 +7.5% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
RawBuffer.copyContents 914 48 -94.7% 19.04x
FlattenListFlatMap 6122 4353 -28.9% 1.41x (?)
DataAppendArray 4100 3800 -7.3% 1.08x (?)

Code size: -O

Performance (x86_64): -Osize

Regression OLD NEW DELTA RATIO
StringFromLongWholeSubstring 4 5 +25.0% 0.80x
DictionaryKeysContainsCocoa 26 28 +7.7% 0.93x (?)
 
Improvement OLD NEW DELTA RATIO
RawBuffer.copyContents 914 48 -94.7% 19.04x
NSStringConversion.Rebridge.UTF8 473 434 -8.2% 1.09x (?)

Code size: -Osize

Performance (x86_64): -Onone

Regression OLD NEW DELTA RATIO
DataToStringSmall 3900 4650 +19.2% 0.84x (?)
 
Improvement OLD NEW DELTA RATIO
RawBuffer.copyContents 914 48 -94.7% 19.04x

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

@eeckstein eeckstein requested review from lorentey and atrick August 19, 2021 06:42
@glessard
Copy link
Contributor Author

@swift-ci please smoke test

@glessard glessard marked this pull request as ready for review August 19, 2021 09:32
Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Wow, that's a pretty big missing performance feature.

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