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

datastore: track bucket count in store stats & mem panel #1555

Merged
merged 2 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
45 changes: 42 additions & 3 deletions crates/re_arrow_store/src/store_stats.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::{
ComponentBucket, ComponentTable, DataStore, IndexBucket, IndexBucketIndices, IndexTable,
PersistentComponentTable, PersistentIndexTable,
ComponentBucket, ComponentTable, DataStore, DataStoreConfig, IndexBucket, IndexBucketIndices,
IndexTable, PersistentComponentTable, PersistentIndexTable,
};

// ---

// TODO(cmc): count buckets?
// TODO(cmc): compute incrementally once/if this becomes too expensive.
#[derive(Default, Debug)]
pub struct DataStoreStats {
Expand All @@ -16,13 +15,17 @@ pub struct DataStoreStats {

pub total_temporal_index_rows: u64,
pub total_temporal_index_size_bytes: u64,
pub total_temporal_index_buckets: u64,
pub total_temporal_component_rows: u64,
pub total_temporal_component_size_bytes: u64,
pub total_temporal_component_buckets: u64,

pub total_index_rows: u64,
pub total_index_size_bytes: u64,
pub total_component_rows: u64,
pub total_component_size_bytes: u64,

pub config: DataStoreConfig,
}

impl DataStoreStats {
Expand All @@ -36,8 +39,10 @@ impl DataStoreStats {

let total_temporal_index_rows = store.total_temporal_index_rows();
let total_temporal_index_size_bytes = store.total_temporal_index_size_bytes();
let total_temporal_index_buckets = store.total_temporal_index_buckets();
let total_temporal_component_rows = store.total_temporal_component_rows();
let total_temporal_component_size_bytes = store.total_temporal_component_size_bytes();
let total_temporal_component_buckets = store.total_temporal_component_buckets();

let total_index_rows = total_timeless_index_rows + total_temporal_index_rows;
let total_index_size_bytes =
Expand All @@ -51,14 +56,20 @@ impl DataStoreStats {
total_timeless_index_size_bytes,
total_timeless_component_rows,
total_timeless_component_size_bytes,

total_temporal_index_rows,
total_temporal_index_size_bytes,
total_temporal_index_buckets,
total_temporal_component_rows,
total_temporal_component_size_bytes,
total_temporal_component_buckets,

total_index_rows,
total_index_size_bytes,
total_component_rows,
total_component_size_bytes,

config: store.config.clone(),
}
}
}
Expand Down Expand Up @@ -123,6 +134,15 @@ impl DataStore {
.sum()
}

/// Returns the number of temporal index buckets stored across this entire store.
pub fn total_temporal_index_buckets(&self) -> u64 {
crate::profile_function!();
self.indices
.values()
.map(|table| table.total_buckets())
.sum()
}

/// Returns the number of temporal component rows stored across this entire store, i.e. the
/// sum of the number of rows across all of its temporal component tables.
pub fn total_temporal_component_rows(&self) -> u64 {
Expand All @@ -142,6 +162,15 @@ impl DataStore {
.map(|table| table.total_size_bytes())
.sum()
}

/// Returns the number of temporal component buckets stored across this entire store.
pub fn total_temporal_component_buckets(&self) -> u64 {
crate::profile_function!();
self.components
.values()
.map(|table| table.total_buckets())
.sum()
}
}

// --- Persistent Indices ---
Expand Down Expand Up @@ -181,6 +210,11 @@ impl IndexTable {
.map(|bucket| bucket.total_size_bytes())
.sum()
}

/// Returns the number of buckets stored across this entire table.
pub fn total_buckets(&self) -> u64 {
self.buckets.len() as _
}
}

impl IndexBucket {
Expand Down Expand Up @@ -237,6 +271,11 @@ impl ComponentTable {
.map(|bucket| bucket.total_size_bytes())
.sum()
}

/// Returns the number of buckets stored across this entire table.
pub fn total_buckets(&self) -> u64 {
self.buckets.len() as _
}
}

impl ComponentBucket {
Expand Down
61 changes: 58 additions & 3 deletions crates/re_viewer/src/ui/memory_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,45 @@ impl MemoryPanel {
}

fn store_stats(ui: &mut egui::Ui, store_stats: &DataStoreStats) {
egui::Grid::new("gpu resource grid")
egui::Grid::new("store config grid")
.num_columns(3)
.show(ui, |ui| {
let DataStoreStats { config, .. } = store_stats;

ui.label(egui::RichText::new("Limits").italics());
ui.label("Row limit");
ui.label("Size limit");
ui.end_row();

let label_rows = |ui: &mut egui::Ui, num_rows| {
if num_rows == u64::MAX {
ui.label("+∞")
Copy link
Member

Choose a reason for hiding this comment

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

... well technically not inf :D

} else {
ui.label(re_format::format_number(num_rows as _))
}
};
let label_size = |ui: &mut egui::Ui, size| {
if size == u64::MAX {
ui.label("+∞")
} else {
ui.label(re_format::format_bytes(size as _))
}
};

ui.label("Indices:");
label_rows(ui, config.index_bucket_nb_rows);
label_size(ui, config.index_bucket_size_bytes);
ui.end_row();

ui.label("Components:");
label_rows(ui, config.component_bucket_nb_rows);
label_size(ui, config.component_bucket_size_bytes);
ui.end_row();
});

ui.separator();

egui::Grid::new("store stats grid")
.num_columns(3)
.show(ui, |ui| {
let DataStoreStats {
Expand All @@ -185,46 +223,63 @@ impl MemoryPanel {
total_timeless_component_size_bytes,
total_temporal_index_rows,
total_temporal_index_size_bytes,
total_temporal_index_buckets,
total_temporal_component_rows,
total_temporal_component_size_bytes,
total_temporal_component_buckets,
total_index_rows,
total_index_size_bytes,
total_component_rows,
total_component_size_bytes,
config: _,
} = *store_stats;

let label_rows = |ui: &mut egui::Ui, num_rows| {
ui.label(format!("rows: {}", re_format::format_number(num_rows as _)))
ui.label(egui::RichText::new("Stats").italics());
ui.label("Buckets");
ui.label("Rows");
ui.label("Size");
ui.end_row();

let label_buckets = |ui: &mut egui::Ui, num_buckets| {
ui.label(re_format::format_number(num_buckets as _))
};
let label_rows =
|ui: &mut egui::Ui, num_rows| ui.label(re_format::format_number(num_rows as _));
let label_size =
|ui: &mut egui::Ui, size| ui.label(re_format::format_bytes(size as _));

ui.label("Indices (timeless):");
ui.label("");
label_rows(ui, total_timeless_index_rows);
label_size(ui, total_timeless_index_size_bytes);
ui.end_row();

ui.label("Indices (temporal):");
label_buckets(ui, total_temporal_index_buckets);
label_rows(ui, total_temporal_index_rows);
label_size(ui, total_temporal_index_size_bytes);
ui.end_row();

ui.label("Indices (total):");
label_buckets(ui, total_temporal_index_buckets);
label_rows(ui, total_index_rows);
label_size(ui, total_index_size_bytes);
ui.end_row();

ui.label("Components (timeless):");
ui.label("");
label_rows(ui, total_timeless_component_rows);
label_size(ui, total_timeless_component_size_bytes);
ui.end_row();

ui.label("Components (temporal):");
label_buckets(ui, total_temporal_component_buckets);
label_rows(ui, total_temporal_component_rows);
label_size(ui, total_temporal_component_size_bytes);
ui.end_row();

ui.label("Components (total):");
label_buckets(ui, total_temporal_component_buckets);
label_rows(ui, total_component_rows);
label_size(ui, total_component_size_bytes);
ui.end_row();
Expand Down