From 02166c9a14d0226eb03fa9c1835e877c1311f200 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Thu, 6 Sep 2018 09:42:44 -0700 Subject: [PATCH] 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. --- .../org/apache/hadoop/hbase/io/BoundedByteBufferPool.java | 8 ++++---- .../main/java/org/apache/hadoop/hbase/ipc/RpcServer.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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 8c371a6d86..4d526143dd 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 @@ -60,7 +60,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 +89,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 +119,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(); 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 e318f3fcd6..3f11233e55 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; } -- 2.18.0