You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by pr...@apache.org on 2014/11/08 00:33:27 UTC

svn commit: r1637485 - /pig/branches/branch-0.14/src/org/apache/pig/impl/util/SpillableMemoryManager.java

Author: prkommireddi
Date: Fri Nov  7 23:33:27 2014
New Revision: 1637485

URL: http://svn.apache.org/r1637485
Log:
PIG-4299 SpillableMemoryManager assumes tenured heap incorrectly (prkommireddi)

Modified:
    pig/branches/branch-0.14/src/org/apache/pig/impl/util/SpillableMemoryManager.java

Modified: pig/branches/branch-0.14/src/org/apache/pig/impl/util/SpillableMemoryManager.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.14/src/org/apache/pig/impl/util/SpillableMemoryManager.java?rev=1637485&r1=1637484&r2=1637485&view=diff
==============================================================================
--- pig/branches/branch-0.14/src/org/apache/pig/impl/util/SpillableMemoryManager.java (original)
+++ pig/branches/branch-0.14/src/org/apache/pig/impl/util/SpillableMemoryManager.java Fri Nov  7 23:33:27 2014
@@ -88,28 +88,30 @@ public class SpillableMemoryManager impl
     private SpillableMemoryManager() {
         ((NotificationEmitter)ManagementFactory.getMemoryMXBean()).addNotificationListener(this, null, null);
         List<MemoryPoolMXBean> mpbeans = ManagementFactory.getMemoryPoolMXBeans();
-        MemoryPoolMXBean tenuredHeap = null;
-        long tenuredHeapSize = 0;
+        MemoryPoolMXBean biggestHeap = null;
+        long biggestSize = 0;
         long totalSize = 0;
-        for (MemoryPoolMXBean pool : mpbeans) {
-            log.debug("Found heap (" + pool.getName() + ") of type " + pool.getType());
-            if (pool.getType() == MemoryType.HEAP) {
-                long size = pool.getUsage().getMax();
+        for (MemoryPoolMXBean b: mpbeans) {
+            log.debug("Found heap (" + b.getName() +
+                ") of type " + b.getType());
+            if (b.getType() == MemoryType.HEAP) {
+                /* Here we are making the leap of faith that the biggest
+                 * heap is the tenured heap
+                 */
+                long size = b.getUsage().getMax();
                 totalSize += size;
-                // CMS Old Gen or "tenured" is the only heap that supports
-                // setting usage threshold.
-                if (pool.isUsageThresholdSupported()) {
-                    tenuredHeapSize = size;
-                    tenuredHeap = pool;
+                if (size > biggestSize) {
+                    biggestSize = size;
+                    biggestHeap = b;
                 }
             }
         }
         extraGCSpillSizeThreshold  = (long) (totalSize * extraGCThresholdFraction);
-        if (tenuredHeap == null) {
+        if (biggestHeap == null) {
             throw new RuntimeException("Couldn't find heap");
         }
         log.debug("Selected heap to monitor (" +
-            tenuredHeap.getName() + ")");
+            biggestHeap.getName() + ")");
 
         // we want to set both collection and usage threshold alerts to be
         // safe. In some local tests after a point only collection threshold
@@ -121,11 +123,11 @@ public class SpillableMemoryManager impl
 
         /* We set the threshold to be 50% of tenured since that is where
          * the GC starts to dominate CPU time according to Sun doc */
-        tenuredHeap.setCollectionUsageThreshold((long)(tenuredHeapSize * collectionMemoryThresholdFraction));
+        biggestHeap.setCollectionUsageThreshold((long)(biggestSize * collectionMemoryThresholdFraction));
         // we set a higher threshold for usage threshold exceeded notification
         // since this is more likely to be effective sooner and we do not
         // want to be spilling too soon
-        tenuredHeap.setUsageThreshold((long)(tenuredHeapSize * memoryThresholdFraction));
+        biggestHeap.setUsageThreshold((long)(biggestSize * memoryThresholdFraction));
     }
 
     public static SpillableMemoryManager getInstance() {