Skip to content

Commit

Permalink
Spine drop batches once logical compaction frontier is empty
Browse files Browse the repository at this point in the history
Once the logical compaction frontier is empty, there are no times
that can be represented in a a trace, which means that we're good to
drop all contents.

Signed-off-by: Moritz Hoffmann <[email protected]>
  • Loading branch information
antiguru committed Jun 28, 2023
1 parent 14417e6 commit fcd905c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/trace/implementations/spine_fueled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ where
fn set_logical_compaction(&mut self, frontier: AntichainRef<B::Time>) {
self.logical_frontier.clear();
self.logical_frontier.extend(frontier.iter().cloned());

// If the logical frontier is empty, we are not obliged to be able to represent any time,
// since no time is in advance of `[]`. In the case, we can drop all contents.
if self.logical_frontier.is_empty() {
self.drop_batches();
}
}
#[inline]
fn get_logical_compaction(&mut self) -> AntichainRef<B::Time> { self.logical_frontier.borrow() }
Expand Down Expand Up @@ -293,6 +299,11 @@ where
// merging the batch. This means it is a good time to perform amortized work proportional
// to the size of batch.
fn insert(&mut self, batch: Self::Batch) {
// If the logical frontier is empty, we are not obliged to be able to represent any time,
// since no time is in advance of `[]`. In the case, we can drop the batch.
if self.logical_frontier.is_empty() {
return
}

// Log the introduction of a batch.
self.logger.as_ref().map(|l| l.log(::logging::BatchEvent {
Expand Down

0 comments on commit fcd905c

Please sign in to comment.