Browse Source

MAPREDUCE-4400: Avoid task finish sleep to improve small job/workflow latency. (llu)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.1@1365851 13f79535-47bb-0310-9956-ffa450edef68
Luke Lu 12 years ago
parent
commit
257f2f9bcd
2 changed files with 13 additions and 4 deletions
  1. 3 0
      CHANGES.txt
  2. 10 4
      src/mapred/org/apache/hadoop/mapred/Task.java

+ 3 - 0
CHANGES.txt

@@ -143,6 +143,9 @@ Release 1.1.0 - 2012.07.09
     MAPREDUCE-4399. Change the Jetty response buffer size to improve 
     shuffle performance. (Luke Lu via suresh)
 
+    MAPREDUCE-4400. Avoid task finish sleep to improve small job/workflow
+    latency. (llu)
+
   BUG FIXES
 
     MAPREDUCE-4087. [Gridmix] GenerateDistCacheData job of Gridmix can

+ 10 - 4
src/mapred/org/apache/hadoop/mapred/Task.java

@@ -649,14 +649,19 @@ abstract public class Task implements Writable, Configurable {
       // get current flag value and reset it as well
       boolean sendProgress = resetProgressFlag();
       while (!taskDone.get()) {
-        synchronized(lock) {
-          done = false;
-        }
         try {
           boolean taskFound = true; // whether TT knows about this task
           // sleep for a bit
           try {
-            Thread.sleep(PROGRESS_INTERVAL);
+            synchronized(lock) {
+              done = false;
+              lock.wait(PROGRESS_INTERVAL);
+              if (taskDone.get()) {
+                done = true;
+                lock.notify();
+                return;
+              }
+            }
           } 
           catch (InterruptedException e) {
             if (LOG.isDebugEnabled()) {
@@ -724,6 +729,7 @@ abstract public class Task implements Writable, Configurable {
       // Updating resources specified in ResourceCalculatorPlugin
       if (pingThread != null) {
         synchronized(lock) {
+          lock.notify(); // wake up the wait in the while loop
           while(!done) {
             lock.wait();
           }