Repository: hbase Updated Branches: refs/heads/branch-1 6f4cbde10 -> 0c6226b56 refs/heads/branch-1.4 c9e166577 -> 89bbc3065
HBASE-21162 Revert suspicious change to BoundedByteBufferPool and disable use of direct buffers for IPC reservoir by default Revert suspicious change to BoundedByteBufferPool made on HBASE-19239 (Fix findbugs and error-prone issues). In addition the allocation of direct memory for the server RPC reservoir is problematic in that tracing native memory or direct buffer leaks to a particular class or compilation unit is difficult, so allocate the reservoir on the heap by default instead. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0c6226b5 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0c6226b5 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0c6226b5 Branch: refs/heads/branch-1 Commit: 0c6226b56cae2850c72c85368bd9725f4451b16a Parents: 6f4cbde Author: Andrew Purtell <apurt...@apache.org> Authored: Fri Sep 7 11:46:19 2018 -0700 Committer: Andrew Purtell <apurt...@apache.org> Committed: Mon Sep 10 18:25:27 2018 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/io/BoundedByteBufferPool.java | 9 +++++---- .../main/java/org/apache/hadoop/hbase/ipc/RpcServer.java | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/0c6226b5/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedByteBufferPool.java ---------------------------------------------------------------------- diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedByteBufferPool.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedByteBufferPool.java index 8c371a6..e2984b3 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedByteBufferPool.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedByteBufferPool.java @@ -46,6 +46,7 @@ import com.google.common.annotations.VisibleForTesting; * <p>This class is thread safe. */ @InterfaceAudience.Private +@SuppressWarnings("NonAtomicVolatileUpdate") // Suppress error-prone warning, see HBASE-21162 public class BoundedByteBufferPool { private static final Log LOG = LogFactory.getLog(BoundedByteBufferPool.class); @@ -60,7 +61,7 @@ public class BoundedByteBufferPool { volatile int runningAverage; // Scratch that keeps rough total size of pooled bytebuffers - private AtomicLong totalReservoirCapacity = new AtomicLong(0); + private volatile int totalReservoirCapacity; // For reporting private AtomicLong allocations = new AtomicLong(0); @@ -89,7 +90,7 @@ public class BoundedByteBufferPool { try { bb = this.buffers.poll(); if (bb != null) { - this.totalReservoirCapacity.addAndGet(-bb.capacity()); + this.totalReservoirCapacity -= bb.capacity(); } } finally { lock.unlock(); @@ -119,8 +120,8 @@ public class BoundedByteBufferPool { try { success = this.buffers.offer(bb); if (success) { - average = (int) this.totalReservoirCapacity.addAndGet(bb.capacity()) / - this.buffers.size(); // size will never be 0. + this.totalReservoirCapacity += bb.capacity(); + average = this.totalReservoirCapacity / this.buffers.size(); // size will never be 0. } } finally { lock.unlock(); http://git-wip-us.apache.org/repos/asf/hbase/blob/0c6226b5/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java index e318f3f..3f11233 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java @@ -2182,7 +2182,7 @@ public class RpcServer implements RpcServerInterface, ConfigurationObserver { conf.getInt(HConstants.REGION_SERVER_HANDLER_COUNT, HConstants.DEFAULT_REGION_SERVER_HANDLER_COUNT) * 2), // By default make direct byte buffers from the buffer pool. - conf.getBoolean("hbase.ipc.server.reservoir.direct.buffer", true)); + conf.getBoolean("hbase.ipc.server.reservoir.direct.buffer", false)); } else { reservoir = null; }