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
[SR-7545] Swift should support using realloc for tail allocated classes #50087
Comments
@swift-ci create |
This is only possible if the class has exactly one strong reference and no weak or unowned references, and if all of the things stored in the class can be bitwise-copied. But that might be a workable and enforceable set of restrictions. |
@belkadan I'm missing something. I would think you could theoretically realloc any (uniquely referenced) thing that is bitwise-movable. So, no ObjC weak/unowned refs, but everything else is ok. |
IIRC we've gone back and forth over whether "uniquely referenced" includes weak and unowned refs (which it really should), but leaving that aside for the moment, isn't your list the same as mine? |
Oh, "movable" instead of "copyable". Yes, you're right, I mistyped. |
Can we make this a dup of https://bugs.swift.org/browse/SR-6503, or vice-versa. |
SGTM |
implemented |
Should we have a separate bug for tracking getting it working on Darwin? |
@belkadan good point! https://bugs.swift.org/browse/SR-9236 |
@swift-ci create |
Additional Detail from JIRA
md5: 05a26fb36e0f13ceab8ad8129b713867
duplicates:
Issue Description:
My last couple of days I spent on aggressively reducing the number of allocations we do in SwiftNIO for a simple echo server and mostly for the HTTP server. One of the most annoying things is that for every allocated
ByteBuffer
you will actually do two allocations:1. the
_Storage
class itself for Cow (https://github.com/apple/swift-nio/blob/master/Sources/NIO/ByteBuffer-core.swift#L214)2. the storage for the actual bytes (https://github.com/apple/swift-nio/blob/master/Sources/NIO/ByteBuffer-core.swift#L233)
It would be great to make use of Swift's tail allocated classes but then we couldn't do
realloc
anymore (which we currently do: https://github.com/apple/swift-nio/blob/master/Sources/NIO/ByteBuffer-core.swift#L258).But really: we should support
realloc
ing tail allocated classes and we could shave another few allocations off.The text was updated successfully, but these errors were encountered: