Skip to content

Removes redundant buffer zeroing in StringGuts.swift by using `init(unsafeUninitializedCapacity:initializingWith:) #30131

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

Conversation

valeriyvan
Copy link
Contributor

@valeriyvan valeriyvan commented Feb 28, 2020

Removes redundant buffer zeroing by using init(unsafeUninitializedCapacity:initializingWith:) instead of init(repeating:count:)

@theblixguy theblixguy requested a review from milseman February 28, 2020 22:29
@valeriyvan valeriyvan changed the title Removes redundand buffer zeroing Removes redundant buffer zeroing Feb 28, 2020
@milseman
Copy link
Member

@swift-ci please benchmark

@milseman
Copy link
Member

@swift-ci please test

Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

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

This looks great! Let me see if we have benchmark coverage.

@swift-ci
Copy link
Contributor

Performance: -O

Code size: -O

Performance: -Osize

Improvement OLD NEW DELTA RATIO
FlattenListFlatMap 3133 2853 -8.9% 1.10x (?)

Code size: -Osize

Performance: -Onone

Improvement OLD NEW DELTA RATIO
DataAppendDataSmallToSmall 3180 2820 -11.3% 1.13x (?)

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 mini
  Model Identifier: Macmini8,1
  Processor Name: Intel Core i7
  Processor Speed: 3.2 GHz
  Number of Processors: 1
  Total Number of Cores: 6
  L2 Cache (per Core): 256 KB
  L3 Cache: 12 MB
  Memory: 64 GB

@milseman
Copy link
Member

Oh, this is only in the corelibs-foundation SPI, so it wouldn't have benchmark coverage. This function isn't called anymore (hence the deprecated availability). You might have greater effect targeting the version of this that's in corelibs-foundation here: https://github.com/apple/swift-corelibs-foundation/blob/master/Sources/Foundation/NSStringAPI.swift#L72

@valeriyvan
Copy link
Contributor Author

@valeriyvan valeriyvan changed the title Removes redundant buffer zeroing Removes redundant buffer zeroing in StringGuts.swift by using `init(unsafeUninitializedCapacity:initializingWith:) Feb 28, 2020
@milseman milseman merged commit 7876eab into swiftlang:master Mar 4, 2020
@valeriyvan valeriyvan deleted the RemoveRedundantZeroingStringGuts branch March 5, 2020 14:27
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