Skip to content

Commit

Permalink
remove dont_protect
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jul 4, 2024
1 parent 6b10cac commit c15ff0c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 60 deletions.
54 changes: 12 additions & 42 deletions crates/re_chunk_store/src/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use std::{
};

use ahash::{HashMap, HashSet};
use nohash_hasher::{IntMap, IntSet};
use re_chunk::{Chunk, ChunkId};
use nohash_hasher::IntMap;
use web_time::Instant;

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

Expand Down Expand Up @@ -51,18 +51,6 @@ pub struct GarbageCollectionOptions {

/// How many component revisions to preserve on each timeline.
pub protect_latest: usize,

/// Components which should not be protected from GC when using
/// [`GarbageCollectionOptions::protect_latest`].
//
// TODO(#6552): this should be removed in favor of a dedicated `remove_entity_path` API.
pub dont_protect_components: IntSet<ComponentName>,

/// Timelines which should not be protected from GC when using `protect_latest`
/// [`GarbageCollectionOptions::protect_latest`].
//
// TODO(#6552): this should be removed in favor of a dedicated `remove_entity_path` API.
pub dont_protect_timelines: IntSet<Timeline>,
}

impl GarbageCollectionOptions {
Expand All @@ -71,8 +59,6 @@ impl GarbageCollectionOptions {
target: GarbageCollectionTarget::Everything,
time_budget: std::time::Duration::MAX,
protect_latest: 0,
dont_protect_components: Default::default(),
dont_protect_timelines: Default::default(),
}
}
}
Expand Down Expand Up @@ -126,11 +112,7 @@ impl ChunkStore {
let total_num_chunks_before = stats_before.total().num_chunks;
let total_num_rows_before = stats_before.total().total_num_rows;

let protected_chunk_ids = self.find_all_protected_chunk_ids(
options.protect_latest,
&options.dont_protect_components,
&options.dont_protect_timelines,
);
let protected_chunk_ids = self.find_all_protected_chunk_ids(options.protect_latest);

let diffs = match options.target {
GarbageCollectionTarget::DropAtLeastFraction(p) => {
Expand Down Expand Up @@ -215,12 +197,7 @@ impl ChunkStore {
//
// TODO(jleibs): More complex functionality might required expanding this to also
// *ignore* specific entities, components, timelines, etc. for this protection.
fn find_all_protected_chunk_ids(
&self,
target_count: usize,
dont_protect_components: &IntSet<ComponentName>,
dont_protect_timelines: &IntSet<Timeline>,
) -> BTreeSet<ChunkId> {
fn find_all_protected_chunk_ids(&self, target_count: usize) -> BTreeSet<ChunkId> {
re_tracing::profile_function!();

if target_count == 0 {
Expand All @@ -230,19 +207,10 @@ impl ChunkStore {
self.temporal_chunk_ids_per_entity
.values()
.flat_map(|temporal_chunk_ids_per_timeline| {
temporal_chunk_ids_per_timeline
.iter()
.filter_map(|(timeline, temporal_chunk_ids_per_component)| {
(!dont_protect_timelines.contains(timeline))
.then_some(temporal_chunk_ids_per_component)
})
.flat_map(|temporal_chunk_ids_per_component| {
temporal_chunk_ids_per_component
.iter()
.filter(|(component_name, _)| {
!dont_protect_components.contains(component_name)
})
.flat_map(|(_, temporal_chunk_ids_per_time)| {
temporal_chunk_ids_per_timeline.iter().flat_map(
|(_timeline, temporal_chunk_ids_per_component)| {
temporal_chunk_ids_per_component.iter().flat_map(
|(_, temporal_chunk_ids_per_time)| {
temporal_chunk_ids_per_time
.per_start_time
.last_key_value()
Expand All @@ -261,8 +229,10 @@ impl ChunkStore {
.into_iter()
.rev()
.take(target_count)
})
})
},
)
},
)
})
.collect()
}
Expand Down
6 changes: 0 additions & 6 deletions crates/re_chunk_store/tests/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ fn simple() -> anyhow::Result<()> {
let (_store_events, stats_diff) = store.gc(&GarbageCollectionOptions {
target: GarbageCollectionTarget::DropAtLeastFraction(1.0 / 3.0),
protect_latest: 0,
dont_protect_components: Default::default(),
dont_protect_timelines: Default::default(),
time_budget: std::time::Duration::MAX,
});

Expand Down Expand Up @@ -174,8 +172,6 @@ fn simple_static() -> anyhow::Result<()> {
store.gc(&GarbageCollectionOptions {
target: GarbageCollectionTarget::Everything,
protect_latest: 1,
dont_protect_components: Default::default(),
dont_protect_timelines: Default::default(),
time_budget: std::time::Duration::MAX,
});

Expand Down Expand Up @@ -265,8 +261,6 @@ fn protected() -> anyhow::Result<()> {
store.gc(&GarbageCollectionOptions {
target: GarbageCollectionTarget::Everything,
protect_latest: 1,
dont_protect_components: Default::default(),
dont_protect_timelines: Default::default(),
time_budget: std::time::Duration::MAX,
});

Expand Down
12 changes: 0 additions & 12 deletions crates/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use re_log_types::{
ApplicationId, ComponentPath, EntityPath, EntityPathHash, LogMsg, ResolvedTimeRange,
ResolvedTimeRangeF, SetStoreInfo, StoreId, StoreInfo, StoreKind, Timeline,
};
use re_types_core::{Archetype, Loggable};

use crate::{Error, TimesPerTimeline};

Expand Down Expand Up @@ -386,15 +385,6 @@ impl EntityDb {
self.gc(&GarbageCollectionOptions {
target: GarbageCollectionTarget::Everything,
protect_latest: 1, // TODO(jleibs): Bump this after we have an undo buffer
dont_protect_components: [
re_types_core::components::ClearIsRecursive::name(),
re_types_core::archetypes::Clear::indicator().name(),
]
.into_iter()
.collect(),
dont_protect_timelines: [Timeline::log_tick(), Timeline::log_time()]
.into_iter()
.collect(),
time_budget: DEFAULT_GC_TIME_BUDGET,
});
}
Expand All @@ -407,8 +397,6 @@ impl EntityDb {
self.gc(&GarbageCollectionOptions {
target: GarbageCollectionTarget::DropAtLeastFraction(fraction_to_purge as _),
protect_latest: 1,
dont_protect_components: Default::default(),
dont_protect_timelines: Default::default(),
time_budget: DEFAULT_GC_TIME_BUDGET,
});
}
Expand Down

0 comments on commit c15ff0c

Please sign in to comment.