Reduce size of Frame - #69
Open
glbrntt wants to merge 1 commit into
Open
Conversation
Frame is large: 161 bytes with a stride of 168 bytes. A reasonably large part of this is just padding which is easily removed by reordering stored properties. This patch moves properties around to reduce the size and stride down to 136 bytes.
agnosticdev
approved these changes
Aug 5, 2026
agnosticdev
left a comment
Collaborator
There was a problem hiding this comment.
Thank you George, just one question but otherwise fine!
| public var connectionComplete: Bool = false | ||
| private var _endOffset: UInt32 = 0 | ||
| private var _effectiveBufferLength: UInt32 = 0 | ||
| private var _aggregateBufferLength: UInt32 = 0 |
Collaborator
There was a problem hiding this comment.
So because of the out of order arrangement of these properties extra padding was being added, is that what was happening?
Contributor
Author
There was a problem hiding this comment.
It was the order the properties were in: Swift lays out types in the order they're declared in.
As an example the Buffer enum was stored first and is 33 bytes in size with an 8 byte alignment. It was followed by a NetworkUniqueArray<UInt8> which is 24 bytes (also 8 byte alignment). Because of the alignment there's 7 bytes of padding between the two, instead you can move smaller types (e.g. 7 booleans) into that space that would otherwise be padding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Frame is large: 161 bytes with a stride of 168 bytes. A reasonably large part of this is just padding which is easily removed by reordering stored properties.
This patch moves properties around to reduce the size and stride down to 136 bytes.