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 Object
implements AdaptivePoolingAllocator.ChunkController, AdaptivePoolingAllocator.ChunkReleasePredicate
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AdaptivePoolingAllocator.ChunkRegistryprivate intprivate intprivate final AdaptivePoolingAllocator.MagazineGroupprivate booleanprivate short[]private static final intprivate static final int[]private intprivate final short[][]private static final intprivate intprivate intprivate static final intprivate static final intprivate final booleanprivate intprivate final int[] -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateHistogramChunkController(AdaptivePoolingAllocator.MagazineGroup group, boolean shareable) -
Method Summary
Modifier and TypeMethodDescriptionprivate 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.newChunkAllocation(int promptingSize, AdaptivePoolingAllocator.Magazine magazine) Allocate a newAdaptivePoolingAllocator.Chunkfor the givenAdaptivePoolingAllocator.Magazine.(package private) intGet the preferred chunk size, based on statistics from the recorded allocation sizes.private voidrecordAllocationSize(int bufferSizeToRecord) private voidbooleanshouldReleaseChunk(int chunkSize) (package private) static intsizeToBucket(int size)
-
Field Details
-
MIN_DATUM_TARGET
private static final int MIN_DATUM_TARGET- See Also:
-
MAX_DATUM_TARGET
private static final int MAX_DATUM_TARGET- See Also:
-
INIT_DATUM_TARGET
private static final int INIT_DATUM_TARGET- See Also:
-
HISTO_BUCKET_COUNT
private static final int HISTO_BUCKET_COUNT- See Also:
-
HISTO_BUCKETS
private static final int[] HISTO_BUCKETS -
group
-
histos
private final short[][] histos -
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 -
localPrefChunkSize
private volatile int localPrefChunkSize -
localUpperBufSize
private volatile int localUpperBufSize
-
-
Constructor Details
-
HistogramChunkController
-
-
Method Details
-
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.
-
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
-