diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java index 710ed6d9844..cb43877f9f2 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java @@ -103,6 +103,12 @@ public class ClassSize { /** Overhead for timerange */ public static final int TIMERANGE; + /** Overhead for TimeRangeTracker */ + public static final int TIMERANGE_TRACKER; + + /** Overhead for KeyValueSkipListSet */ + public static final int KEYVALUE_SKIPLIST_SET; + /* Are we running on jdk7? */ private static final boolean JDK7; static { @@ -181,6 +187,10 @@ public class ClassSize { COPYONWRITE_ARRAYLIST = align(OBJECT + (2 * REFERENCE) + ARRAY); TIMERANGE = align(ClassSize.OBJECT + Bytes.SIZEOF_LONG * 2 + Bytes.SIZEOF_BOOLEAN); + + TIMERANGE_TRACKER = align(ClassSize.OBJECT + Bytes.SIZEOF_LONG * 2); + + KEYVALUE_SKIPLIST_SET = align(OBJECT + REFERENCE); } /** diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueSkipListSet.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueSkipListSet.java index 4e82880c35f..1297ce297b2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueSkipListSet.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueSkipListSet.java @@ -44,7 +44,7 @@ import java.util.concurrent.ConcurrentSkipListMap; * get and set and won't throw ConcurrentModificationException when iterating. */ @InterfaceAudience.Private -class KeyValueSkipListSet implements NavigableSet { +public class KeyValueSkipListSet implements NavigableSet { private final ConcurrentNavigableMap delegatee; KeyValueSkipListSet(final KeyValue.KVComparator c) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java index 28a1a6acfd4..734140c0ca7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStore.java @@ -962,8 +962,8 @@ public class MemStore implements HeapSize { public final static long DEEP_OVERHEAD = ClassSize.align(FIXED_OVERHEAD + ClassSize.REENTRANT_LOCK + ClassSize.ATOMIC_LONG + - ClassSize.COPYONWRITE_ARRAYSET + ClassSize.COPYONWRITE_ARRAYLIST + - (2 * ClassSize.CONCURRENT_SKIPLISTMAP)); + (2 * ClassSize.TIMERANGE_TRACKER) + + (2 * ClassSize.KEYVALUE_SKIPLIST_SET) + (2 * ClassSize.CONCURRENT_SKIPLISTMAP)); /** Used for readability when we don't store memstore timestamp in HFile */ public static final boolean NO_PERSISTENT_TS = false; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java index 7511e99bfea..d4a5ce157de 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java @@ -47,7 +47,10 @@ import org.apache.hadoop.hbase.io.hfile.CachedBlock; import org.apache.hadoop.hbase.io.hfile.LruBlockCache; import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.regionserver.HStore; +import org.apache.hadoop.hbase.regionserver.KeyValueSkipListSet; import org.apache.hadoop.hbase.regionserver.MemStore; +import org.apache.hadoop.hbase.regionserver.MemStoreLAB; +import org.apache.hadoop.hbase.regionserver.TimeRangeTracker; import org.apache.hadoop.hbase.util.ClassSize; import org.junit.BeforeClass; import org.junit.Test; @@ -225,7 +228,23 @@ public class TestHeapSize { assertEquals(expected, actual); } + // TimeRangeTracker + cl = TimeRangeTracker.class; + expected = ClassSize.estimateBase(cl, false); + actual = ClassSize.TIMERANGE_TRACKER; + if (expected != actual) { + ClassSize.estimateBase(cl, true); + assertEquals(expected, actual); + } + // KeyValueSkipListSet + cl = KeyValueSkipListSet.class; + expected = ClassSize.estimateBase(cl, false); + actual = ClassSize.KEYVALUE_SKIPLIST_SET; + if (expected != actual) { + ClassSize.estimateBase(cl, true); + assertEquals(expected, actual); + } } /** @@ -288,17 +307,19 @@ public class TestHeapSize { expected = ClassSize.estimateBase(cl, false); expected += ClassSize.estimateBase(ReentrantReadWriteLock.class, false); expected += ClassSize.estimateBase(AtomicLong.class, false); - expected += ClassSize.estimateBase(ConcurrentSkipListMap.class, false); - expected += ClassSize.estimateBase(ConcurrentSkipListMap.class, false); - expected += ClassSize.estimateBase(CopyOnWriteArraySet.class, false); - expected += ClassSize.estimateBase(CopyOnWriteArrayList.class, false); + expected += (2 * ClassSize.estimateBase(KeyValueSkipListSet.class, false)); + expected += (2 * ClassSize.estimateBase(ConcurrentSkipListMap.class, false)); + expected += (2 * ClassSize.estimateBase(TimeRangeTracker.class, false)); if(expected != actual) { ClassSize.estimateBase(cl, true); ClassSize.estimateBase(ReentrantReadWriteLock.class, true); ClassSize.estimateBase(AtomicLong.class, true); + ClassSize.estimateBase(KeyValueSkipListSet.class, true); + ClassSize.estimateBase(KeyValueSkipListSet.class, true); ClassSize.estimateBase(ConcurrentSkipListMap.class, true); - ClassSize.estimateBase(CopyOnWriteArraySet.class, true); - ClassSize.estimateBase(CopyOnWriteArrayList.class, true); + ClassSize.estimateBase(ConcurrentSkipListMap.class, true); + ClassSize.estimateBase(TimeRangeTracker.class, true); + ClassSize.estimateBase(TimeRangeTracker.class, true); assertEquals(expected, actual); }