-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
coldata: do not allocate wasteful memory for UUIDs #63231
Conversation
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.
Reviewed 7 of 7 files at r1.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich)
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich)
pkg/col/coldata/bytes.go, line 51 at r1 (raw file):
// that will be added to this Bytes. It can be 0 when the length is unknown in // which case BytesInitialAllocationFactor will be used as a guess. func NewBytes(n int, avgElementLength int) *Bytes {
[nit] It's cleaner to have separate constructors instead of special values (e.g. NewBytes, NewBytesWithAvgLength). The one without the length would just call out to the general one with BytesInitialAllocationFactor. For one, you won't have to add a /* avgElementLength */
to all the call sites :)
Previously, whenever we're allocating a new `Bytes` vector, we would use 64 bytes as an average element size to decide how large of a flat byte slice to allocate initially. This is wasteful in case of Uuids because then we know that each element will be exactly of 16 bytes. This commit uses that knowledge to remove wasteful allocations. Release note: None
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.
TFTRs!
bors r+
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @michae2 and @RaduBerinde)
pkg/col/coldata/bytes.go, line 51 at r1 (raw file):
Previously, RaduBerinde wrote…
[nit] It's cleaner to have separate constructors instead of special values (e.g. NewBytes, NewBytesWithAvgLength). The one without the length would just call out to the general one with BytesInitialAllocationFactor. For one, you won't have to add a
/* avgElementLength */
to all the call sites :)
Good point, done.
Build failed (retrying...): |
Build failed (retrying...): |
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @michae2 and @RaduBerinde)
Build failed (retrying...): |
Build succeeded: |
@yuzefovich is this a candidate for a backport? |
I think so, thanks Raphael. |
Previously, whenever we're allocating a new
Bytes
vector, we would use64 bytes as an average element size to decide how large of a flat byte
slice to allocate initially. This is wasteful in case of Uuids because
then we know that each element will be exactly of 16 bytes. This commit
uses that knowledge to remove wasteful allocations.
Release note: None