You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ay...@apache.org on 2021/03/23 20:50:27 UTC

[hadoop] branch branch-3.3 updated: HDFS-15907. Reduce Memory Overhead of AclFeature by avoiding AtomicInteger. Contributed by Stephen O'Donnell.

This is an automated email from the ASF dual-hosted git repository.

ayushsaxena pushed a commit to branch branch-3.3
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.3 by this push:
     new 76c40a5  HDFS-15907. Reduce Memory Overhead of AclFeature by avoiding AtomicInteger. Contributed by Stephen O'Donnell.
76c40a5 is described below

commit 76c40a52d76671df4c46d131e85478b50697dedf
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Wed Mar 24 02:10:02 2021 +0530

    HDFS-15907. Reduce Memory Overhead of AclFeature by avoiding AtomicInteger. Contributed by Stephen O'Donnell.
---
 .../apache/hadoop/hdfs/server/namenode/AclFeature.java    | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/AclFeature.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/AclFeature.java
index 6b2baa4..2dfe507 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/AclFeature.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/AclFeature.java
@@ -19,7 +19,6 @@
 package org.apache.hadoop.hdfs.server.namenode;
 
 import java.util.Arrays;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.fs.permission.AclEntry;
@@ -35,7 +34,7 @@ import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList;
 public class AclFeature implements INode.Feature, ReferenceCounter {
   public static final ImmutableList<AclEntry> EMPTY_ENTRY_LIST =
     ImmutableList.of();
-  private AtomicInteger value = new AtomicInteger();
+  private int refCount = 0;
 
   private final int [] entries;
 
@@ -84,17 +83,17 @@ public class AclFeature implements INode.Feature, ReferenceCounter {
   }
 
   @Override
-  public int getRefCount() {
-    return value.get();
+  public synchronized int getRefCount() {
+    return refCount;
   }
 
   @Override
-  public int incrementAndGetRefCount() {
-    return value.incrementAndGet();
+  public synchronized int incrementAndGetRefCount() {
+    return ++refCount;
   }
 
   @Override
-  public int decrementAndGetRefCount() {
-    return value.updateAndGet(i -> i > 0 ? i - 1 : i);
+  public synchronized int decrementAndGetRefCount() {
+    return (refCount > 0) ? --refCount : 0;
   }
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org