-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Clean up and restructure String bridging a bit #20623
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
@swift-ci please smoke benchmark |
@@ -480,7 +483,7 @@ extension String.UTF16View { | |||
internal func _nativeGetIndex(for offset: Int) -> Index { | |||
// Trivial and common: start | |||
if offset == 0 { return startIndex } | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had an ASCII fast path here too but I got it wrong and it was crashing. Need to debug further.
return 0 | ||
} | ||
defer { _fixLifetime(nativeOther) } | ||
let otherStart = nativeOther.start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving start to the protocol certainly cleaned this up :)
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
ae46f1b
to
bc167d4
Compare
@swift-ci please smoke benchmark |
1 similar comment
@swift-ci please smoke benchmark |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
bc167d4
to
1d6c786
Compare
1d6c786
to
0cc4787
Compare
@swift-ci please benchmark |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@swift-ci please benchmark |
1 similar comment
@swift-ci please benchmark |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@swift-ci please benchmark |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
return _cocoaGetCStringTrampoline(self, | ||
outputPtr, | ||
maxLength, | ||
encoding) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style would be to line-break after opening delimiter, and try to fit these all on the next line
@@ -190,7 +187,7 @@ final internal class _StringStorage: _AbstractStringStorage { | |||
internal var _reserved: UInt16 | |||
|
|||
@inlinable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, unrelated to your PR, but this @inlinable
can be dropped.
@swift-ci please benchmark |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@swift-ci please smoke benchmark |
1 similar comment
@swift-ci please smoke benchmark |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
762c49c
to
492cab9
Compare
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
@swift-ci please test and merge |
1 similar comment
@swift-ci please test and merge |
@swift-ci please smoke test |
@swift-ci please smoke benchmark |
@swift-ci please smoke test |
@swift-ci please smoke benchmark |
Build comment file:Performance: -O
Performance: -Osize
Performance: -Onone
How to read the dataThe 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 Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
dabea0c
to
37c4967
Compare
• Convert _AbstractStringStorage to a protocol, and the free functions used to deduplicate implementations to extensions on that protocol. • Move 'start' into the abstract type and use that to simplify some code • Move the ASCII fast path for length into UTF16View. • Add a weirder but faster way to check which (if any) of our NSString subclasses a given object is, and adopt it
37c4967
to
8b57921
Compare
@swift-ci please smoke test and merge |
the ABI diffs are due to https://bugs.swift.org/browse/SR-9372 |
@swift-ci please smoke test and merge |
@airspeedswift we may want this for Swift 5, not so much because of the perf win (though that's nice), but because it'll make cherry-picking other bridging changes hard if we don't |
Initial local benchmarking suggests this isn't a speedup, but I'm curious what the full test suite will say.