From 9b8086df74532c3e06475c42b1276147ab54bb75 Mon Sep 17 00:00:00 2001 From: Marco Neumann Date: Mon, 27 Jun 2022 17:25:32 +0200 Subject: [PATCH] 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> --- data_types/src/lib.rs | 3 +-- querier/src/cache/partition.rs | 3 +++ querier/src/cache/tombstones.rs | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/data_types/src/lib.rs b/data_types/src/lib.rs index f81db3d8dd..15d0726226 100644 --- a/data_types/src/lib.rs +++ b/data_types/src/lib.rs @@ -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() } } diff --git a/querier/src/cache/partition.rs b/querier/src/cache/partition.rs index 48d0e771ba..96fa4098ec 100644 --- a/querier/src/cache/partition.rs +++ b/querier/src/cache/partition.rs @@ -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() diff --git a/querier/src/cache/tombstones.rs b/querier/src/cache/tombstones.rs index 4cb9b8ce6e..1b6bb12dc8 100644 --- a/querier/src/cache/tombstones.rs +++ b/querier/src/cache/tombstones.rs @@ -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