fix: size estimates (#4950)

* fix: `Tombstone::size` must include serialized predicate

* fix: `CachedPartition::size` must include `Arc` heap allocation

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
pull/24376/head
Marco Neumann 2022-06-27 17:25:32 +02:00 committed by GitHub
parent 1a74f84494
commit 9b8086df74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -799,8 +799,7 @@ pub struct Tombstone {
impl Tombstone {
/// Estimate the memory consumption of this object and its contents
pub fn size(&self) -> usize {
// No additional heap allocations
std::mem::size_of_val(self)
std::mem::size_of_val(self) + self.serialized_predicate.capacity()
}
}

View File

@ -136,6 +136,9 @@ struct CachedPartition {
impl CachedPartition {
/// RAM-bytes EXCLUDING `self`.
fn size(&self) -> usize {
// Arc heap allocation
size_of_val(self.sort_key.as_ref()) +
// Arc content
self.sort_key
.as_ref()
.as_ref()

View File

@ -275,8 +275,8 @@ mod tests {
let cache = make_cache(&catalog);
let single_tombstone_size = 96;
let two_tombstone_size = 176;
let single_tombstone_size = 101;
let two_tombstone_size = 186;
assert!(single_tombstone_size < two_tombstone_size);
// Create tombstone 1