Package io.netty.buffer
Class PoolArena<T>
- java.lang.Object
-
- io.netty.buffer.SizeClasses
-
- io.netty.buffer.PoolArena<T>
-
- All Implemented Interfaces:
PoolArenaMetric
,SizeClassesMetric
- Direct Known Subclasses:
PoolArena.DirectArena
,PoolArena.HeapArena
abstract class PoolArena<T> extends SizeClasses implements PoolArenaMetric
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
PoolArena.DirectArena
(package private) static class
PoolArena.HeapArena
(package private) static class
PoolArena.SizeClass
-
Field Summary
Fields Modifier and Type Field Description private LongCounter
activeBytesHuge
private LongCounter
allocationsHuge
private long
allocationsNormal
private LongCounter
allocationsSmall
private java.util.List<PoolChunkListMetric>
chunkListMetrics
private LongCounter
deallocationsHuge
private long
deallocationsNormal
private long
deallocationsSmall
(package private) int
directMemoryCacheAlignment
private static boolean
HAS_UNSAFE
private java.util.concurrent.locks.ReentrantLock
lock
(package private) int
numSmallSubpagePools
(package private) java.util.concurrent.atomic.AtomicInteger
numThreadCaches
(package private) PooledByteBufAllocator
parent
private PoolChunkList<T>
q000
private PoolChunkList<T>
q025
private PoolChunkList<T>
q050
private PoolChunkList<T>
q075
private PoolChunkList<T>
q100
private PoolChunkList<T>
qInit
(package private) PoolSubpage<T>[]
smallSubpagePools
-
Fields inherited from class io.netty.buffer.SizeClasses
chunkSize, LOG2_QUANTUM, lookupMaxSize, nPSizes, nSizes, nSubpages, pageShifts, pageSize, smallMaxSizeIdx
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PoolArena(PooledByteBufAllocator parent, int pageSize, int pageShifts, int chunkSize, int cacheAlignment)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) PooledByteBuf<T>
allocate(PoolThreadCache cache, int reqCapacity, int maxCapacity)
private void
allocate(PoolThreadCache cache, PooledByteBuf<T> buf, int reqCapacity)
private void
allocateHuge(PooledByteBuf<T> buf, int reqCapacity)
private void
allocateNormal(PooledByteBuf<T> buf, int reqCapacity, int sizeIdx, PoolThreadCache threadCache)
private static void
appendPoolSubPages(java.lang.StringBuilder buf, PoolSubpage<?>[] subpages)
java.util.List<PoolChunkListMetric>
chunkLists()
Returns an unmodifiableList
which holdsPoolChunkListMetric
s.protected abstract void
destroyChunk(PoolChunk<T> chunk)
private void
destroyPoolChunkLists(PoolChunkList<T>... chunkLists)
private static void
destroyPoolSubPages(PoolSubpage<?>[] pages)
protected void
finalize()
(package private) void
free(PoolChunk<T> chunk, java.nio.ByteBuffer nioBuffer, long handle, int normCapacity, PoolThreadCache cache)
(package private) void
freeChunk(PoolChunk<T> chunk, long handle, int normCapacity, PoolArena.SizeClass sizeClass, java.nio.ByteBuffer nioBuffer, boolean finalizer)
private void
incSmallAllocation()
(package private) abstract boolean
isDirect()
(package private) void
lock()
protected abstract void
memoryCopy(T src, int srcOffset, PooledByteBuf<T> dst, int length)
protected abstract PooledByteBuf<T>
newByteBuf(int maxCapacity)
protected abstract PoolChunk<T>
newChunk(int pageSize, int maxPageIdx, int pageShifts, int chunkSize)
private PoolSubpage<T>[]
newSubpagePoolArray(int size)
private PoolSubpage<T>
newSubpagePoolHead(int index)
protected abstract PoolChunk<T>
newUnpooledChunk(int capacity)
long
numActiveAllocations()
Return the number of currently active allocations.long
numActiveBytes()
Return the number of active bytes that are currently allocated by the arena.long
numActiveHugeAllocations()
Return the number of currently active huge allocations.long
numActiveNormalAllocations()
Return the number of currently active normal allocations.long
numActiveSmallAllocations()
Return the number of currently active small allocations.long
numActiveTinyAllocations()
Return the number of currently active tiny allocations.long
numAllocations()
Return the number of allocations done via the arena.int
numChunkLists()
Returns the number of chunk lists for the arena.long
numDeallocations()
Return the number of deallocations done via the arena.long
numHugeAllocations()
Return the number of huge allocations done via the arena.long
numHugeDeallocations()
Return the number of huge deallocations done via the arena.long
numNormalAllocations()
Return the number of normal allocations done via the arena.long
numNormalDeallocations()
Return the number of normal deallocations done via the arena.long
numPinnedBytes()
Return the number of bytes that are currently pinned to buffer instances, by the arena.long
numSmallAllocations()
Return the number of small allocations done via the arena.long
numSmallDeallocations()
Return the number of small deallocations done via the arena.int
numSmallSubpages()
Returns the number of small sub-pages for the arena.int
numThreadCaches()
Returns the number of thread caches backed by this arena.long
numTinyAllocations()
Return the number of tiny allocations done via the arena.long
numTinyDeallocations()
Return the number of tiny deallocations done via the arena.int
numTinySubpages()
Returns the number of tiny sub-pages for the arena.(package private) void
reallocate(PooledByteBuf<T> buf, int newCapacity)
private static PoolArena.SizeClass
sizeClass(long handle)
java.util.List<PoolSubpageMetric>
smallSubpages()
Returns an unmodifiableList
which holdsPoolSubpageMetric
s for small sub-pages.private static java.util.List<PoolSubpageMetric>
subPageMetricList(PoolSubpage<?>[] pages)
private void
tcacheAllocateNormal(PoolThreadCache cache, PooledByteBuf<T> buf, int reqCapacity, int sizeIdx)
private void
tcacheAllocateSmall(PoolThreadCache cache, PooledByteBuf<T> buf, int reqCapacity, int sizeIdx)
java.util.List<PoolSubpageMetric>
tinySubpages()
Returns an unmodifiableList
which holdsPoolSubpageMetric
s for tiny sub-pages.java.lang.String
toString()
(package private) void
unlock()
-
Methods inherited from class io.netty.buffer.SizeClasses
normalizeSize, pageIdx2size, pageIdx2sizeCompute, pages2pageIdx, pages2pageIdxFloor, size2SizeIdx, sizeIdx2size, sizeIdx2sizeCompute
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty.buffer.SizeClassesMetric
normalizeSize, pageIdx2size, pageIdx2sizeCompute, pages2pageIdx, pages2pageIdxFloor, size2SizeIdx, sizeIdx2size, sizeIdx2sizeCompute
-
-
-
-
Field Detail
-
HAS_UNSAFE
private static final boolean HAS_UNSAFE
-
parent
final PooledByteBufAllocator parent
-
numSmallSubpagePools
final int numSmallSubpagePools
-
directMemoryCacheAlignment
final int directMemoryCacheAlignment
-
smallSubpagePools
final PoolSubpage<T>[] smallSubpagePools
-
q050
private final PoolChunkList<T> q050
-
q025
private final PoolChunkList<T> q025
-
q000
private final PoolChunkList<T> q000
-
qInit
private final PoolChunkList<T> qInit
-
q075
private final PoolChunkList<T> q075
-
q100
private final PoolChunkList<T> q100
-
chunkListMetrics
private final java.util.List<PoolChunkListMetric> chunkListMetrics
-
allocationsNormal
private long allocationsNormal
-
allocationsSmall
private final LongCounter allocationsSmall
-
allocationsHuge
private final LongCounter allocationsHuge
-
activeBytesHuge
private final LongCounter activeBytesHuge
-
deallocationsSmall
private long deallocationsSmall
-
deallocationsNormal
private long deallocationsNormal
-
deallocationsHuge
private final LongCounter deallocationsHuge
-
numThreadCaches
final java.util.concurrent.atomic.AtomicInteger numThreadCaches
-
lock
private final java.util.concurrent.locks.ReentrantLock lock
-
-
Constructor Detail
-
PoolArena
protected PoolArena(PooledByteBufAllocator parent, int pageSize, int pageShifts, int chunkSize, int cacheAlignment)
-
-
Method Detail
-
newSubpagePoolHead
private PoolSubpage<T> newSubpagePoolHead(int index)
-
newSubpagePoolArray
private PoolSubpage<T>[] newSubpagePoolArray(int size)
-
isDirect
abstract boolean isDirect()
-
allocate
PooledByteBuf<T> allocate(PoolThreadCache cache, int reqCapacity, int maxCapacity)
-
allocate
private void allocate(PoolThreadCache cache, PooledByteBuf<T> buf, int reqCapacity)
-
tcacheAllocateSmall
private void tcacheAllocateSmall(PoolThreadCache cache, PooledByteBuf<T> buf, int reqCapacity, int sizeIdx)
-
tcacheAllocateNormal
private void tcacheAllocateNormal(PoolThreadCache cache, PooledByteBuf<T> buf, int reqCapacity, int sizeIdx)
-
allocateNormal
private void allocateNormal(PooledByteBuf<T> buf, int reqCapacity, int sizeIdx, PoolThreadCache threadCache)
-
incSmallAllocation
private void incSmallAllocation()
-
allocateHuge
private void allocateHuge(PooledByteBuf<T> buf, int reqCapacity)
-
free
void free(PoolChunk<T> chunk, java.nio.ByteBuffer nioBuffer, long handle, int normCapacity, PoolThreadCache cache)
-
sizeClass
private static PoolArena.SizeClass sizeClass(long handle)
-
freeChunk
void freeChunk(PoolChunk<T> chunk, long handle, int normCapacity, PoolArena.SizeClass sizeClass, java.nio.ByteBuffer nioBuffer, boolean finalizer)
-
reallocate
void reallocate(PooledByteBuf<T> buf, int newCapacity)
-
numThreadCaches
public int numThreadCaches()
Description copied from interface:PoolArenaMetric
Returns the number of thread caches backed by this arena.- Specified by:
numThreadCaches
in interfacePoolArenaMetric
-
numTinySubpages
public int numTinySubpages()
Description copied from interface:PoolArenaMetric
Returns the number of tiny sub-pages for the arena.- Specified by:
numTinySubpages
in interfacePoolArenaMetric
-
numSmallSubpages
public int numSmallSubpages()
Description copied from interface:PoolArenaMetric
Returns the number of small sub-pages for the arena.- Specified by:
numSmallSubpages
in interfacePoolArenaMetric
-
numChunkLists
public int numChunkLists()
Description copied from interface:PoolArenaMetric
Returns the number of chunk lists for the arena.- Specified by:
numChunkLists
in interfacePoolArenaMetric
-
tinySubpages
public java.util.List<PoolSubpageMetric> tinySubpages()
Description copied from interface:PoolArenaMetric
Returns an unmodifiableList
which holdsPoolSubpageMetric
s for tiny sub-pages.- Specified by:
tinySubpages
in interfacePoolArenaMetric
-
smallSubpages
public java.util.List<PoolSubpageMetric> smallSubpages()
Description copied from interface:PoolArenaMetric
Returns an unmodifiableList
which holdsPoolSubpageMetric
s for small sub-pages.- Specified by:
smallSubpages
in interfacePoolArenaMetric
-
chunkLists
public java.util.List<PoolChunkListMetric> chunkLists()
Description copied from interface:PoolArenaMetric
Returns an unmodifiableList
which holdsPoolChunkListMetric
s.- Specified by:
chunkLists
in interfacePoolArenaMetric
-
subPageMetricList
private static java.util.List<PoolSubpageMetric> subPageMetricList(PoolSubpage<?>[] pages)
-
numAllocations
public long numAllocations()
Description copied from interface:PoolArenaMetric
Return the number of allocations done via the arena. This includes all sizes.- Specified by:
numAllocations
in interfacePoolArenaMetric
-
numTinyAllocations
public long numTinyAllocations()
Description copied from interface:PoolArenaMetric
Return the number of tiny allocations done via the arena.- Specified by:
numTinyAllocations
in interfacePoolArenaMetric
-
numSmallAllocations
public long numSmallAllocations()
Description copied from interface:PoolArenaMetric
Return the number of small allocations done via the arena.- Specified by:
numSmallAllocations
in interfacePoolArenaMetric
-
numNormalAllocations
public long numNormalAllocations()
Description copied from interface:PoolArenaMetric
Return the number of normal allocations done via the arena.- Specified by:
numNormalAllocations
in interfacePoolArenaMetric
-
numDeallocations
public long numDeallocations()
Description copied from interface:PoolArenaMetric
Return the number of deallocations done via the arena. This includes all sizes.- Specified by:
numDeallocations
in interfacePoolArenaMetric
-
numTinyDeallocations
public long numTinyDeallocations()
Description copied from interface:PoolArenaMetric
Return the number of tiny deallocations done via the arena.- Specified by:
numTinyDeallocations
in interfacePoolArenaMetric
-
numSmallDeallocations
public long numSmallDeallocations()
Description copied from interface:PoolArenaMetric
Return the number of small deallocations done via the arena.- Specified by:
numSmallDeallocations
in interfacePoolArenaMetric
-
numNormalDeallocations
public long numNormalDeallocations()
Description copied from interface:PoolArenaMetric
Return the number of normal deallocations done via the arena.- Specified by:
numNormalDeallocations
in interfacePoolArenaMetric
-
numHugeAllocations
public long numHugeAllocations()
Description copied from interface:PoolArenaMetric
Return the number of huge allocations done via the arena.- Specified by:
numHugeAllocations
in interfacePoolArenaMetric
-
numHugeDeallocations
public long numHugeDeallocations()
Description copied from interface:PoolArenaMetric
Return the number of huge deallocations done via the arena.- Specified by:
numHugeDeallocations
in interfacePoolArenaMetric
-
numActiveAllocations
public long numActiveAllocations()
Description copied from interface:PoolArenaMetric
Return the number of currently active allocations.- Specified by:
numActiveAllocations
in interfacePoolArenaMetric
-
numActiveTinyAllocations
public long numActiveTinyAllocations()
Description copied from interface:PoolArenaMetric
Return the number of currently active tiny allocations.- Specified by:
numActiveTinyAllocations
in interfacePoolArenaMetric
-
numActiveSmallAllocations
public long numActiveSmallAllocations()
Description copied from interface:PoolArenaMetric
Return the number of currently active small allocations.- Specified by:
numActiveSmallAllocations
in interfacePoolArenaMetric
-
numActiveNormalAllocations
public long numActiveNormalAllocations()
Description copied from interface:PoolArenaMetric
Return the number of currently active normal allocations.- Specified by:
numActiveNormalAllocations
in interfacePoolArenaMetric
-
numActiveHugeAllocations
public long numActiveHugeAllocations()
Description copied from interface:PoolArenaMetric
Return the number of currently active huge allocations.- Specified by:
numActiveHugeAllocations
in interfacePoolArenaMetric
-
numActiveBytes
public long numActiveBytes()
Description copied from interface:PoolArenaMetric
Return the number of active bytes that are currently allocated by the arena.- Specified by:
numActiveBytes
in interfacePoolArenaMetric
-
numPinnedBytes
public long numPinnedBytes()
Return the number of bytes that are currently pinned to buffer instances, by the arena. The pinned memory is not accessible for use by any other allocation, until the buffers using have all been released.
-
newChunk
protected abstract PoolChunk<T> newChunk(int pageSize, int maxPageIdx, int pageShifts, int chunkSize)
-
newByteBuf
protected abstract PooledByteBuf<T> newByteBuf(int maxCapacity)
-
memoryCopy
protected abstract void memoryCopy(T src, int srcOffset, PooledByteBuf<T> dst, int length)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
appendPoolSubPages
private static void appendPoolSubPages(java.lang.StringBuilder buf, PoolSubpage<?>[] subpages)
-
finalize
protected final void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
destroyPoolSubPages
private static void destroyPoolSubPages(PoolSubpage<?>[] pages)
-
destroyPoolChunkLists
private void destroyPoolChunkLists(PoolChunkList<T>... chunkLists)
-
lock
void lock()
-
unlock
void unlock()
-
-