Skip to content
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

Improve entity size stats: include whole subtree #4542

Merged
merged 6 commits into from
Dec 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crates/re_data_store/src/entity_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,47 @@ pub struct SubtreeInfo {
///
/// ⚠ Auto-generated instance keys are _not_ accounted for. ⚠
pub time_histogram: TimeHistogramPerTimeline,

/// Number of bytes used by all arrow data in this tree (ignores overhead from book-keeping, schemas, etc).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The size of the cell does take into account the copy of the arrow schema that is stored in the cell

data_bytes: u64,
}

impl SubtreeInfo {
/// Assumes the event has been filtered to be part of this subtree.
fn on_event(&mut self, event: &StoreEvent) {
use re_types_core::SizeBytes as _;

match event.kind {
StoreDiffKind::Addition => {
self.time_histogram
.add(&event.times, event.num_components() as _);

for cell in event.cells.values() {
self.data_bytes += cell.heap_size_bytes();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cells themselves are also stored on the heap at this point, so you want total_size_bytes()

}
}
StoreDiffKind::Deletion => {
self.time_histogram
.remove(&event.timepoint(), event.num_components() as _);

for cell in event.cells.values() {
if let Some(bytes_left) = self.data_bytes.checked_sub(cell.heap_size_bytes()) {
self.data_bytes = bytes_left;
} else if cfg!(debug_assertions) {
re_log::warn_once!(
"Error in book-keeping: we've removed more bytes then we've added"
);
}
}
}
}
}

/// Number of bytes used by all arrow data in this tree (ignores overhead from book-keeping, schemas, etc).
#[inline]
pub fn data_bytes(&self) -> u64 {
self.data_bytes
}
}

/// Maintains an optimized representation of a batch of [`StoreEvent`]s specifically designed to
Expand Down