Skip to content

Commit

Permalink
fix nasty accounting issue due to arcs
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 26, 2024
1 parent 181f9db commit 4c5f37a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/re_query_cache2/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl StoreSubscriber for Caches {
// running while we're updating the invalidation flags.

{
re_tracing::profile_scope!("timeless");
re_tracing::profile_scope!("static");

// TODO(cmc): This is horribly stupid and slow and can easily be made faster by adding
// yet another layer of caching indirection.
Expand Down
14 changes: 13 additions & 1 deletion crates/re_query_cache2/src/latest_at/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,19 @@ impl SizeBytes for LatestAtCache {
.keys()
.map(|k| k.total_size_bytes())
.sum::<u64>();
let per_data_time = per_data_time.total_size_bytes();
// NOTE: per query time buckets are just pointers, don't count them.

let per_data_time_keys = per_data_time
.keys()
.map(|k| k.total_size_bytes())
.sum::<u64>();
let per_data_time_values = per_data_time
.values()
// NOTE: make sure to dereference the Arc, else this will account for zero (assumed amortized!)
.map(|arc| (**arc).total_size_bytes())
.sum::<u64>();

let per_data_time = per_data_time_keys + per_data_time_values;
let pending_invalidations = pending_invalidations.total_size_bytes();

per_query_time + per_data_time + pending_invalidations
Expand Down
4 changes: 2 additions & 2 deletions crates/re_query_cache2/src/latest_at/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ impl SizeBytes for CachedLatestAtComponentResults {
cached_dense,
} = self;

index.heap_size_bytes()
+ promise.heap_size_bytes()
index.total_size_bytes()
+ promise.total_size_bytes()
+ cached_dense
.get()
.map_or(0, |data| data.dyn_total_size_bytes())
Expand Down
6 changes: 3 additions & 3 deletions crates/re_query_cache2/src/range/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,9 @@ impl SizeBytes for CachedRangeComponentResultsInner {
cached_dense,
} = self;

indices.heap_size_bytes()
+ promises_front.heap_size_bytes()
+ promises_back.heap_size_bytes()
indices.total_size_bytes()
+ promises_front.total_size_bytes()
+ promises_back.total_size_bytes()
+ cached_dense
.as_ref()
.map_or(0, |data| data.dyn_total_size_bytes())
Expand Down

0 comments on commit 4c5f37a

Please sign in to comment.