-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Foundation] adjust inline of append and initialization functions #17027
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 test |
@swift-ci please benchmark |
… use _copyContents(initialzing:) to avoid performance regressions while using generic collection/sequence APIs
d624c1b
to
9a09ab4
Compare
@swift-ci please smoke test |
@swift-ci please benchmark |
@swift-ci please benchmark |
@@ -1897,13 +1867,7 @@ extension Data { | |||
|
|||
/// Provides bridging functionality for struct Data to class NSData and vice-versa. | |||
|
|||
#if DEPLOYMENT_RUNTIME_SWIFT |
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.
Is this change orthogonal to the copyContents one?
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.
Correct but it allows me to iterate on sclf for validating this easily
var iter = endIterator | ||
while let byte = iter.next() { self.append(byte) } | ||
let backing = _DataStorage(capacity: Swift.max(elements.underestimatedCount, 1)) | ||
var (iter, endIndex) = elements._copyContents(initializing: UnsafeMutableBufferPointer(start: backing._bytes?.bindMemory(to: UInt8.self, capacity: backing._capacity), count: backing._capacity)) |
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.
cc @atrick to double check the bind here
@@ -1260,30 +1238,20 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl | |||
} | |||
|
|||
// slightly faster paths for common sequences | |||
|
|||
@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.
Are you sure this @inlinable
doesn't expose the _DataStorage
type?
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.
@airspeedswift was telling me this is ok (similar to how Array does it)
/// Initialize a `Data` with the contents of an Array. | ||
/// | ||
/// - parameter bytes: An array of bytes to copy. | ||
public init(bytes: Array<UInt8>) { |
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.
The Data perf tests have some cases that cover these specific types, right?
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.
Yes it does
Build comment file:Optimized (O)Regression (7)
Improvement (9)
No Changes (424)
Unoptimized (Onone)Regression (8)
Improvement (12)
No Changes (420)
Hardware Overview
|
@swift-ci please benchmark |
@swift-ci please smoke test |
@swift-ci please benchmark |
Build comment file:Optimized (O)Regression (19)
Improvement (6)
No Changes (415)
Unoptimized (Onone)Regression (13)
Improvement (6)
No Changes (421)
Hardware Overview
|
Use _copyContents(initialzing:) to avoid performance regressions while using generic collection/sequence APIs