-
Notifications
You must be signed in to change notification settings - Fork 10.5k
add String(decoding:as:) benchmarks for Unsafe(Mutable)(Raw)BufferPoi… #21706
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 benchmark |
b7cd394
to
2f572bf
Compare
@swift-ci Please benchmark |
Build comment file:Performance: -O
Code size: -O
Performance: -Osize
Code size: -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
|
I feel like benchmarks for this don't give us any useful signal, they're just there to catch unintended regressions. @eeckstein, can we instead formulate these as SIL optimizer tests? We want the init decoding with Basically: public init(decoding:as:)<C: Collection, Encoding: Unicode.Encoding>(
decoding codeUnits: C, as sourceEncoding: Encoding.Type
) where C.Iterator.Element == Encoding.CodeUnit {
if let contigBytes = codeUnits as? _HasContiguousBytes,
sourceEncoding == UTF8.self,
contigBytes._providesContiguousBytesNoCopy
{
// ... calls String._fromUTF8Repairing ...
}
// ... calls String._fromCodeUnits(_:encoding:repair:) ...
} So we can just test that only the |
@milseman Definitely! If we expect the optimizer to compile a function down to a trivial thing, a SIL (or LLVM IR) FileCheck test is better than a benchmark. Examples are https://github.com/apple/swift/blob/master/test/SILOptimizer/character_literals.swift or https://github.com/apple/swift/blob/master/test/SILOptimizer/optionset.swift. I would not be worried too much about testing against internals of the stdlib (specifically usableFromInline functions) because with ABI stability those shouldn't change anyway. |
SGTM. @weissi, let me know if you'd like some help writing the tests. |
@eeckstein / @milseman does this sound about right? #21743 |
closing for #21743 |
…nters
in #21611 I added
_HasContiguousBytes
conformances forUnsafeRawBufferPointer
which should makeString
decoding from them a lot faster. But this needs a benchmark. This adds UTF8 decoding benchmarks for allUnsafe(Mutable)(Raw)BufferPointer(<UInt8>)
s and their slices.