hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1138647 - in /hbase/trunk/src: main/java/org/apache/hadoop/hbase/regionserver/HRegion.java main/java/org/apache/hadoop/hbase/util/ClassSize.java test/java/org/apache/hadoop/hbase/io/TestHeapSize.java
Date Wed, 22 Jun 2011 21:45:31 GMT
Author: stack
Date: Wed Jun 22 21:45:31 2011
New Revision: 1138647

URL: http://svn.apache.org/viewvc?rev=1138647&view=rev
Log:
Attempted fix for broken TestHeapSize up on jenkins

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1138647&r1=1138646&r2=1138647&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Wed Jun 22
21:45:31 2011
@@ -3592,9 +3592,11 @@ public class HRegion implements HeapSize
   }
 
   public static final long FIXED_OVERHEAD = ClassSize.align(
-      (4 * Bytes.SIZEOF_LONG) + ClassSize.ARRAY +
-      ClassSize.align(27 * ClassSize.REFERENCE) + ClassSize.OBJECT +
-      ClassSize.align(Bytes.SIZEOF_INT));
+      ClassSize.OBJECT +
+      ClassSize.ARRAY +
+      ClassSize.align(27 * ClassSize.REFERENCE) +
+      (4 * Bytes.SIZEOF_LONG) +
+      Bytes.SIZEOF_BOOLEAN);
 
   public static final long DEEP_OVERHEAD = FIXED_OVERHEAD +
       ClassSize.OBJECT + // closeLock

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java?rev=1138647&r1=1138646&r2=1138647&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/util/ClassSize.java Wed Jun 22 21:45:31
2011
@@ -185,45 +185,46 @@ public class ClassSize {
     int arrays = 0;
     //The number of references that a new object takes
     int references = nrOfRefsPerObj;
+    int index = 0;
 
     for ( ; null != cl; cl = cl.getSuperclass()) {
       Field[] field = cl.getDeclaredFields();
       if (null != field) {
         for (Field aField : field) {
-          if (!Modifier.isStatic(aField.getModifiers())) {
-            Class fieldClass = aField.getType();
-            if (fieldClass.isArray()) {
-              arrays++;
-              references++;
-            } else if (!fieldClass.isPrimitive()) {
-              references++;
-            } else {// Is simple primitive
-              String name = fieldClass.getName();
-
-              if (name.equals("int") || name.equals("I"))
-                primitives += Bytes.SIZEOF_INT;
-              else if (name.equals("long") || name.equals("J"))
-                primitives += Bytes.SIZEOF_LONG;
-              else if (name.equals("boolean") || name.equals("Z"))
-                primitives += Bytes.SIZEOF_BOOLEAN;
-              else if (name.equals("short") || name.equals("S"))
-                primitives += Bytes.SIZEOF_SHORT;
-              else if (name.equals("byte") || name.equals("B"))
-                primitives += Bytes.SIZEOF_BYTE;
-              else if (name.equals("char") || name.equals("C"))
-                primitives += Bytes.SIZEOF_CHAR;
-              else if (name.equals("float") || name.equals("F"))
-                primitives += Bytes.SIZEOF_FLOAT;
-              else if (name.equals("double") || name.equals("D"))
-                primitives += Bytes.SIZEOF_DOUBLE;
-            }
-            if (debug) {
-              if (LOG.isDebugEnabled()) {
-                // Write out region name as string and its encoded name.
-                LOG.debug(aField.getName() + "\n\t" + aField.getType());
-              }
+          if (Modifier.isStatic(aField.getModifiers())) continue;
+          Class fieldClass = aField.getType();
+          if (fieldClass.isArray()) {
+            arrays++;
+            references++;
+          } else if (!fieldClass.isPrimitive()) {
+            references++;
+          } else {// Is simple primitive
+            String name = fieldClass.getName();
+
+            if (name.equals("int") || name.equals("I"))
+              primitives += Bytes.SIZEOF_INT;
+            else if (name.equals("long") || name.equals("J"))
+              primitives += Bytes.SIZEOF_LONG;
+            else if (name.equals("boolean") || name.equals("Z"))
+              primitives += Bytes.SIZEOF_BOOLEAN;
+            else if (name.equals("short") || name.equals("S"))
+              primitives += Bytes.SIZEOF_SHORT;
+            else if (name.equals("byte") || name.equals("B"))
+              primitives += Bytes.SIZEOF_BYTE;
+            else if (name.equals("char") || name.equals("C"))
+              primitives += Bytes.SIZEOF_CHAR;
+            else if (name.equals("float") || name.equals("F"))
+              primitives += Bytes.SIZEOF_FLOAT;
+            else if (name.equals("double") || name.equals("D"))
+              primitives += Bytes.SIZEOF_DOUBLE;
+          }
+          if (debug) {
+            if (LOG.isDebugEnabled()) {
+              // Write out region name as string and its encoded name.
+              LOG.debug("" + index + " " + aField.getName() + " " + aField.getType());
             }
           }
+          index++;
         }
       }
     }
@@ -240,17 +241,17 @@ public class ClassSize {
    * @return the size estimate, in bytes
    */
   private static long estimateBaseFromCoefficients(int [] coeff, boolean debug) {
-    long size = coeff[0] + align(coeff[1]*ARRAY) + coeff[2]*REFERENCE;
+    long prealign_size = coeff[0] + align(coeff[1] * ARRAY) + coeff[2] * REFERENCE;
 
     // Round up to a multiple of 8
-    size = align(size);
+    long size = align(prealign_size);
     if(debug) {
       if (LOG.isDebugEnabled()) {
         // Write out region name as string and its encoded name.
-        LOG.debug("Primitives " + coeff[0] + ", arrays " + coeff[1] +
+        LOG.debug("Primitives=" + coeff[0] + ", arrays=" + coeff[1] +
             ", references(includes " + nrOfRefsPerObj +
-            " for object overhead) " + coeff[2] + ", refSize " + REFERENCE +
-            ", size " + size);
+            " for object overhead)=" + coeff[2] + ", refSize " + REFERENCE +
+            ", size=" + size + ", prealign_size=" + prealign_size);
       }
     }
     return size;
@@ -291,6 +292,5 @@ public class ClassSize {
     //stored and sent together
     return  ((num + 7) >> 3) << 3;
   }
-
 }
 

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java?rev=1138647&r1=1138646&r2=1138647&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/io/TestHeapSize.java Wed Jun 22 21:45:31
2011
@@ -304,7 +304,7 @@ public class TestHeapSize extends TestCa
     cl = HRegion.class;
     actual = HRegion.FIXED_OVERHEAD;
     expected = ClassSize.estimateBase(cl, false);
-    if(expected != actual) {
+    if (expected != actual) {
       ClassSize.estimateBase(cl, true);
       assertEquals(expected, actual);
     }
@@ -315,7 +315,5 @@ public class TestHeapSize extends TestCa
     // accounted for.  But we have satisfied our two core requirements.
     // Sizing is quite accurate now, and our tests will throw errors if
     // any of these classes are modified without updating overhead sizes.
-
   }
-
 }



Mime
View raw message