-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
sem/builtins: account for internal memory of some aggregates #46545
Conversation
8ee4131
to
5bc1ed5
Compare
a.sawNonNull = false | ||
a.result.Reset() | ||
a.acc.Empty(ctx) |
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 actually might be incorrect, will need to double check this tomorrow.
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 max aggregate doesn't reset its account here either
Can you share the memory profile that brought you to this conclusion? |
if a.val == tree.DNull && datum != tree.DNull { | ||
a.val = datum | ||
if err := a.acc.Grow(ctx, int64(datum.Size())); err != nil { |
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.
I think this should be ResizeTo
, not Grow
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.
ack never mind, we are only going to call this once.
a.sawNonNull = false | ||
a.result.Reset() | ||
a.acc.Empty(ctx) |
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 max aggregate doesn't reset its account here either
Release justification: fixes for high-priority or high-severity bugs in existing functionality. Previously, we were not accounting for the memory of the first non-null datum in `anyNotNull` aggregate. Similarly, we were not accounting for the byte slice in `bytesXor` aggregate. This is now fixed. This commit also fixes an issue with double accounting for the current datum in `min` and `max` aggregates on fixed size types (previously, it was reported in `Size()` method as well as separately on the first non-null datum). Additionally, `minAggregate` and `maxAggregate` have been unexported. Release note (bug fix): CockroachDB previously was incorrectly accounting for some RAM usage when computing aggregate functions which results in an underestimation of it and could cause an out of memory crash. Now this has been fixed.
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! 0 of 0 LGTMs obtained (waiting on @asubiotto and @rohany)
pkg/sql/sem/builtins/aggregate_builtins.go, line 521 at r1 (raw file):
Previously, rohany (Rohan Yadav) wrote…
ack never mind, we are only going to call this once.
Yep.
pkg/sql/sem/builtins/aggregate_builtins.go, line 766 at r1 (raw file):
Previously, rohany (Rohan Yadav) wrote…
The max aggregate doesn't reset its account here either
Done.
this LGTM, but i'd wait for someone else more knowledgeable in this area to agree |
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 @asubiotto and @rohany)
TFTRs! bors r+ |
Build succeeded |
Release justification: fixes for high-priority or high-severity bugs in
existing functionality.
Previously, we were not accounting for the memory of the first non-null
datum in
anyNotNull
aggregate. Similarly, we were not accounting forthe byte slice in
bytesXor
aggregate. This is now fixed.This commit also fixes an issue with double accounting for the current
datum in
min
andmax
aggregates on fixed size types (previously, itwas reported in
Size()
method as well as separately on the firstnon-null datum). Additionally,
minAggregate
andmaxAggregate
havebeen unexported.
Addresses: #45812.
Release note (bug fix): CockroachDB previously was incorrectly
accounting for some RAM usage when computing aggregate functions which
results in an underestimation of it and could cause an out of memory
crash. Now this has been fixed.