Skip to content

Commit

Permalink
GC the blueprints before saving while preserving the current state (#…
Browse files Browse the repository at this point in the history
…3148)

Resolves: #3098
Related to: #1803

Because blueprints used timeless data and timeless data wasn't GC'd, we
previously had no great way to clean up blueprints.

This PR paves the way for better overall GC behavior in the future but
doesn't change the default behavior yet.

This PR:
- Introduces a new `GarbageCollectionOptions` instead of just providing
a target. This allows you to configure whether you want to gc the
timeless data, and additionally how many latest_at values you want to
preserve.
 - Introduces a new gc target: Everything.
- Calculates a set of protected rows for every component based on the
last relevant row across every timeline (including timeless).
- Modifies both `gc_drop_at_least_num_bytes` and the new `gc_everything`
to respect the protected rows during gc.
 - Modifies the store_hub to gc the blueprint before saving it.

Photogrammetry with `--no-frames` is another "worst-case" for blueprint
because every image is a space-view, so you can easily create a huge
blueprint history by repeatedly resetting the blueprint.

![image](https://github.com/rerun-io/rerun/assets/3312232/03df3d06-a780-47b3-b0d9-aaf564793230)

* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3148) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/3148)
- [Docs
preview](https://rerun.io/preview/60f3747383780c50886ac781bdf81b32fbff76bd/docs)
- [Examples
preview](https://rerun.io/preview/60f3747383780c50886ac781bdf81b32fbff76bd/examples)
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
  • Loading branch information
jleibs committed Aug 31, 2023
1 parent d35c50c commit 6426bb0
Show file tree
Hide file tree
Showing 10 changed files with 600 additions and 86 deletions.
19 changes: 14 additions & 5 deletions crates/re_arrow_store/benches/data_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use arrow2::array::UnionArray;
use criterion::{criterion_group, criterion_main, Criterion};

use re_arrow_store::{
DataStore, DataStoreConfig, GarbageCollectionTarget, LatestAtQuery, RangeQuery, TimeInt,
TimeRange,
DataStore, DataStoreConfig, GarbageCollectionOptions, GarbageCollectionTarget, LatestAtQuery,
RangeQuery, TimeInt, TimeRange,
};
use re_components::{
datagen::{build_frame_nr, build_some_instances, build_some_rects},
Expand Down Expand Up @@ -276,7 +276,12 @@ fn gc(c: &mut Criterion) {
let store = insert_table(Default::default(), InstanceKey::name(), &table);
b.iter(|| {
let mut store = store.clone();
let (_, stats_diff) = store.gc(GarbageCollectionTarget::DropAtLeastFraction(1.0 / 3.0));
let (_, stats_diff) = store.gc(GarbageCollectionOptions {
target: GarbageCollectionTarget::DropAtLeastFraction(1.0 / 3.0),
gc_timeless: false,
protect_latest: 0,
purge_empty_tables: false,
});
stats_diff
});
});
Expand All @@ -294,8 +299,12 @@ fn gc(c: &mut Criterion) {
);
b.iter(|| {
let mut store = store.clone();
let (_, stats_diff) =
store.gc(GarbageCollectionTarget::DropAtLeastFraction(1.0 / 3.0));
let (_, stats_diff) = store.gc(GarbageCollectionOptions {
target: GarbageCollectionTarget::DropAtLeastFraction(1.0 / 3.0),
gc_timeless: false,
protect_latest: 0,
purge_empty_tables: false,
});
stats_diff
});
});
Expand Down
2 changes: 1 addition & 1 deletion crates/re_arrow_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub mod test_util;

pub use self::arrow_util::ArrayExt;
pub use self::store::{DataStore, DataStoreConfig, StoreGeneration};
pub use self::store_gc::GarbageCollectionTarget;
pub use self::store_gc::{GarbageCollectionOptions, GarbageCollectionTarget};
pub use self::store_read::{LatestAtQuery, RangeQuery};
pub use self::store_stats::{DataStoreRowStats, DataStoreStats};
pub use self::store_write::{WriteError, WriteResult};
Expand Down

0 comments on commit 6426bb0

Please sign in to comment.