Browse Source

HADOOP-3313. Avoid unnecessary calls to System.currentTimeMillis
in RPC::Invoker.



git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@651691 13f79535-47bb-0310-9956-ffa450edef68

Christopher Douglas 17 years ago
parent
commit
08b62e9ca7
2 changed files with 12 additions and 3 deletions
  1. 3 0
      CHANGES.txt
  2. 9 3
      src/java/org/apache/hadoop/ipc/RPC.java

+ 3 - 0
CHANGES.txt

@@ -88,6 +88,9 @@ Trunk (unreleased changes)
     HADOOP-2793. Fix broken links for worst performing shuffle tasks in
     HADOOP-2793. Fix broken links for worst performing shuffle tasks in
     the job history page. (Amareshwari Sriramadasu via ddas)
     the job history page. (Amareshwari Sriramadasu via ddas)
 
 
+    HADOOP-3313. Avoid unnecessary calls to System.currentTimeMillis
+    in RPC::Invoker. (cdouglas)
+
 Release 0.17.0 - Unreleased
 Release 0.17.0 - Unreleased
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 9 - 3
src/java/org/apache/hadoop/ipc/RPC.java

@@ -208,11 +208,17 @@ public class RPC {
 
 
     public Object invoke(Object proxy, Method method, Object[] args)
     public Object invoke(Object proxy, Method method, Object[] args)
       throws Throwable {
       throws Throwable {
-      long startTime = System.currentTimeMillis();
+      final boolean logDebug = LOG.isDebugEnabled();
+      long startTime = 0;
+      if (logDebug) {
+        startTime = System.currentTimeMillis();
+      }
       ObjectWritable value = (ObjectWritable)
       ObjectWritable value = (ObjectWritable)
         client.call(new Invocation(method, args), address, ticket);
         client.call(new Invocation(method, args), address, ticket);
-      long callTime = System.currentTimeMillis() - startTime;
-      LOG.debug("Call: " + method.getName() + " " + callTime);
+      if (logDebug) {
+        long callTime = System.currentTimeMillis() - startTime;
+        LOG.debug("Call: " + method.getName() + " " + callTime);
+      }
       return value.get();
       return value.get();
     }
     }