-
Notifications
You must be signed in to change notification settings - Fork 869
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
Account for child Bucket
size in OrderPreservingInterner
#4646
Conversation
@@ -343,8 +343,19 @@ impl Bucket { | |||
fn size(&self) -> usize { | |||
std::mem::size_of::<Self>() | |||
+ self.slots.capacity() * std::mem::size_of::<Slot>() | |||
// and account for the size of any embedded buckets in the slots | |||
+ self.slot_child_bucket_size() |
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 problem is that a Bucket
may contain other Bucket
s in the children Slots
:
arrow-rs/arrow-row/src/interner.rs
Line 233 in b15838c
child: Option<Box<Bucket>>, |
Their memory was not accounted for
Bucket
size in OrderPreservingInterner
.iter() | ||
.map(|slot| slot.child.as_ref().map(|x| x.size()).unwrap_or_default()) | ||
.sum() | ||
} | ||
} | ||
|
||
#[cfg(test)] |
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 would love some suggestions on how to test this -- what I tried is described on #4645
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 made a test in 111b43c
It is basically a second implementation of size, which one could argue is unnecessary but I feel good by having a double check
I am still working on a test for this |
Which issue does this PR close?
Closes #4645
Rationale for this change
Without this change our system consumes significantly more memory (2-3x) than the configured limit
What changes are included in this PR?
Account for missing allocation
Are there any user-facing changes?
If you use this to enforce memory limits, will not exceed limits