Forráskód Böngészése

HADOOP-3475. Fix MapTask to correctly size the accounting allocation of io.sort.mb.


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@662631 13f79535-47bb-0310-9956-ffa450edef68
Christopher Douglas 17 éve
szülő
commit
9d0a0cffe7
2 módosított fájl, 9 hozzáadás és 4 törlés
  1. 3 0
      CHANGES.txt
  2. 6 4
      src/java/org/apache/hadoop/mapred/MapTask.java

+ 3 - 0
CHANGES.txt

@@ -388,6 +388,9 @@ Trunk (unreleased changes)
     HADOOP-3471. Fix spurious errors from TestIndexedSort and add additional
     logging to let failures be reproducible. (cdouglas)
 
+    HADOOP-3475. Fix MapTask to correctly size the accounting allocation of
+    io.sort.mb. (cdouglas)
+
 Release 0.17.0 - 2008-05-18
 
   INCOMPATIBLE CHANGES

+ 6 - 4
src/java/org/apache/hadoop/mapred/MapTask.java

@@ -324,6 +324,8 @@ class MapTask extends Task {
     private static final int KEYSTART = 1;  // key offset in acct
     private static final int VALSTART = 2;  // val offset in acct
     private static final int ACCTSIZE = 3;  // total #fields in acct
+    private static final int RECSIZE =
+                       (ACCTSIZE + 1) * 4;  // acct bytes per record
 
     // spill accounting
     private volatile int numSpills = 0;
@@ -367,12 +369,12 @@ class MapTask extends Task {
       // buffers and accounting
       int maxMemUsage = sortmb << 20;
       int recordCapacity = (int)(maxMemUsage * recper);
-      recordCapacity += (recordCapacity >>> 2) % 4;
+      recordCapacity -= recordCapacity % RECSIZE;
       kvbuffer = new byte[maxMemUsage - recordCapacity];
       bufvoid = kvbuffer.length;
-      int kvcapacity = recordCapacity >>> 2;
-      kvoffsets = new int[kvcapacity];
-      kvindices = new int[recordCapacity - kvcapacity];
+      recordCapacity /= RECSIZE;
+      kvoffsets = new int[recordCapacity];
+      kvindices = new int[recordCapacity * ACCTSIZE];
       softBufferLimit = (int)(kvbuffer.length * spillper);
       softRecordLimit = (int)(kvoffsets.length * spillper);
       // k/v serialization