-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] Implement withContiguousStorageIfAvailable
for raw buffer types
#41288
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 linux platform |
@swift-ci please test macOS platform |
@swift-ci apple silicon benchmark |
@swift-ci apple silicon benchmark |
Performance (arm64): -O
Code size: -OPerformance (arm64): -Osize
Code size: -OsizePerformance (arm64): -Onone
Code size: -swiftlibsHow 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 don't think any of these benchmark (performance) results are relevant. Thoughts, @lorentey? |
yes, it looks like noise. |
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.
This looks good!
Incidentally: I keep having a hard time grokking the nature of withMemoryRebound
-- is rebinding memory semantically mutating the global state of a Swift program? Or is its effect localized somehow, to, say, a single thread? (I.e., is it really safe to call it from a nonmutating context, while some other parts of the program may be accessing the same memory, bound differently?)
|
I looked at |
`UnsafeRawBufferPointer` only gained an implementation of `withContiguousStorageIfAvailable(_:)` with [SE-0333](https://github.com/apple/swift-evolution/blob/main/proposals/0333-with-memory-rebound.md) and swiftlang/swift#41288. Because swift-testing can be used on older versions of Darwin that don't have this implementation, one of our unit tests now crashes there when calling `FileHandle.write(_: some Sequence<UInt8>)`. This PR resolves the crash by providing a concretely-typed overload that takes an instance of `UnsafeRawBufferPointer`. This code path is technically dead right now (it survives from an intermediate implementation of #286) but because "writing bytes to a file" remains a useful tool we'll probably need in the future, I'm not ripping it out just yet.
…309) `UnsafeRawBufferPointer` only gained an implementation of `withContiguousStorageIfAvailable(_:)` with [SE-0333](https://github.com/apple/swift-evolution/blob/main/proposals/0333-with-memory-rebound.md) and swiftlang/swift#41288. Because swift-testing can be used on older versions of Darwin that don't have this implementation, one of our unit tests now crashes there when calling `FileHandle.write(_: some Sequence<UInt8>)`. This PR resolves the crash by providing a concretely-typed overload that takes an instance of `UnsafeRawBufferPointer`. This code path is technically dead right now (it survives from an intermediate implementation of #286) but because "writing bytes to a file" remains a useful tool we'll probably need in the future, I'm not ripping it out just yet. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
Until now,
UnsafeRawBufferPointer
andUnsafeMutableRawBufferPointer
have not had an implementation of thewithContiguousStorageIfAvailable
andwithContiguousMutableStorageIfAvailable
functions, making a frequently-used fast path unavailable to those types.The recently-landed SE-0333 (apple/swift#39529) means implementing the
withContiguous{Mutable}StorageIfAvailable
functions for the raw buffer types is now possible.Resolves SR-15433 (rdar://84980367)