From 35cd754a6dfd5281556f9dae6d2099209ae46921 Mon Sep 17 00:00:00 2001 From: Abhishek Madan Date: Thu, 18 Oct 2018 17:16:36 -0700 Subject: [PATCH] Add writes_before_delete_range flag to db_bench (#4538) Summary: The new flag allows tombstones to be generated after enough keys have been written to the database, which makes it easier to ensure that tombstones cover a lot of keys. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4538 Differential Revision: D10455685 Pulled By: abhimadan fbshipit-source-id: f25d5421745a353c830dea12b79784e852056551 --- tools/db_bench_tool.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index d9e8eb2c7b..1a68ad6548 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -640,9 +640,11 @@ DEFINE_bool(optimize_filters_for_hits, false, DEFINE_uint64(delete_obsolete_files_period_micros, 0, "Ignored. Left here for backward compatibility"); +DEFINE_int64(writes_before_delete_range, 0, + "Number of writes before DeleteRange is called regularly."); + DEFINE_int64(writes_per_range_tombstone, 0, - "Number of writes between range " - "tombstones"); + "Number of writes between range tombstones"); DEFINE_int64(range_tombstone_width, 100, "Number of keys in tombstone's range"); @@ -1968,6 +1970,7 @@ class Benchmark { int prefix_size_; int64_t keys_per_prefix_; int64_t entries_per_batch_; + int64_t writes_before_delete_range_; int64_t writes_per_range_tombstone_; int64_t range_tombstone_width_; int64_t max_num_range_tombstones_; @@ -2495,6 +2498,7 @@ void VerifyDBFromDB(std::string& truth_db_name) { value_size_ = FLAGS_value_size; key_size_ = FLAGS_key_size; entries_per_batch_ = FLAGS_batch_size; + writes_before_delete_range_ = FLAGS_writes_before_delete_range; writes_per_range_tombstone_ = FLAGS_writes_per_range_tombstone; range_tombstone_width_ = FLAGS_range_tombstone_width; max_num_range_tombstones_ = FLAGS_max_num_range_tombstones; @@ -3876,9 +3880,13 @@ void VerifyDBFromDB(std::string& truth_db_name) { bytes += value_size_ + key_size_; ++num_written; if (writes_per_range_tombstone_ > 0 && - num_written / writes_per_range_tombstone_ <= + num_written > writes_before_delete_range_ && + (num_written - writes_before_delete_range_) / + writes_per_range_tombstone_ <= max_num_range_tombstones_ && - num_written % writes_per_range_tombstone_ == 0) { + (num_written - writes_before_delete_range_) % + writes_per_range_tombstone_ == + 0) { int64_t begin_num = key_gens[id]->Next(); if (FLAGS_expand_range_tombstones) { for (int64_t offset = 0; offset < range_tombstone_width_;