You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tez.apache.org by go...@apache.org on 2015/08/25 23:56:31 UTC
tez git commit: TEZ-2731: Fix Tez GenericCounter performance
bottleneck (Gopal V, reviewed by Rajesh Balamohan)
Repository: tez
Updated Branches:
refs/heads/master a0c0727dd -> dc0ee0115
TEZ-2731: Fix Tez GenericCounter performance bottleneck (Gopal V, reviewed by Rajesh Balamohan)
Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/dc0ee011
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/dc0ee011
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/dc0ee011
Branch: refs/heads/master
Commit: dc0ee0115cef3d0ad6ea64c3f93042a081d66472
Parents: a0c0727
Author: Gopal V <go...@apache.org>
Authored: Tue Aug 25 14:53:40 2015 -0700
Committer: Gopal V <go...@apache.org>
Committed: Tue Aug 25 14:53:40 2015 -0700
----------------------------------------------------------------------
.../tez/common/counters/GenericCounter.java | 21 ++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tez/blob/dc0ee011/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