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.
This commit is contained in:
parent
6f4cbde103
commit
0c6226b56c
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue