提交 7dd16410 编写于 作者: A Abhishek Madan 提交者: Facebook Github Bot

Use vector in UncollapsedRangeDelMap (#4487)

Summary:
Using `./range_del_aggregator_bench --use_collapsed=false
--num_range_tombstones=5000 --num_runs=1000`, here are the results before and
after this change:

Before:
```
=========================
Results:
=========================
AddTombstones:           1822.61 us
ShouldDelete (first):    94.5286 us
```

After:
```
=========================
Results:
=========================
AddTombstones:           199.26 us
ShouldDelete (first):    38.9344 us
```
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4487

Differential Revision: D10347288

Pulled By: abhimadan

fbshipit-source-id: d44efe3a166d583acfdc3ec1199e0892f34dbfb7
上级 46dd8b1e
......@@ -37,8 +37,7 @@ struct ParsedInternalKeyComparator {
// An UncollapsedRangeDelMap is quick to create but slow to answer ShouldDelete
// queries.
class UncollapsedRangeDelMap : public RangeDelMap {
typedef std::multiset<TruncatedRangeTombstone, TombstoneStartKeyComparator>
Rep;
typedef std::vector<TruncatedRangeTombstone> Rep;
class Iterator : public RangeDelIterator {
const Rep& rep_;
......@@ -70,7 +69,7 @@ class UncollapsedRangeDelMap : public RangeDelMap {
public:
explicit UncollapsedRangeDelMap(const InternalKeyComparator* icmp)
: rep_(TombstoneStartKeyComparator(icmp)), icmp_(icmp) {}
: icmp_(icmp) {}
bool ShouldDelete(const ParsedInternalKey& parsed,
RangeDelPositioningMode mode) override {
......@@ -78,7 +77,7 @@ class UncollapsedRangeDelMap : public RangeDelMap {
assert(mode == RangeDelPositioningMode::kFullScan);
for (const auto& tombstone : rep_) {
if (icmp_->Compare(parsed, tombstone.start_key_) < 0) {
break;
continue;
}
if (parsed.sequence < tombstone.seq_ &&
icmp_->Compare(parsed, tombstone.end_key_) < 0) {
......@@ -101,7 +100,7 @@ class UncollapsedRangeDelMap : public RangeDelMap {
}
void AddTombstone(TruncatedRangeTombstone tombstone) override {
rep_.emplace(tombstone);
rep_.emplace_back(tombstone);
}
size_t Size() const override { return rep_.size(); }
......@@ -109,6 +108,7 @@ class UncollapsedRangeDelMap : public RangeDelMap {
void InvalidatePosition() override {} // no-op
std::unique_ptr<RangeDelIterator> NewIterator() override {
std::sort(rep_.begin(), rep_.end(), TombstoneStartKeyComparator(icmp_));
return std::unique_ptr<RangeDelIterator>(new Iterator(this->rep_));
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册