Package io.netty.buffer
Class AdaptivePoolingAllocator.HistogramChunkController
- java.lang.Object
-
- io.netty.buffer.AdaptivePoolingAllocator.HistogramChunkController
-
- All Implemented Interfaces:
AdaptivePoolingAllocator.ChunkController,AdaptivePoolingAllocator.ChunkReleasePredicate
- Enclosing class:
- AdaptivePoolingAllocator
private static final class AdaptivePoolingAllocator.HistogramChunkController extends java.lang.Object implements AdaptivePoolingAllocator.ChunkController, AdaptivePoolingAllocator.ChunkReleasePredicate
-
-
Field Summary
Fields Modifier and Type Field Description private AdaptivePoolingAllocator.ChunkRegistrychunkRegistryprivate intdatumCountprivate intdatumTargetprivate AdaptivePoolingAllocator.MagazineGroupgroupprivate booleanhasHadRotationprivate short[]histoprivate static intHISTO_BUCKET_COUNTprivate static int[]HISTO_BUCKETSprivate inthistoIndexprivate short[][]histosprivate static intINIT_DATUM_TARGETprivate intlocalPrefChunkSizeprivate intlocalUpperBufSizeprivate static intMAX_DATUM_TARGETprivate static intMIN_DATUM_TARGETprivate booleanshareableprivate intsharedPrefChunkSizeprivate int[]sums
-
Constructor Summary
Constructors Modifier Constructor Description privateHistogramChunkController(AdaptivePoolingAllocator.MagazineGroup group, boolean shareable)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static intbinarySearchInsertionPoint(int index)(package private) static intbucketToSize(int sizeBucket)intcomputeBufferCapacity(int requestedSize, int maxCapacity, boolean isReallocation)Compute the "fast max capacity" value for the buffer.voidinitializeSharedStateIn(AdaptivePoolingAllocator.ChunkController chunkController)Initialize the given chunk factory with shared statistics state (if any) from this factory.AdaptivePoolingAllocator.ChunknewChunkAllocation(int promptingSize, AdaptivePoolingAllocator.Magazine magazine)Allocate a newAdaptivePoolingAllocator.Chunkfor the givenAdaptivePoolingAllocator.Magazine.(package private) intpreferredChunkSize()Get the preferred chunk size, based on statistics from the recorded allocation sizes.private voidrecordAllocationSize(int bufferSizeToRecord)private voidrotateHistograms()booleanshouldReleaseChunk(int chunkSize)(package private) static intsizeToBucket(int size)
-
-
-
Field Detail
-
MIN_DATUM_TARGET
private static final int MIN_DATUM_TARGET
- See Also:
- Constant Field Values
-
MAX_DATUM_TARGET
private static final int MAX_DATUM_TARGET
- See Also:
- Constant Field Values
-
INIT_DATUM_TARGET
private static final int INIT_DATUM_TARGET
- See Also:
- Constant Field Values
-
HISTO_BUCKET_COUNT
private static final int HISTO_BUCKET_COUNT
- See Also:
- Constant Field Values
-
HISTO_BUCKETS
private static final int[] HISTO_BUCKETS
-
group
private final AdaptivePoolingAllocator.MagazineGroup group
-
shareable
private final boolean shareable
-
histos
private final short[][] histos
-
chunkRegistry
private final AdaptivePoolingAllocator.ChunkRegistry chunkRegistry
-
histo
private short[] histo
-
sums
private final int[] sums
-
histoIndex
private int histoIndex
-
datumCount
private int datumCount
-
datumTarget
private int datumTarget
-
hasHadRotation
private boolean hasHadRotation
-
sharedPrefChunkSize
private volatile int sharedPrefChunkSize
-
localPrefChunkSize
private volatile int localPrefChunkSize
-
localUpperBufSize
private volatile int localUpperBufSize
-
-
Constructor Detail
-
HistogramChunkController
private HistogramChunkController(AdaptivePoolingAllocator.MagazineGroup group, boolean shareable)
-
-
Method Detail
-
computeBufferCapacity
public int computeBufferCapacity(int requestedSize, int maxCapacity, boolean isReallocation)Description copied from interface:AdaptivePoolingAllocator.ChunkControllerCompute the "fast max capacity" value for the buffer.- Specified by:
computeBufferCapacityin interfaceAdaptivePoolingAllocator.ChunkController
-
recordAllocationSize
private void recordAllocationSize(int bufferSizeToRecord)
-
sizeToBucket
static int sizeToBucket(int size)
-
binarySearchInsertionPoint
private static int binarySearchInsertionPoint(int index)
-
bucketToSize
static int bucketToSize(int sizeBucket)
-
rotateHistograms
private void rotateHistograms()
-
preferredChunkSize
int preferredChunkSize()
Get the preferred chunk size, based on statistics from the recorded allocation sizes.This method must be thread-safe.
- Returns:
- The currently preferred chunk allocation size.
-
initializeSharedStateIn
public void initializeSharedStateIn(AdaptivePoolingAllocator.ChunkController chunkController)
Description copied from interface:AdaptivePoolingAllocator.ChunkControllerInitialize the given chunk factory with shared statistics state (if any) from this factory.- Specified by:
initializeSharedStateInin interfaceAdaptivePoolingAllocator.ChunkController
-
newChunkAllocation
public AdaptivePoolingAllocator.Chunk newChunkAllocation(int promptingSize, AdaptivePoolingAllocator.Magazine magazine)
Description copied from interface:AdaptivePoolingAllocator.ChunkControllerAllocate a newAdaptivePoolingAllocator.Chunkfor the givenAdaptivePoolingAllocator.Magazine.- Specified by:
newChunkAllocationin interfaceAdaptivePoolingAllocator.ChunkController
-
shouldReleaseChunk
public boolean shouldReleaseChunk(int chunkSize)
- Specified by:
shouldReleaseChunkin interfaceAdaptivePoolingAllocator.ChunkReleasePredicate
-
-