Skip to content

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

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

Conversation

valeriyvan
Copy link
Contributor

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

@valeriyvan valeriyvan changed the title Removes redundant buffer zeroing Removes redundant buffer zeroing in StringGraphemeBreaking.swift by using `init(unsafeUninitializedCapacity:initializingWith:) Feb 28, 2020
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.

Nice!

@milseman
Copy link
Member

milseman commented Mar 4, 2020

@swift-ci please test

@milseman
Copy link
Member

milseman commented Mar 4, 2020

@swift-ci please benchmark

@swift-ci
Copy link
Contributor

swift-ci commented Mar 4, 2020

Performance: -O

Regression OLD NEW DELTA RATIO
EqualSubstringSubstring 22 28 +27.3% 0.79x
LessSubstringSubstring 22 28 +27.3% 0.79x
EqualSubstringSubstringGenericEquatable 22 28 +27.3% 0.79x
LessSubstringSubstringGenericComparable 22 28 +27.3% 0.79x
EqualStringSubstring 23 29 +26.1% 0.79x
EqualSubstringString 23 29 +26.1% 0.79x (?)
NSStringConversion.Long 490 569 +16.1% 0.86x
StringComparison_longSharedPrefix 314 351 +11.8% 0.89x (?)
NSStringConversion.Medium 237 260 +9.7% 0.91x (?)
 
Improvement OLD NEW DELTA RATIO
FlattenListFlatMap 5776 4487 -22.3% 1.29x (?)
UTF8Decode_InitDecoding 161 134 -16.8% 1.20x
ArrayPlusEqualSingleElementCollection 470 423 -10.0% 1.11x (?)
UTF8Decode_InitFromBytes_ascii 222 202 -9.0% 1.10x (?)
DictionarySubscriptDefaultMutation 175 160 -8.6% 1.09x (?)

Code size: -O

Performance: -Osize

Regression OLD NEW DELTA RATIO
EqualSubstringSubstring 22 28 +27.3% 0.79x
LessSubstringSubstring 22 28 +27.3% 0.79x
EqualStringSubstring 22 28 +27.3% 0.79x (?)
EqualSubstringSubstringGenericEquatable 22 28 +27.3% 0.79x (?)
EqualSubstringString 22 28 +27.3% 0.79x
LessSubstringSubstringGenericComparable 22 28 +27.3% 0.79x
NSStringConversion.Long 499 568 +13.8% 0.88x
StringComparison_longSharedPrefix 314 351 +11.8% 0.89x (?)
NSStringConversion.Medium 241 267 +10.8% 0.90x (?)
 
Improvement OLD NEW DELTA RATIO
UTF8Decode_InitDecoding 161 135 -16.1% 1.19x
FlattenListFlatMap 5053 4689 -7.2% 1.08x (?)

Code size: -Osize

Regression OLD NEW DELTA RATIO
ReversedCollections.o 8689 8809 +1.4% 0.99x

Performance: -Onone

Regression OLD NEW DELTA RATIO
EqualSubstringSubstringGenericEquatable 26 32 +23.1% 0.81x
LessSubstringSubstringGenericComparable 26 32 +23.1% 0.81x
LessSubstringSubstring 27 33 +22.2% 0.82x
EqualSubstringSubstring 28 33 +17.9% 0.85x (?)
EqualStringSubstring 28 33 +17.9% 0.85x
EqualSubstringString 28 33 +17.9% 0.85x
 
Improvement OLD NEW DELTA RATIO
UTF8Decode_InitDecoding 182 156 -14.3% 1.17x (?)
ArrayOfPOD 726 648 -10.7% 1.12x (?)

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 milseman merged commit ebe8aac into swiftlang:master Mar 5, 2020
@valeriyvan valeriyvan deleted the RemoveRedundantZeroingStringGraphemeBreaking branch February 20, 2023 08:05
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