Optimize range-delete aggregator call in merge helper.

Summary:
In the condition:
```
if (range_del_agg != nullptr &&
    range_del_agg->ShouldDelete(
        iter->key(),
        RangeDelAggregator::RangePositioningMode::kForwardTraversal) &&
    filter != CompactionFilter::Decision::kRemoveAndSkipUntil) {
...
}
```
it could be possible that all the work done in `range_del_agg->ShouldDelete` is wasted due to not having the right `filter` value later on.
Instead, check `filter` value before even calling `range_del_agg->ShouldDelete`, which is a much more involved function.
Closes https://github.com/facebook/rocksdb/pull/2690

Differential Revision: D5568931

Pulled By: sagar0

fbshipit-source-id: 17512d52360425c7ae9de7675383f5d7bc3dad58
main
Sagar Vemuri 7 years ago committed by Facebook Github Bot
parent 0d4a2b7330
commit 20dc5e74f2
  1. 7
      db/merge_helper.cc

@ -201,12 +201,11 @@ Status MergeHelper::MergeUntil(InternalIterator* iter,
ikey.sequence <= latest_snapshot_
? CompactionFilter::Decision::kKeep
: FilterMerge(orig_ikey.user_key, value_slice);
if (range_del_agg != nullptr &&
if (filter != CompactionFilter::Decision::kRemoveAndSkipUntil &&
range_del_agg != nullptr &&
range_del_agg->ShouldDelete(
iter->key(),
RangeDelAggregator::RangePositioningMode::kForwardTraversal) &&
filter != CompactionFilter::Decision::kRemoveAndSkipUntil) {
RangeDelAggregator::RangePositioningMode::kForwardTraversal)) {
filter = CompactionFilter::Decision::kRemove;
}
if (filter == CompactionFilter::Decision::kKeep ||

Loading…
Cancel
Save