-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Refine the size() calculation of accumulator #5904
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,7 +289,7 @@ impl Accumulator for SumAccumulator { | |
} | ||
|
||
fn size(&self) -> usize { | ||
std::mem::size_of_val(self) - std::mem::size_of_val(&self.sum) + self.sum.size() | ||
std::mem::size_of_val(self) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this size change after the AvgAccumulator /SumAccumulator struct is initialized? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest rename the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think not. Option is of Enum type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the flamegraph, it seems it's not a bottleneck now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the docs /// Allocated size required for this accumulator, in bytes, including `Self`.
/// Allocated means that for internal containers such as `Vec`, the `capacity` should be used
/// not the `len`
fn size(&self) -> usize; The change in this PR seems to avoid extra allocations in ScalarValue (such as |
||
} | ||
|
||
|
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 the logic is quite complex to collect the memory size of the accumulators, maybe the computation is more than the real useful aggregations
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.
Yes, I agree the calculation for the memory size is complicated.
I think @tustvold has been thinking about how to improve performance in this area, but I am not sure how far he has gotten
In general, managing individual allocations (and then accounting for their sizes) for each group is a significant additional overhead for grouping.