Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent gratuitous blueprint saves by not gc'ing when the blueprint hasn't changed #5793

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion crates/re_viewer_context/src/store_hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ pub struct StoreHub {
/// Was a recording ever activated? Used by the heuristic controlling the welcome screen.
was_recording_active: bool,

// The [`StoreGeneration`] from when the [`EntityDb`] was last saved
/// The [`StoreGeneration`] from when the [`EntityDb`] was last saved
blueprint_last_save: HashMap<StoreId, StoreGeneration>,

/// The [`StoreGeneration`] from when the [`EntityDb`] was last garbage collected
blueprint_last_gc: HashMap<StoreId, StoreGeneration>,
}

/// Load a blueprint from persisted storage, e.g. disk.
Expand Down Expand Up @@ -128,6 +131,7 @@ impl StoreHub {
was_recording_active: false,

blueprint_last_save: Default::default(),
blueprint_last_gc: Default::default(),
}
}

Expand Down Expand Up @@ -547,9 +551,16 @@ impl StoreHub {
.chain(self.default_blueprint_by_app_id.values())
{
if let Some(blueprint) = self.store_bundle.get_mut(blueprint_id) {
if self.blueprint_last_gc.get(blueprint_id) == Some(&blueprint.generation()) {
continue; // no change since last gc
}

// TODO(jleibs): Decide a better tuning for this. Would like to save a
// reasonable amount of history, or incremental snapshots.
blueprint.gc_everything_but_the_latest_row();

self.blueprint_last_gc
.insert(blueprint_id.clone(), blueprint.generation());
}
}
}
Expand Down Expand Up @@ -579,6 +590,8 @@ impl StoreHub {

if app_options.blueprint_gc {
blueprint.gc_everything_but_the_latest_row();
self.blueprint_last_gc
.insert(blueprint_id.clone(), blueprint.generation());
}

if let Some(saver) = &self.persistence.saver {
Expand Down
Loading