You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2017/11/01 18:29:19 UTC

kudu git commit: Add a benchmark test for tablet deletion

Repository: kudu
Updated Branches:
  refs/heads/master bf91ac400 -> 6696b4eb4


Add a benchmark test for tablet deletion

Commit 15f3f9b2f optimizes the performance of group blocks deletion via
coalescing holes punch for log block manager. This patch adds a test to
benchmark tablet deletion for measuring actual improvement.

With 2.5k blocks on the tablet:

Before commit 15f3f9b2f:
I1030 15:25:38.700058 145431 tablet_server-test.cc:2336] Time spent deleting tablet: real 0.182s user 0.000s sys 0.000s
I1030 15:25:38.700096 145431 tablet_server-test.cc:2345] block_count_before_delete : 2500
I1030 15:25:38.700109 145431 tablet_server-test.cc:2346] log_block_manager_containers : 6
I1030 15:25:38.700124 145431 tablet_server-test.cc:2347] log_block_manager_holes_punched : 3000

After:
I1030 15:31:54.720243 24610 tablet_server-test.cc:2336] Time spent deleting tablet: real 0.062s	user 0.001s sys 0.000s
I1030 15:31:54.720258 24610 tablet_server-test.cc:2345] block_count_before_delete : 2500
I1030 15:31:54.720268 24610 tablet_server-test.cc:2346] log_block_manager_containers : 6
I1030 15:31:54.720280 24610 tablet_server-test.cc:2347] log_block_manager_holes_punched : 638

Change-Id: I6054b55f81e5a6e6febcbb5781ad8d776c49a5cf
Reviewed-on: http://gerrit.cloudera.org:8080/8420
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/6696b4eb
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/6696b4eb
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/6696b4eb

Branch: refs/heads/master
Commit: 6696b4eb4c19c9d06f736e6d8d0d8f21d123071f
Parents: bf91ac4
Author: hahao <ha...@cloudera.com>
Authored: Mon Oct 30 15:36:03 2017 -0700
Committer: Adar Dembo <ad...@cloudera.com>
Committed: Wed Nov 1 18:29:00 2017 +0000

----------------------------------------------------------------------
 src/kudu/tserver/tablet_server-test.cc | 53 +++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/6696b4eb/src/kudu/tserver/tablet_server-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_server-test.cc b/src/kudu/tserver/tablet_server-test.cc
index df35822..854bd1c 100644
--- a/src/kudu/tserver/tablet_server-test.cc
+++ b/src/kudu/tserver/tablet_server-test.cc
@@ -95,6 +95,7 @@
 #include "kudu/util/pb_util.h"
 #include "kudu/util/slice.h"
 #include "kudu/util/status.h"
+#include "kudu/util/stopwatch.h"
 #include "kudu/util/test_macros.h"
 #include "kudu/util/test_util.h"
 #include "kudu/util/thread.h"
@@ -127,6 +128,9 @@ DEFINE_int32(single_threaded_insert_latency_bench_insert_rows, 1000,
              "Number of rows to insert in the testing phase of the single threaded"
              " tablet server insert latency micro-benchmark");
 
+DEFINE_int32(delete_tablet_bench_num_flushes, 200,
+             "Number of disk row sets to flush in the delete tablet benchmark");
+
 DECLARE_bool(fail_dns_resolution);
 DECLARE_int32(metrics_retirement_age_ms);
 DECLARE_int32(scanner_batch_size_rows);
@@ -140,6 +144,8 @@ METRIC_DECLARE_counter(rows_updated);
 METRIC_DECLARE_counter(rows_deleted);
 METRIC_DECLARE_counter(scanners_expired);
 METRIC_DECLARE_gauge_uint64(log_block_manager_blocks_under_management);
+METRIC_DECLARE_gauge_uint64(log_block_manager_containers);
+METRIC_DECLARE_counter(log_block_manager_holes_punched);
 METRIC_DECLARE_gauge_size(active_scanners);
 METRIC_DECLARE_gauge_size(tablet_active_scanners);
 
@@ -2283,6 +2289,53 @@ TEST_F(TabletServerTest, TestDeleteTablet_TabletNotCreated) {
   }
 }
 
+TEST_F(TabletServerTest, TestDeleteTabletBenchmark) {
+  // Collect some related metrics.
+  scoped_refptr<AtomicGauge<uint64_t>> block_count =
+      METRIC_log_block_manager_blocks_under_management.Instantiate(
+          mini_server_->server()->metric_entity(), 0);
+  scoped_refptr<AtomicGauge<uint64_t>> container =
+      METRIC_log_block_manager_containers.Instantiate(
+          mini_server_->server()->metric_entity(), 0);
+  scoped_refptr<Counter> holes_punched =
+      METRIC_log_block_manager_holes_punched.Instantiate(
+          mini_server_->server()->metric_entity());
+
+  // Put some data in the tablet. We insert rows and flush immediately to
+  // ensure that there is enough blocks on disk to run the benchmark.
+  for (int i = 0; i < FLAGS_delete_tablet_bench_num_flushes; i++) {
+    NO_FATALS(InsertTestRowsRemote(i, 1));
+    ASSERT_OK(tablet_replica_->tablet()->Flush());
+  }
+  const int block_count_before_delete = block_count->value();
+
+  // Drop any local references to the tablet from within this test,
+  // so that when we delete it on the server, it's not held alive
+  // by the test code.
+  tablet_replica_.reset();
+
+  DeleteTabletRequestPB req;
+  DeleteTabletResponsePB resp;
+  RpcController rpc;
+
+  req.set_dest_uuid(mini_server_->server()->fs_manager()->uuid());
+  req.set_tablet_id(kTabletId);
+  req.set_delete_type(tablet::TABLET_DATA_DELETED);
+
+  // Send the call and measure the time spent deleting the tablet.
+  LOG_TIMING(INFO, "deleting tablet") {
+    SCOPED_TRACE(SecureDebugString(req));
+    ASSERT_OK(admin_proxy_->DeleteTablet(req, &resp, &rpc));
+    SCOPED_TRACE(SecureDebugString(resp));
+    ASSERT_FALSE(resp.has_error());
+  }
+
+  // Log the related metrics.
+  LOG(INFO) << "block_count_before_delete : " << block_count_before_delete;
+  LOG(INFO) << "log_block_manager_containers : " << container->value();
+  LOG(INFO) << "log_block_manager_holes_punched : " << holes_punched->value();
+}
+
 // Test that with concurrent requests to delete the same tablet, one wins and
 // the other fails, with no assertion failures. Regression test for KUDU-345.
 TEST_F(TabletServerTest, TestConcurrentDeleteTablet) {