@@ -5,6 +5,7 @@ use glam::DAffine3;
55use itertools:: { Either , izip} ;
66use nohash_hasher:: IntMap ;
77use parking_lot:: Mutex ;
8+ use re_byte_size:: SizeBytes ;
89
910use crate :: frame_id_registry:: FrameIdRegistry ;
1011use crate :: {
@@ -17,8 +18,7 @@ use crate::{
1718} ;
1819
1920use re_arrow_util:: ArrowArrayDowncastRef as _;
20- use re_chunk_store:: external:: arrow;
21- use re_chunk_store:: { Chunk , LatestAtQuery } ;
21+ use re_chunk_store:: { Chunk , LatestAtQuery , external:: arrow} ;
2222use re_entity_db:: EntityDb ;
2323use re_log_types:: { EntityPath , TimeInt , TimelineName } ;
2424use re_types:: { ComponentIdentifier , archetypes, components} ;
@@ -61,6 +61,20 @@ impl Default for TransformResolutionCache {
6161 }
6262}
6363
64+ impl SizeBytes for TransformResolutionCache {
65+ fn heap_size_bytes ( & self ) -> u64 {
66+ let Self {
67+ frame_id_registry,
68+ per_timeline,
69+ static_timeline,
70+ } = self ;
71+
72+ frame_id_registry. heap_size_bytes ( )
73+ + per_timeline. heap_size_bytes ( )
74+ + static_timeline. heap_size_bytes ( )
75+ }
76+ }
77+
6478/// A transform from a child frame to a parent frame.
6579#[ derive( Clone , Debug , PartialEq ) ]
6680pub struct ParentFromChildTransform {
@@ -71,6 +85,14 @@ pub struct ParentFromChildTransform {
7185 pub transform : DAffine3 ,
7286}
7387
88+ impl SizeBytes for ParentFromChildTransform {
89+ fn heap_size_bytes ( & self ) -> u64 {
90+ let Self { parent, transform } = self ;
91+
92+ parent. heap_size_bytes ( ) + transform. heap_size_bytes ( )
93+ }
94+ }
95+
7496/// Cached transforms for a single timeline.
7597///
7698/// Includes any static transforms that may apply globally.
@@ -243,6 +265,20 @@ impl CachedTransformsForTimeline {
243265 }
244266}
245267
268+ impl SizeBytes for CachedTransformsForTimeline {
269+ fn heap_size_bytes ( & self ) -> u64 {
270+ let Self {
271+ per_child_frame_transforms,
272+ non_recursive_clears,
273+ recursive_clears,
274+ } = self ;
275+
276+ per_child_frame_transforms. heap_size_bytes ( )
277+ + non_recursive_clears. heap_size_bytes ( )
278+ + recursive_clears. heap_size_bytes ( )
279+ }
280+ }
281+
246282#[ derive( Clone , Debug , PartialEq ) ]
247283enum CachedTransformValue < T > {
248284 /// Cache is invalidated, we don't know what state we're in.
@@ -255,6 +291,15 @@ enum CachedTransformValue<T> {
255291 Cleared ,
256292}
257293
294+ impl < T : SizeBytes > SizeBytes for CachedTransformValue < T > {
295+ fn heap_size_bytes ( & self ) -> u64 {
296+ match self {
297+ Self :: Resident ( item) => item. heap_size_bytes ( ) ,
298+ Self :: Invalidated | Self :: Cleared => 0 ,
299+ }
300+ }
301+ }
302+
258303type FrameTransformTimeMap = BTreeMap < TimeInt , CachedTransformValue < ParentFromChildTransform > > ;
259304
260305type PoseTransformTimeMap = BTreeMap < TimeInt , CachedTransformValue < Vec < DAffine3 > > > ;
@@ -344,6 +389,20 @@ impl TransformsForChildFrameEvents {
344389 }
345390}
346391
392+ impl SizeBytes for TransformsForChildFrameEvents {
393+ fn heap_size_bytes ( & self ) -> u64 {
394+ let Self {
395+ frame_transforms,
396+ pose_transforms,
397+ pinhole_projections,
398+ } = self ;
399+
400+ frame_transforms. heap_size_bytes ( )
401+ + pose_transforms. heap_size_bytes ( )
402+ + pinhole_projections. heap_size_bytes ( )
403+ }
404+ }
405+
347406/// Cached transforms from a single child frame to a (potentially changing) parent frame over time.
348407///
349408/// Incorporates any static transforms that may apply to this entity.
@@ -391,6 +450,23 @@ impl PartialEq for TransformsForChildFrame {
391450 }
392451}
393452
453+ impl SizeBytes for TransformsForChildFrame {
454+ fn heap_size_bytes ( & self ) -> u64 {
455+ let Self {
456+ associated_entity_path,
457+ child_frame,
458+ events,
459+
460+ #[ cfg( debug_assertions) ]
461+ timeline : _,
462+ } = self ;
463+
464+ associated_entity_path. heap_size_bytes ( )
465+ + child_frame. heap_size_bytes ( )
466+ + events. lock ( ) . heap_size_bytes ( )
467+ }
468+ }
469+
394470fn add_invalidated_entry_if_not_already_cleared < T : PartialEq > (
395471 transforms : & mut BTreeMap < TimeInt , CachedTransformValue < T > > ,
396472 time : TimeInt ,
@@ -424,6 +500,22 @@ pub struct ResolvedPinholeProjection {
424500 pub view_coordinates : components:: ViewCoordinates ,
425501}
426502
503+ impl SizeBytes for ResolvedPinholeProjection {
504+ fn heap_size_bytes ( & self ) -> u64 {
505+ let Self {
506+ parent,
507+ image_from_camera,
508+ resolution,
509+ view_coordinates,
510+ } = self ;
511+
512+ parent. heap_size_bytes ( )
513+ + image_from_camera. heap_size_bytes ( )
514+ + resolution. heap_size_bytes ( )
515+ + view_coordinates. heap_size_bytes ( )
516+ }
517+ }
518+
427519impl TransformsForChildFrame {
428520 fn new (
429521 associated_entity_path : EntityPath ,
0 commit comments