Skip to content

Commit

Permalink
Move trait SizeBytes to new crate re_byte_size
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 19, 2024
1 parent 662e404 commit 0a6356a
Show file tree
Hide file tree
Showing 336 changed files with 782 additions and 614 deletions.
24 changes: 24 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2398,6 +2398,7 @@ name = "extend_viewer_ui"
version = "0.22.0-alpha.1+dev"
dependencies = [
"mimalloc",
"re_byte_size",
"re_crash_handler",
"re_sdk_comms",
"re_viewer",
Expand Down Expand Up @@ -5605,6 +5606,17 @@ dependencies = [
"walkdir",
]

[[package]]
name = "re_byte_size"
version = "0.22.0-alpha.1+dev"
dependencies = [
"arrow",
"half",
"re_arrow2",
"re_tuid",
"smallvec",
]

[[package]]
name = "re_capabilities"
version = "0.22.0-alpha.1+dev"
Expand Down Expand Up @@ -5637,6 +5649,7 @@ dependencies = [
"nohash-hasher",
"rand",
"re_arrow2",
"re_byte_size",
"re_error",
"re_format",
"re_format_arrow",
Expand Down Expand Up @@ -5667,6 +5680,7 @@ dependencies = [
"parking_lot",
"rand",
"re_arrow2",
"re_byte_size",
"re_chunk",
"re_format",
"re_log",
Expand All @@ -5689,6 +5703,7 @@ dependencies = [
"egui",
"egui_extras",
"itertools 0.13.0",
"re_byte_size",
"re_chunk_store",
"re_format",
"re_log_types",
Expand All @@ -5705,6 +5720,7 @@ dependencies = [
"egui",
"egui_extras",
"egui_plot",
"re_byte_size",
"re_data_source",
"re_data_ui",
"re_format",
Expand Down Expand Up @@ -5811,6 +5827,7 @@ dependencies = [
"image",
"itertools 0.13.0",
"nohash-hasher",
"re_byte_size",
"re_capabilities",
"re_chunk_store",
"re_entity_db",
Expand Down Expand Up @@ -5894,6 +5911,7 @@ dependencies = [
"parking_lot",
"rand",
"re_build_info",
"re_byte_size",
"re_chunk",
"re_chunk_store",
"re_format",
Expand Down Expand Up @@ -6030,6 +6048,7 @@ dependencies = [
"num-traits",
"re_arrow2",
"re_build_info",
"re_byte_size",
"re_format",
"re_log",
"re_protos",
Expand Down Expand Up @@ -6130,6 +6149,7 @@ dependencies = [
"paste",
"rand",
"re_arrow2",
"re_byte_size",
"re_chunk",
"re_chunk_store",
"re_error",
Expand Down Expand Up @@ -6261,6 +6281,7 @@ dependencies = [
"re_arrow2",
"re_build_info",
"re_build_tools",
"re_byte_size",
"re_chunk",
"re_chunk_store",
"re_data_loader",
Expand Down Expand Up @@ -6425,6 +6446,7 @@ dependencies = [
"rayon",
"re_arrow2",
"re_build_tools",
"re_byte_size",
"re_format",
"re_log",
"re_log_types",
Expand Down Expand Up @@ -6486,6 +6508,7 @@ dependencies = [
"nohash-hasher",
"once_cell",
"re_arrow2",
"re_byte_size",
"re_case",
"re_error",
"re_string_interner",
Expand Down Expand Up @@ -7200,6 +7223,7 @@ dependencies = [
"re_analytics",
"re_build_info",
"re_build_tools",
"re_byte_size",
"re_capabilities",
"re_chunk",
"re_chunk_store",
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ re_format = { path = "crates/utils/re_format", version = "=0.22.0-alpha.1", defa
re_int_histogram = { path = "crates/utils/re_int_histogram", version = "=0.22.0-alpha.1", default-features = false }
re_log = { path = "crates/utils/re_log", version = "=0.22.0-alpha.1", default-features = false }
re_memory = { path = "crates/utils/re_memory", version = "=0.22.0-alpha.1", default-features = false }
re_byte_size = { path = "crates/utils/re_byte_size", version = "=0.22.0-alpha.1", default-features = false }
re_smart_channel = { path = "crates/utils/re_smart_channel", version = "=0.22.0-alpha.1", default-features = false }
re_string_interner = { path = "crates/utils/re_string_interner", version = "=0.22.0-alpha.1", default-features = false }
re_tracing = { path = "crates/utils/re_tracing", version = "=0.22.0-alpha.1", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions crates/build/re_types_builder/src/codegen/rust/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ fn quote_struct(
};

quote! {
impl ::re_types_core::SizeBytes for #name {
impl ::re_byte_size::SizeBytes for #name {
#[inline]
fn heap_size_bytes(&self) -> u64 {
#heap_size_bytes_impl
Expand Down Expand Up @@ -443,7 +443,7 @@ fn quote_union(
};

quote! {
impl ::re_types_core::SizeBytes for #name {
impl ::re_byte_size::SizeBytes for #name {
#[inline]
fn heap_size_bytes(&self) -> u64 {
#![allow(clippy::match_same_arms)]
Expand Down Expand Up @@ -630,7 +630,7 @@ fn quote_enum(
}
}

impl ::re_types_core::SizeBytes for #name {
impl ::re_byte_size::SizeBytes for #name {
#[inline]
fn heap_size_bytes(&self) -> u64 {
0
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_chunk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ arrow = ["arrow2/arrow"]
[dependencies]

# Rerun
re_byte_size.workspace = true
re_error.workspace = true
re_format.workspace = true
re_format_arrow.workspace = true
Expand Down
5 changes: 3 additions & 2 deletions crates/store/re_chunk/src/batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use arrow2::array::{Array as Arrow2Array, PrimitiveArray as Arrow2PrimitiveArray
use crossbeam::channel::{Receiver, Sender};
use nohash_hasher::IntMap;

use re_byte_size::SizeBytes as _;
use re_log_types::{EntityPath, ResolvedTimeRange, TimeInt, TimePoint, Timeline};
use re_types_core::{ComponentDescriptor, SizeBytes as _};
use re_types_core::ComponentDescriptor;

use crate::{chunk::ChunkComponents, Chunk, ChunkId, ChunkResult, RowId, TimeColumn};

Expand Down Expand Up @@ -695,7 +696,7 @@ impl PendingRow {
}
}

impl re_types_core::SizeBytes for PendingRow {
impl re_byte_size::SizeBytes for PendingRow {
#[inline]
fn heap_size_bytes(&self) -> u64 {
let Self {
Expand Down
8 changes: 4 additions & 4 deletions crates/store/re_chunk/src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ use arrow2::{
},
Either,
};

use itertools::{izip, Itertools};
use nohash_hasher::IntMap;

use re_byte_size::SizeBytes as _;
use re_log_types::{EntityPath, ResolvedTimeRange, Time, TimeInt, TimePoint, Timeline};
use re_types_core::{
ComponentDescriptor, ComponentName, DeserializationError, Loggable, LoggableBatch,
SerializationError, SizeBytes,
SerializationError,
};

use crate::{ChunkId, RowId};
Expand Down Expand Up @@ -1399,7 +1399,7 @@ impl TimeColumn {
}
}

impl re_types_core::SizeBytes for Chunk {
impl re_byte_size::SizeBytes for Chunk {
#[inline]
fn heap_size_bytes(&self) -> u64 {
let Self {
Expand Down Expand Up @@ -1428,7 +1428,7 @@ impl re_types_core::SizeBytes for Chunk {
}
}

impl re_types_core::SizeBytes for TimeColumn {
impl re_byte_size::SizeBytes for TimeColumn {
#[inline]
fn heap_size_bytes(&self) -> u64 {
let Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/store/re_chunk/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use arrow::array::ArrayRef;
use arrow2::array::Array as Arrow2Array;

use re_log_types::{TimeInt, Timeline};
use re_types_core::{Component, ComponentName, SizeBytes};
use re_types_core::{Component, ComponentName};

use crate::{Chunk, ChunkResult, RowId};

Expand Down Expand Up @@ -175,7 +175,7 @@ impl std::ops::Deref for UnitChunkShared {
}
}

impl SizeBytes for UnitChunkShared {
impl re_byte_size::SizeBytes for UnitChunkShared {
#[inline]
fn heap_size_bytes(&self) -> u64 {
Chunk::heap_size_bytes(&self.0)
Expand Down
4 changes: 2 additions & 2 deletions crates/store/re_chunk/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl ChunkId {
}
}

impl re_types_core::SizeBytes for ChunkId {
impl re_byte_size::SizeBytes for ChunkId {
#[inline]
fn heap_size_bytes(&self) -> u64 {
0
Expand Down Expand Up @@ -223,7 +223,7 @@ impl RowId {
}
}

impl re_types_core::SizeBytes for RowId {
impl re_byte_size::SizeBytes for RowId {
#[inline]
fn heap_size_bytes(&self) -> u64 {
0
Expand Down
5 changes: 3 additions & 2 deletions crates/store/re_chunk/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ use arrow2::{
Schema as Arrow2Schema, TimeUnit as ArrowTimeUnit,
},
};

use itertools::Itertools;
use nohash_hasher::IntMap;

use re_byte_size::SizeBytes as _;
use re_log_types::{EntityPath, Timeline};
use re_types_core::{Component as _, ComponentDescriptor, Loggable as _, SizeBytes};
use re_types_core::{Component as _, ComponentDescriptor, Loggable as _};

use crate::{chunk::ChunkComponents, Chunk, ChunkError, ChunkId, ChunkResult, RowId, TimeColumn};

Expand Down
1 change: 1 addition & 0 deletions crates/store/re_chunk_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ deadlock_detection = ["parking_lot/deadlock_detection"]

[dependencies]
# Rerun dependencies:
re_byte_size.workspace = true
re_chunk.workspace = true
re_format.workspace = true
re_log = { workspace = true, features = ["setup"] }
Expand Down
3 changes: 2 additions & 1 deletion crates/store/re_chunk_store/src/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ use std::{

use ahash::{HashMap, HashSet};
use nohash_hasher::IntMap;
use re_byte_size::SizeBytes;
use web_time::Instant;

use re_chunk::{Chunk, ChunkId};
use re_log_types::{EntityPath, ResolvedTimeRange, TimeInt, Timeline};
use re_types_core::{ComponentName, SizeBytes};
use re_types_core::ComponentName;

use crate::{
store::ChunkIdSetPerTime, ChunkStore, ChunkStoreChunkStats, ChunkStoreDiff, ChunkStoreDiffKind,
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_chunk_store/src/stats.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::{atomic::Ordering, Arc};

use re_chunk::{Chunk, ComponentName, EntityPath, Timeline};
use re_types_core::SizeBytes;
use re_byte_size::SizeBytes;

use crate::ChunkStore;

Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_chunk_store/src/writes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use arrow2::array::{Array as _, ListArray as Arrow2ListArray};
use itertools::Itertools as _;

use re_chunk::{Chunk, EntityPath, RowId};
use re_types_core::SizeBytes;
use re_byte_size::SizeBytes;

use crate::{
store::ChunkIdSetPerTime, ChunkStore, ChunkStoreChunkStats, ChunkStoreConfig, ChunkStoreDiff,
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_entity_db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ serde = ["dep:serde", "re_log_types/serde"]

[dependencies]
re_build_info.workspace = true
re_byte_size.workspace = true
re_chunk = { workspace = true, features = ["serde"] }
re_chunk_store.workspace = true
re_format.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ impl EntityDb {
}
}

impl re_types_core::SizeBytes for EntityDb {
impl re_byte_size::SizeBytes for EntityDb {
#[inline]
fn heap_size_bytes(&self) -> u64 {
// TODO(emilk): size of entire EntityDb, including secondary indices etc
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_log_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ serde = [

# Rerun
re_build_info.workspace = true
re_byte_size.workspace = true
re_format.workspace = true
re_log.workspace = true
re_protos.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion crates/store/re_log_types/src/example_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
use std::sync::Arc;

use re_types_core::{Component, ComponentDescriptor, DeserializationError, Loggable, SizeBytes};
use re_byte_size::SizeBytes;
use re_types_core::{Component, ComponentDescriptor, DeserializationError, Loggable};

// ----------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_log_types/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#[derive(Copy, Clone, Eq, PartialOrd, Ord)]
pub struct Hash64(u64);

impl re_types_core::SizeBytes for Hash64 {
impl re_byte_size::SizeBytes for Hash64 {
#[inline]
fn heap_size_bytes(&self) -> u64 {
0
Expand Down
4 changes: 2 additions & 2 deletions crates/store/re_log_types/src/path/entity_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::sync::Arc;
use ahash::{HashMap, HashSet};
use itertools::Itertools as _;

use re_byte_size::SizeBytes;
use re_string_interner::InternedString;
use re_types_core::SizeBytes;

use crate::{hash::Hash64, EntityPathPart};

Expand All @@ -14,7 +14,7 @@ use crate::{hash::Hash64, EntityPathPart};
#[derive(Copy, Clone, Eq, PartialOrd, Ord)]
pub struct EntityPathHash(Hash64);

impl re_types_core::SizeBytes for EntityPathHash {
impl re_byte_size::SizeBytes for EntityPathHash {
#[inline]
fn heap_size_bytes(&self) -> u64 {
self.0.heap_size_bytes()
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_log_types/src/resolved_time_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl ResolvedTimeRange {
}
}

impl re_types_core::SizeBytes for ResolvedTimeRange {
impl re_byte_size::SizeBytes for ResolvedTimeRange {
#[inline]
fn heap_size_bytes(&self) -> u64 {
0
Expand Down
2 changes: 1 addition & 1 deletion crates/store/re_log_types/src/time_point/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl TimePoint {
}
}

impl re_types_core::SizeBytes for TimePoint {
impl re_byte_size::SizeBytes for TimePoint {
#[inline]
fn heap_size_bytes(&self) -> u64 {
self.0.heap_size_bytes()
Expand Down
Loading

0 comments on commit 0a6356a

Please sign in to comment.