tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rbalamo...@apache.org
Subject tez git commit: TEZ-2731: Fix Tez GenericCounter performance bottleneck (Gopal V, reviewed by Rajesh Balamohan)
Date Thu, 03 Sep 2015 01:57:10 GMT
Repository: tez
Updated Branches:
  refs/heads/branch-0.7 ccfc16ba8 -> 5dc0770fe


TEZ-2731: Fix Tez GenericCounter performance bottleneck (Gopal V, reviewed by Rajesh Balamohan)

(cherry picked from commit dc0ee0115cef3d0ad6ea64c3f93042a081d66472)


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

Branch: refs/heads/branch-0.7
Commit: 5dc0770fe995c665f800a9009bf647828fad277d
Parents: ccfc16b
Author: Gopal V <gopalv@apache.org>
Authored: Tue Aug 25 14:53:40 2015 -0700
Committer: Rajesh Balamohan <rbalamohan@apache.org>
Committed: Thu Sep 3 07:27:34 2015 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../tez/common/counters/GenericCounter.java     | 21 ++++++++++----------
 2 files changed, 12 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/5dc0770f/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5e3a183..63860eb 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -6,6 +6,7 @@ Release 0.7.1: Unreleased
 INCOMPATIBLE CHANGES
 
 ALL CHANGES:
+  TEZ-2731. Fix Tez GenericCounter performance bottleneck
   TEZ-2752. logUnsuccessful completion in Attempt should write original finish
   time to ATS
   TEZ-2755. Fix findbugs warning in TezClient

http://git-wip-us.apache.org/repos/asf/tez/blob/5dc0770f/tez-api/src/main/java/org/apache/tez/common/counters/GenericCounter.java
----------------------------------------------------------------------
diff --git a/tez-api/src/main/java/org/apache/tez/common/counters/GenericCounter.java b/tez-api/src/main/java/org/apache/tez/common/counters/GenericCounter.java
index 4bb4c76..758ab51 100644
--- a/tez-api/src/main/java/org/apache/tez/common/counters/GenericCounter.java
+++ b/tez-api/src/main/java/org/apache/tez/common/counters/GenericCounter.java
@@ -21,6 +21,7 @@ package org.apache.tez.common.counters;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.io.Text;
@@ -35,7 +36,7 @@ public class GenericCounter extends AbstractCounter {
 
   private String name;
   private String displayName;
-  private long value = 0;
+  private final AtomicLong value = new AtomicLong(0);
 
   public GenericCounter() {
     // mostly for readFields
@@ -48,7 +49,7 @@ public class GenericCounter extends AbstractCounter {
   public GenericCounter(String name, String displayName, long value) {
     this.name = StringInterner.weakIntern(name);
     this.displayName = StringInterner.weakIntern(displayName);
-    this.value = value;
+    this.value.set(value);
   }
 
   @Override @Deprecated
@@ -60,7 +61,7 @@ public class GenericCounter extends AbstractCounter {
   public synchronized void readFields(DataInput in) throws IOException {
     name = StringInterner.weakIntern(Text.readString(in));
     displayName = in.readBoolean() ? StringInterner.weakIntern(Text.readString(in)) : name;
-    value = WritableUtils.readVLong(in);
+    value.set(WritableUtils.readVLong(in));
   }
 
   /**
@@ -74,7 +75,7 @@ public class GenericCounter extends AbstractCounter {
     if (distinctDisplayName) {
       Text.writeString(out, displayName);
     }
-    WritableUtils.writeVLong(out, value);
+    WritableUtils.writeVLong(out, value.get());
   }
 
   @Override
@@ -88,18 +89,18 @@ public class GenericCounter extends AbstractCounter {
   }
 
   @Override
-  public synchronized long getValue() {
-    return value;
+  public long getValue() {
+    return value.get();
   }
 
   @Override
-  public synchronized void setValue(long value) {
-    this.value = value;
+  public void setValue(long value) {
+    this.value.set(value);
   }
 
   @Override
-  public synchronized void increment(long incr) {
-    value += incr;
+  public void increment(long incr) {
+    value.addAndGet(incr);
   }
 
   @Override


Mime
View raw message