Skip to content

Commit

Permalink
Improve #6322 log buckets in RetainableByteBufferPool
Browse files Browse the repository at this point in the history
Add a Log2 bucket size impl for ArrayRetainableByteBufferPool

Signed-off-by: Greg Wilkins <gregw@webtide.com>
  • Loading branch information
gregw committed Jul 12, 2021
1 parent f2b545c commit 8feecc0
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -119,7 +119,7 @@ public RetainableByteBuffer acquire(int size, boolean direct)
Pool<RetainableByteBuffer>.Entry reservedEntry = bucket.reserve();
if (reservedEntry != null)
{
buffer = newRetainableByteBuffer(bucket.capacity, direct, byteBuffer ->
buffer = newRetainableByteBuffer(bucket._capacity, direct, byteBuffer ->
{
BufferUtil.clear(byteBuffer);
reservedEntry.release();
Expand Down Expand Up @@ -335,15 +335,20 @@ private Pool<RetainableByteBuffer>.Entry findOldestEntry(long now, Pool<Retainab

private static class Bucket extends Pool<RetainableByteBuffer>
{
private final int capacity;
private final int _capacity;

Bucket(int capacity, int size)
{
super(Pool.StrategyType.THREAD_ID, size, true);
this.capacity = capacity;
_capacity = capacity;
}
}

/**
* A variant of the {@link ArrayRetainableByteBufferPool} that
* uses buckets of buffers that increase in size by a power of
* 2 (eg 1k, 2k, 4k, 8k, etc.).
*/
public static class LogBuckets extends ArrayRetainableByteBufferPool
{
public LogBuckets()
Expand Down

0 comments on commit 8feecc0

Please sign in to comment.