From 916594902761cb99036d1c7d37af48b474f528af Mon Sep 17 00:00:00 2001 From: Umesh Agashe Date: Tue, 16 Jan 2018 18:10:09 -0800 Subject: [PATCH] HBASE-18963 (addendum) Added a test to benchmark an impact of HBASE-18963 on write path --- .../hadoop/hbase/regionserver/TestHRegion.java | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java index 3c11b3164c469db739b4a9740f20166577a721b8..f4de5f96e553efab2c4d034a77933fa487cf4483 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java @@ -18,6 +18,8 @@ */ package org.apache.hadoop.hbase.regionserver; +import static java.util.concurrent.TimeUnit.MILLISECONDS; +import static java.util.concurrent.TimeUnit.NANOSECONDS; import static org.apache.hadoop.hbase.HBaseTestingUtility.COLUMNS; import static org.apache.hadoop.hbase.HBaseTestingUtility.fam1; import static org.apache.hadoop.hbase.HBaseTestingUtility.fam2; @@ -163,10 +165,12 @@ import org.apache.hadoop.hbase.wal.WALKeyImpl; import org.apache.hadoop.hbase.wal.WALProvider; import org.apache.hadoop.hbase.wal.WALProvider.Writer; import org.apache.hadoop.hbase.wal.WALSplitter; +import org.apache.hbase.thirdparty.com.google.common.base.Stopwatch; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.ClassRule; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -6493,6 +6497,58 @@ public class TestHRegion { } } + @Ignore + @Test + public void testMutateRowPerf() throws Exception { + int NUM_REQUESTS = 1000000; + int WARM_UP = 100; + long min = Long.MAX_VALUE; + long max = 0; + long total = 0; + + byte[] fam = Bytes.toBytes("family"); + byte[] qf = Bytes.toBytes("qualifier"); + byte[] val = Bytes.toBytes("value"); + + this.region = initHRegion(tableName, method, CONF, fam); + + Stopwatch watch = Stopwatch.createStarted(); + try { + for (int i = 0; i < (NUM_REQUESTS + WARM_UP); i++) { + byte[] row = Bytes.toBytes(i); + RowMutations rm = new RowMutations(row); + Put put = new Put(row); + put.addColumn(fam, qf, val); + rm.add(put); + + long before = watch.elapsed(NANOSECONDS); + this.region.mutateRow(rm); + long after = watch.elapsed(NANOSECONDS); + long t = after - before; + + if (i >= WARM_UP) { + // update results + total += t; + + if (min > t) { + min = t; + } + + if (max < t) { + max = t; + } + } + } + } finally { + watch.stop(); + HBaseTestingUtility.closeRegionAndWAL(this.region); + this.region = null; + } + LOG.info("Put request execution time - avg: " + total / NUM_REQUESTS + "ns, min: " + min + + "ns, max: " + max + "ns"); + LOG.info("Test exec time: " + watch.elapsed(MILLISECONDS) + "ms"); + } + /** * The same as HRegion class, the only difference is that instantiateHStore will * create a different HStore - HStoreForTesting. [HBASE-8518] -- 2.10.1 (Apple Git-78)