hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077126 - in /hadoop/common/branches/branch-0.20-security-patches/src: mapred/org/apache/hadoop/mapred/ReduceTask.java test/org/apache/hadoop/mapred/TestReduceFetch.java
Date Fri, 04 Mar 2011 03:43:36 GMT
Author: omalley
Date: Fri Mar  4 03:43:35 2011
New Revision: 1077126

URL: http://svn.apache.org/viewvc?rev=1077126&view=rev
Log:
commit 3959754ec65141a3154bc9881b8227d0f6e6272d
Author: Devaraj Das <ddas@yahoo-inc.com>
Date:   Mon Jan 25 14:04:10 2010 -0800

    MAPREDUCE:433 from https://issues.apache.org/jira/secure/attachment/12431249/M433-v20.another.patch
    
    +++ b/YAHOO-CHANGES.txt
    +    MAPREDUCE-433. Use more reliable counters in TestReduceFetch.
    +    (Christopher Douglas via ddas)
    +

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/ReduceTask.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestReduceFetch.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/ReduceTask.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/ReduceTask.java?rev=1077126&r1=1077125&r2=1077126&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/ReduceTask.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/ReduceTask.java
Fri Mar  4 03:43:35 2011
@@ -1011,9 +1011,10 @@ class ReduceTask extends Task {
           throw new IOException("mapred.job.shuffle.input.buffer.percent" +
                                 maxInMemCopyUse);
         }
-        maxSize = (long)Math.min(
-            Runtime.getRuntime().maxMemory() * maxInMemCopyUse,
-            Integer.MAX_VALUE);
+        // Allow unit tests to fix Runtime memory
+        maxSize = (int)(conf.getInt("mapred.job.reduce.total.mem.bytes",
+            (int)Math.min(Runtime.getRuntime().maxMemory(), Integer.MAX_VALUE))
+          * maxInMemCopyUse);
         maxSingleShuffleLimit = (long)(maxSize * MAX_SINGLE_SHUFFLE_SEGMENT_FRACTION);
         LOG.info("ShuffleRamManager: MemoryLimit=" + maxSize + 
                  ", MaxSingleShuffleLimit=" + maxSingleShuffleLimit);

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestReduceFetch.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestReduceFetch.java?rev=1077126&r1=1077125&r2=1077126&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestReduceFetch.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestReduceFetch.java
Fri Mar  4 03:43:35 2011
@@ -101,48 +101,53 @@ public class TestReduceFetch extends Tes
   }
 
   public void testReduceFromDisk() throws Exception {
+    final int MAP_TASKS = 8;
     JobConf job = mrCluster.createJobConf();
     job.set("mapred.job.reduce.input.buffer.percent", "0.0");
-    job.setNumMapTasks(3);
+    job.setNumMapTasks(MAP_TASKS);
+    job.setInt("mapred.job.reduce.total.mem.bytes", 128 << 20);
+    job.set("mapred.job.shuffle.input.buffer.percent", "0.14");
+    job.setInt("io.sort.factor", 2);
+    job.setInt("mapred.inmem.merge.threshold", 4);
     Counters c = runJob(job);
-    final long hdfsWritten = c.findCounter(Task.FILESYSTEM_COUNTER_GROUP, 
-        Task.getFileSystemCounterNames("hdfs")[1]).getCounter();
-    final long localRead = c.findCounter(Task.FILESYSTEM_COUNTER_GROUP, 
-        Task.getFileSystemCounterNames("file")[0]).getCounter();
-    assertTrue("Expected more bytes read from local (" +
-        localRead + ") than written to HDFS (" + hdfsWritten + ")",
-        hdfsWritten <= localRead);
+    final long spill = c.findCounter(Task.Counter.SPILLED_RECORDS).getCounter();
+    final long out = c.findCounter(Task.Counter.MAP_OUTPUT_RECORDS).getCounter();
+    assertTrue("Expected all records spilled during reduce (" + spill + ")",
+        spill >= 2 * out); // all records spill at map, reduce
+    assertTrue("Expected intermediate merges (" + spill + ")",
+        spill >= 2 * out + (out / MAP_TASKS)); // some records hit twice
   }
 
   public void testReduceFromPartialMem() throws Exception {
+    final int MAP_TASKS = 5;
     JobConf job = mrCluster.createJobConf();
-    job.setNumMapTasks(5);
+    job.setNumMapTasks(MAP_TASKS);
     job.setInt("mapred.inmem.merge.threshold", 0);
     job.set("mapred.job.reduce.input.buffer.percent", "1.0");
     job.setInt("mapred.reduce.parallel.copies", 1);
     job.setInt("io.sort.mb", 10);
-    job.set(JobConf.MAPRED_REDUCE_TASK_JAVA_OPTS, "-Xmx128m");
+    job.setInt("mapred.job.reduce.total.mem.bytes", 128 << 20);
     job.set("mapred.job.shuffle.input.buffer.percent", "0.14");
     job.setNumTasksToExecutePerJvm(1);
     job.set("mapred.job.shuffle.merge.percent", "1.0");
     Counters c = runJob(job);
-    final long hdfsWritten = c.findCounter(Task.FILESYSTEM_COUNTER_GROUP, 
-        Task.getFileSystemCounterNames("hdfs")[1]).getCounter();
-    final long localRead = c.findCounter(Task.FILESYSTEM_COUNTER_GROUP, 
-        Task.getFileSystemCounterNames("file")[0]).getCounter();
-    assertTrue("Expected at least 1MB fewer bytes read from local (" +
-        localRead + ") than written to HDFS (" + hdfsWritten + ")",
-        hdfsWritten >= localRead + 1024 * 1024);
+    final long out = c.findCounter(Task.Counter.MAP_OUTPUT_RECORDS).getCounter();
+    final long spill = c.findCounter(Task.Counter.SPILLED_RECORDS).getCounter();
+    assertTrue("Expected some records not spilled during reduce" + spill + ")",
+        spill < 2 * out); // spilled map records, some records at the reduce
   }
 
   public void testReduceFromMem() throws Exception {
+    final int MAP_TASKS = 3;
     JobConf job = mrCluster.createJobConf();
     job.set("mapred.job.reduce.input.buffer.percent", "1.0");
-    job.setNumMapTasks(3);
+    job.set("mapred.job.shuffle.input.buffer.percent", "1.0");
+    job.setInt("mapred.job.reduce.total.mem.bytes", 128 << 20);
+    job.setNumMapTasks(MAP_TASKS);
     Counters c = runJob(job);
-    final long localRead = c.findCounter(Task.FILESYSTEM_COUNTER_GROUP, 
-        Task.getFileSystemCounterNames("file")[0]).getCounter();
-    assertTrue("Non-zero read from local: " + localRead, localRead == 0);
+    final long spill = c.findCounter(Task.Counter.SPILLED_RECORDS).getCounter();
+    final long out = c.findCounter(Task.Counter.MAP_OUTPUT_RECORDS).getCounter();
+    assertEquals("Spilled records: " + spill, out, spill); // no reduce spill
   }
 
 }



Mime
View raw message