You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2015/12/17 23:12:52 UTC

hive git commit: HIVE-12675 : PerfLogger should log performance metrics at debug level(Hari Subramaniyan, reviewed by Laljo John Pullokkaran)

Repository: hive
Updated Branches:
  refs/heads/master 81146f436 -> df7f6fe49


HIVE-12675 : PerfLogger should log performance metrics at debug level(Hari Subramaniyan, reviewed by Laljo John Pullokkaran)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/df7f6fe4
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/df7f6fe4
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/df7f6fe4

Branch: refs/heads/master
Commit: df7f6fe49b0c6ff1a8a680f55216e49cdc19c405
Parents: 81146f4
Author: Hari Subramaniyan <ha...@apache.org>
Authored: Thu Dec 17 14:12:44 2015 -0800
Committer: Hari Subramaniyan <ha...@apache.org>
Committed: Thu Dec 17 14:12:44 2015 -0800

----------------------------------------------------------------------
 .../apache/hadoop/hive/ql/log/PerfLogger.java   | 55 +++++++++++---------
 1 file changed, 30 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/df7f6fe4/common/src/java/org/apache/hadoop/hive/ql/log/PerfLogger.java
----------------------------------------------------------------------
diff --git a/common/src/java/org/apache/hadoop/hive/ql/log/PerfLogger.java b/common/src/java/org/apache/hadoop/hive/ql/log/PerfLogger.java
index f6eb64b..98ebd50 100644
--- a/common/src/java/org/apache/hadoop/hive/ql/log/PerfLogger.java
+++ b/common/src/java/org/apache/hadoop/hive/ql/log/PerfLogger.java
@@ -117,10 +117,12 @@ public class PerfLogger {
    * @param method method or ID that identifies this perf log element.
    */
   public void PerfLogBegin(String callerName, String method) {
-    long startTime = System.currentTimeMillis();
-    LOG.info("<PERFLOG method=" + method + " from=" + callerName + ">");
-    startTimes.put(method, new Long(startTime));
-    beginMetrics(method);
+    if (LOG.isDebugEnabled()) {
+      long startTime = System.currentTimeMillis();
+      LOG.debug("<PERFLOG method=" + method + " from=" + callerName + ">");
+      startTimes.put(method, new Long(startTime));
+      beginMetrics(method);
+    }
   }
   /**
    * Call this function in correspondence of PerfLogBegin to mark the end of the measurement.
@@ -139,31 +141,34 @@ public class PerfLogger {
    * @return long duration  the difference between now and startTime, or -1 if startTime is null
    */
   public long PerfLogEnd(String callerName, String method, String additionalInfo) {
-    Long startTime = startTimes.get(method);
-    long endTime = System.currentTimeMillis();
-    long duration = -1;
+    if (LOG.isDebugEnabled()) {
+      Long startTime = startTimes.get(method);
+      long endTime = System.currentTimeMillis();
+      long duration = -1;
 
-    endTimes.put(method, new Long(endTime));
+      endTimes.put(method, new Long(endTime));
 
-    StringBuilder sb = new StringBuilder("</PERFLOG method=").append(method);
-    if (startTime != null) {
-      sb.append(" start=").append(startTime);
-    }
-    sb.append(" end=").append(endTime);
-    if (startTime != null) {
-      duration = endTime - startTime.longValue();
-      sb.append(" duration=").append(duration);
-    }
-    sb.append(" from=").append(callerName);
-    if (additionalInfo != null) {
-      sb.append(" ").append(additionalInfo);
-    }
-    sb.append(">");
-    LOG.info(sb.toString());
+      StringBuilder sb = new StringBuilder("</PERFLOG method=").append(method);
+      if (startTime != null) {
+        sb.append(" start=").append(startTime);
+      }
+      sb.append(" end=").append(endTime);
+      if (startTime != null) {
+        duration = endTime - startTime.longValue();
+        sb.append(" duration=").append(duration);
+      }
+      sb.append(" from=").append(callerName);
+      if (additionalInfo != null) {
+        sb.append(" ").append(additionalInfo);
+      }
+      sb.append(">");
+      LOG.debug(sb.toString());
 
-    endMetrics(method);
+      endMetrics(method);
 
-    return duration;
+      return duration;
+    }
+    return -1;
   }
 
   public Long getStartTime(String method) {