diff -Naur hbase-1.3.1-A/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedByteBufferPool.java hbase-1.3.1/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedByteBufferPool.java --- hbase-1.3.1-A/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedByteBufferPool.java 2017-04-05 10:54:40.000000000 +0800 +++ hbase-1.3.1/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedByteBufferPool.java 2000-02-06 13:59:07.590000000 +0800 @@ -21,7 +21,7 @@ import java.util.Queue; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.ReentrantLock; - +import java.util.concurrent.ConcurrentLinkedQueue; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.classification.InterfaceAudience; @@ -79,12 +79,13 @@ final int maxToCache, final boolean createDirectByteBuffer) { this.maxByteBufferSizeToCache = maxByteBufferSizeToCache; this.runningAverage = initialByteBufferSize; - this.buffers = new BoundedArrayQueue(maxToCache); + // this.buffers = new BoundedArrayQueue(maxToCache); + this.buffers = new ConcurrentLinkedQueue<>(); this.createDirectByteBuffer = createDirectByteBuffer; } public ByteBuffer getBuffer() { - ByteBuffer bb = null; + /* ByteBuffer bb = null; lock.lock(); try { bb = this.buffers.poll(); @@ -94,8 +95,11 @@ } finally { lock.unlock(); } + */ + ByteBuffer bb = buffers.poll(); if (bb != null) { // Clear sets limit == capacity. Postion == 0. + this.totalReservoirCapacity -= bb.capacity(); bb.clear(); } else { bb = this.createDirectByteBuffer ? ByteBuffer.allocateDirect(this.runningAverage) @@ -115,6 +119,7 @@ if (bb.capacity() > this.maxByteBufferSizeToCache) return; boolean success = false; int average = 0; + /* lock.lock(); try { success = this.buffers.offer(bb); @@ -125,6 +130,11 @@ } finally { lock.unlock(); } + */ + this.buffers.offer(bb); + success = true; + this.totalReservoirCapacity += bb.capacity(); + average = this.totalReservoirCapacity / this.buffers.size(); if (!success) { if (LOG.isDebugEnabled()) { LOG.debug("At capacity: " + this.buffers.size());