Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 25, 2024
1 parent 2040616 commit 2395717
Show file tree
Hide file tree
Showing 190 changed files with 844 additions and 2,496 deletions.
19 changes: 11 additions & 8 deletions crates/re_data_store/benches/arrow2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ use arrow2::array::{Array, FixedSizeListArray, PrimitiveArray, StructArray};
use criterion::Criterion;
use itertools::Itertools;

use re_log_types::example_components::MyIndex;
use re_log_types::DataCell;
use re_types::datagen::{build_some_instances, build_some_positions2d};
use re_types::datagen::build_some_positions2d;
use re_types::{
components::{InstanceKey, Position2D},
components::Position2D,
testing::{build_some_large_structs, LargeStruct},
};
use re_types_core::{Component, SizeBytes};
Expand Down Expand Up @@ -40,7 +41,7 @@ const NUM_INSTANCES: usize = 1;

#[derive(Debug, Clone, Copy)]
enum ArrayKind {
/// E.g. an array of `InstanceKey`.
/// E.g. an array of `MyIndex`.
Primitive,

/// E.g. an array of `Position2D`.
Expand Down Expand Up @@ -79,7 +80,7 @@ fn erased_clone(c: &mut Criterion) {

match kind {
ArrayKind::Primitive => {
let data = build_some_instances(NUM_INSTANCES);
let data = MyIndex::from_iter(0..NUM_INSTANCES as _);
bench_arrow(&mut group, &data);
bench_native(&mut group, &data);
}
Expand Down Expand Up @@ -198,7 +199,9 @@ fn estimated_size_bytes(c: &mut Criterion) {
fn generate_cells(kind: ArrayKind) -> Vec<DataCell> {
match kind {
ArrayKind::Primitive => (0..NUM_ROWS)
.map(|_| DataCell::from_native(build_some_instances(NUM_INSTANCES).as_slice()))
.map(|_| {
DataCell::from_native(MyIndex::from_iter(0..NUM_INSTANCES as _).as_slice())
})
.collect(),
ArrayKind::Struct => (0..NUM_ROWS)
.map(|_| {
Expand Down Expand Up @@ -312,9 +315,9 @@ fn estimated_size_bytes(c: &mut Criterion) {
.collect()
}

fn generate_keys() -> Vec<Vec<InstanceKey>> {
fn generate_indices() -> Vec<Vec<MyIndex>> {
(0..NUM_ROWS)
.map(|_| build_some_instances(NUM_INSTANCES))
.map(|_| MyIndex::from_iter(0..NUM_INSTANCES as _))
.collect()
}

Expand All @@ -325,7 +328,7 @@ fn estimated_size_bytes(c: &mut Criterion) {
}

match kind {
ArrayKind::Primitive => bench_std(&mut group, generate_keys()),
ArrayKind::Primitive => bench_std(&mut group, generate_indices()),
ArrayKind::Struct => bench_std(&mut group, generate_positions()),
ArrayKind::StructLarge => bench_std(&mut group, generate_rects()),
}
Expand Down
16 changes: 4 additions & 12 deletions crates/re_data_store/benches/data_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ use re_data_store::{
RangeQuery, TimeInt, TimeRange,
};
use re_log_types::{
build_frame_nr, DataCell, DataRow, DataTable, EntityPath, RowId, TableId, TimePoint, TimeType,
Timeline,
};
use re_types::datagen::build_some_instances;
use re_types::{
components::InstanceKey,
testing::{build_some_large_structs, LargeStruct},
build_frame_nr, example_components::MyIndex, DataCell, DataRow, DataTable, EntityPath, RowId,
TableId, TimePoint, TimeType, Timeline,
};
use re_types::testing::{build_some_large_structs, LargeStruct};
use re_types_core::{ComponentName, Loggable as _};

criterion_group!(
Expand Down Expand Up @@ -123,7 +119,6 @@ fn insert_same_time_point(c: &mut Criterion) {
b.iter(|| {
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
DataStoreConfig::default(),
);

Expand Down Expand Up @@ -398,9 +393,8 @@ fn build_rows_ex(
RowId::new(),
"large_structs",
time_point(frame_idx),
num_instances as _,
(
build_some_instances(num_instances),
MyIndex::from_iter(0..num_instances as _),
build_some_large_structs(num_instances),
),
)
Expand Down Expand Up @@ -432,10 +426,8 @@ fn build_rows_ex(
}

fn insert_rows(config: DataStoreConfig, rows: &[DataRow]) -> DataStore {
let cluster_key = InstanceKey::name();
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
cluster_key,
config,
);
for row in rows {
Expand Down
14 changes: 2 additions & 12 deletions crates/re_data_store/benches/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use re_data_store::{
use re_log_types::{
build_frame_nr, build_log_time, DataRow, DataTable, EntityPath, RowId, TableId, Time, TimePoint,
};
use re_types::components::InstanceKey;
use re_types_core::{AsComponents, ComponentBatch, ComponentName, Loggable as _};
use re_types_core::{AsComponents, ComponentBatch};

criterion_group!(benches, plotting_dashboard);
criterion_main!(benches);
Expand Down Expand Up @@ -85,13 +84,7 @@ fn plotting_dashboard(c: &mut Criterion) {

// Default config
group.bench_function("default", |b| {
let store = build_store(
Default::default(),
InstanceKey::name(),
false,
&mut timegen,
&mut datagen,
);
let store = build_store(Default::default(), false, &mut timegen, &mut datagen);
b.iter_batched(
|| store.clone(),
|mut store| {
Expand All @@ -117,7 +110,6 @@ fn plotting_dashboard(c: &mut Criterion) {
indexed_bucket_num_rows: num_rows_per_bucket,
..Default::default()
},
InstanceKey::name(),
false,
&mut timegen,
&mut datagen,
Expand All @@ -142,7 +134,6 @@ fn plotting_dashboard(c: &mut Criterion) {

fn build_store<FT, FD>(
config: DataStoreConfig,
cluster_key: ComponentName,
packed: bool,
timegen: &mut FT,
datagen: &mut FD,
Expand All @@ -153,7 +144,6 @@ where
{
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
cluster_key,
config,
);

Expand Down
3 changes: 1 addition & 2 deletions crates/re_data_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ pub use self::store_subscriber::{StoreSubscriber, StoreSubscriberHandle};
pub use self::store_write::{WriteError, WriteResult};

pub(crate) use self::store::{
ClusterCellCache, IndexedBucket, IndexedBucketInner, IndexedTable, MetadataRegistry,
StaticCell, StaticTable,
IndexedBucket, IndexedBucketInner, IndexedTable, MetadataRegistry, StaticCell, StaticTable,
};

// Re-exports
Expand Down
Loading

0 comments on commit 2395717

Please sign in to comment.