Top Description Inners Fields Constructors Methods
io.netty5.buffer.pool

pack-priv abstract Class SizeClasses

extends Object
implements SizeClassesMetric
Class Inheritance
All Implemented Interfaces
io.netty5.buffer.pool.SizeClassesMetric
Known Direct Subclasses
io.netty5.buffer.pool.PoolArena
Imports
java.util.concurrent.ConcurrentHashMap

SizeClasses requires pageShifts to be defined prior to inclusion, and it in turn defines:

LOG2_SIZE_CLASS_GROUP: Log of size class count for each size doubling. LOG2_MAX_LOOKUP_SIZE: Log of max size class in the lookup table. sizeClasses: Complete table of [index, log2Group, log2Delta, nDelta, isMultiPageSize, isSubPage, log2DeltaLookup] tuples. index: Size class index. log2Group: Log of group base size (no deltas added). log2Delta: Log of delta to previous size class. nDelta: Delta multiplier. isMultiPageSize: 'yes' if a multiple of the page size, 'no' otherwise. isSubPage: 'yes' if a subpage size class, 'no' otherwise. log2DeltaLookup: Same as log2Delta if a lookup table size class, 'no' otherwise.

nSubpages: Number of subpages size classes. nSizes: Number of size classes. nPSizes: Number of size classes that are multiples of pageSize. smallMaxSizeIdx: Maximum small size class index. lookupMaxclass: Maximum size class included in lookup table. log2NormalMinClass: Log of minimum normal size class.

The first size class and spacing are 1 << LOG2_QUANTUM. Each group has 1 << LOG2_SIZE_CLASS_GROUP of size classes. size = 1 << log2Group + nDelta * (1 << log2Delta) The first size class has an unusual encoding, because the size has to be split between group and delta*nDelta. If pageShift = 13, sizeClasses looks like this: (index, log2Group, log2Delta, nDelta, isMultiPageSize, isSubPage, log2DeltaLookup)

( 0, 4, 4, 0, no, yes, 4) ( 1, 4, 4, 1, no, yes, 4) ( 2, 4, 4, 2, no, yes, 4) ( 3, 4, 4, 3, no, yes, 4)

( 4, 6, 4, 1, no, yes, 4) ( 5, 6, 4, 2, no, yes, 4) ( 6, 6, 4, 3, no, yes, 4) ( 7, 6, 4, 4, no, yes, 4)

( 8, 7, 5, 1, no, yes, 5) ( 9, 7, 5, 2, no, yes, 5) ( 10, 7, 5, 3, no, yes, 5) ( 11, 7, 5, 4, no, yes, 5) ... ... ( 72, 23, 21, 1, yes, no, no) ( 73, 23, 21, 2, yes, no, no) ( 74, 23, 21, 3, yes, no, no) ( 75, 23, 21, 4, yes, no, no)

( 76, 24, 22, 1, yes, no, no)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final ConcurrentHashMap<SizeClasses.SizeClassKey, SizeClasses.SizeClassValue>
protected final int
protected final int
private static final int
private static final int
pack-priv static final int
private static final int
private static final int
private static final int
private final int
private static final int
private static final byte
pack-priv final int
pack-priv final int
pack-priv final int
private final int[]
protected final int
protected final int
private static final int
private final int[]
private final int[]
pack-priv final int
private static final int
private static final byte

Constructor Summary

AccessConstructor and Description
protected
SizeClasses(int pageSize, int pageShifts, int chunkSize, int directMemoryCacheAlignment)

Method Summary

Modifier and TypeMethod and Description
private static int
alignSizeIfNeeded(int size, int alignment)

public int
normalizeSize(int
request size
size
)

Implements io.netty5.buffer.pool.SizeClassesMetric.normalizeSize.

Normalizes usable size that would result from allocating an object with the specified size and alignment.
private static int
public long
pageIdx2size(int pageIdx)

Implements io.netty5.buffer.pool.SizeClassesMetric.pageIdx2size.

Computes size from lookup table according to pageIdx.
public long
pageIdx2sizeCompute(int pageIdx)

Implements io.netty5.buffer.pool.SizeClassesMetric.pageIdx2sizeCompute.

Computes size according to pageIdx.
public int
pages2pageIdx(int
multiples of pageSizes
pages
)

Implements io.netty5.buffer.pool.SizeClassesMetric.pages2pageIdx.

Normalizes request size up to the nearest pageSize class.
private int
pages2pageIdxCompute(int pages, boolean floor)

public int
pages2pageIdxFloor(int
multiples of pageSizes
pages
)

Implements io.netty5.buffer.pool.SizeClassesMetric.pages2pageIdxFloor.

Normalizes request size down to the nearest pageSize class.
public int
size2SizeIdx(int
request size
size
)

Implements io.netty5.buffer.pool.SizeClassesMetric.size2SizeIdx.

Normalizes request size up to the nearest size class.
public int
sizeIdx2size(int sizeIdx)

Implements io.netty5.buffer.pool.SizeClassesMetric.sizeIdx2size.

Computes size from lookup table according to sizeIdx.
public int
sizeIdx2sizeCompute(int sizeIdx)

Implements io.netty5.buffer.pool.SizeClassesMetric.sizeIdx2sizeCompute.

Computes size according to sizeIdx.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CACHEback to summary
private static final ConcurrentHashMap<SizeClasses.SizeClassKey, SizeClasses.SizeClassValue> CACHE
chunkSizeback to summary
protected final int chunkSize
directMemoryCacheAlignmentback to summary
protected final int directMemoryCacheAlignment
LOG2_DELTA_LOOKUP_IDXback to summary
private static final int LOG2_DELTA_LOOKUP_IDX
LOG2_MAX_LOOKUP_SIZEback to summary
private static final int LOG2_MAX_LOOKUP_SIZE
LOG2_QUANTUMback to summary
pack-priv static final int LOG2_QUANTUM
LOG2_SIZE_CLASS_GROUPback to summary
private static final int LOG2_SIZE_CLASS_GROUP
LOG2DELTA_IDXback to summary
private static final int LOG2DELTA_IDX
LOG2GROUP_IDXback to summary
private static final int LOG2GROUP_IDX
lookupMaxSizeback to summary
private final int lookupMaxSize
NDELTA_IDXback to summary
private static final int NDELTA_IDX
noback to summary
private static final byte no
nPSizesback to summary
pack-priv final int nPSizes
nSizesback to summary
pack-priv final int nSizes
nSubpagesback to summary
pack-priv final int nSubpages
pageIdx2sizeTabback to summary
private final int[] pageIdx2sizeTab
pageShiftsback to summary
protected final int pageShifts
pageSizeback to summary
protected final int pageSize
PAGESIZE_IDXback to summary
private static final int PAGESIZE_IDX
size2idxTabback to summary
private final int[] size2idxTab
sizeIdx2sizeTabback to summary
private final int[] sizeIdx2sizeTab
smallMaxSizeIdxback to summary
pack-priv final int smallMaxSizeIdx
SUBPAGE_IDXback to summary
private static final int SUBPAGE_IDX
yesback to summary
private static final byte yes

Constructor Detail

SizeClassesback to summary
protected SizeClasses(int pageSize, int pageShifts, int chunkSize, int directMemoryCacheAlignment)

Method Detail

alignSizeIfNeededback to summary
private static int alignSizeIfNeeded(int size, int alignment)
normalizeSizeback to summary
public int normalizeSize(int size)

Implements io.netty5.buffer.pool.SizeClassesMetric.normalizeSize.

Doc from io.netty5.buffer.pool.SizeClassesMetric.normalizeSize.

Normalizes usable size that would result from allocating an object with the specified size and alignment.

Parameters
size:int

request size

Returns:int

normalized size

Annotations
@Override
normalizeSizeComputeback to summary
private static int normalizeSizeCompute(int size)
pageIdx2sizeback to summary
public long pageIdx2size(int pageIdx)

Implements io.netty5.buffer.pool.SizeClassesMetric.pageIdx2size.

Doc from io.netty5.buffer.pool.SizeClassesMetric.pageIdx2size.

Computes size from lookup table according to pageIdx.

Returns:long

size which is multiples of pageSize.

Annotations
@Override
pageIdx2sizeComputeback to summary
public long pageIdx2sizeCompute(int pageIdx)

Implements io.netty5.buffer.pool.SizeClassesMetric.pageIdx2sizeCompute.

Doc from io.netty5.buffer.pool.SizeClassesMetric.pageIdx2sizeCompute.

Computes size according to pageIdx.

Returns:long

size which is multiples of pageSize

Annotations
@Override
pages2pageIdxback to summary
public int pages2pageIdx(int pages)

Implements io.netty5.buffer.pool.SizeClassesMetric.pages2pageIdx.

Doc from io.netty5.buffer.pool.SizeClassesMetric.pages2pageIdx.

Normalizes request size up to the nearest pageSize class.

Parameters
pages:int

multiples of pageSizes

Returns:int

pageIdx of the pageSize class

Annotations
@Override
pages2pageIdxComputeback to summary
private int pages2pageIdxCompute(int pages, boolean floor)
pages2pageIdxFloorback to summary
public int pages2pageIdxFloor(int pages)

Implements io.netty5.buffer.pool.SizeClassesMetric.pages2pageIdxFloor.

Doc from io.netty5.buffer.pool.SizeClassesMetric.pages2pageIdxFloor.

Normalizes request size down to the nearest pageSize class.

Parameters
pages:int

multiples of pageSizes

Returns:int

pageIdx of the pageSize class

Annotations
@Override
size2SizeIdxback to summary
public int size2SizeIdx(int size)

Implements io.netty5.buffer.pool.SizeClassesMetric.size2SizeIdx.

Doc from io.netty5.buffer.pool.SizeClassesMetric.size2SizeIdx.

Normalizes request size up to the nearest size class.

Parameters
size:int

request size

Returns:int

sizeIdx of the size class

Annotations
@Override
sizeIdx2sizeback to summary
public int sizeIdx2size(int sizeIdx)

Implements io.netty5.buffer.pool.SizeClassesMetric.sizeIdx2size.

Doc from io.netty5.buffer.pool.SizeClassesMetric.sizeIdx2size.

Computes size from lookup table according to sizeIdx.

Returns:int

size

Annotations
@Override
sizeIdx2sizeComputeback to summary
public int sizeIdx2sizeCompute(int sizeIdx)

Implements io.netty5.buffer.pool.SizeClassesMetric.sizeIdx2sizeCompute.

Doc from io.netty5.buffer.pool.SizeClassesMetric.sizeIdx2sizeCompute.

Computes size according to sizeIdx.

Returns:int

size

Annotations
@Override
io.netty5.buffer.pool back to summary

private final Class SizeClasses.SizeClassKey

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final int
pack-priv final int
pack-priv final int
pack-priv final int

Constructor Summary

AccessConstructor and Description
private
SizeClassKey(int pageSize, int pageShifts, int chunkSize, int directMemoryCacheAlignment)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

chunkSizeback to summary
pack-priv final int chunkSize
directMemoryCacheAlignmentback to summary
pack-priv final int directMemoryCacheAlignment
pageShiftsback to summary
pack-priv final int pageShifts
pageSizeback to summary
pack-priv final int pageSize

Constructor Detail

SizeClassKeyback to summary
private SizeClassKey(int pageSize, int pageShifts, int chunkSize, int directMemoryCacheAlignment)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
io.netty5.buffer.pool back to summary

private final Class SizeClasses.SizeClassValue

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final SizeClasses.SizeClassKey
pack-priv final int
pack-priv final int
pack-priv final int
pack-priv final int
pack-priv final int[]
pack-priv final int[]
pack-priv final int[]
pack-priv final int

Constructor Summary

AccessConstructor and Description
pack-priv
SizeClassValue(SizeClasses.SizeClassKey key, int directMemoryCacheAlignment)

Method Summary

Modifier and TypeMethod and Description
private static int
calculateSize(int log2Group, int nDelta, int log2Delta)

private static int[]
newIdx2SizeTab(short[][] sizeClasses, int nSizes, int directMemoryCacheAlignment)

private static int[]
newPageIdx2sizeTab(short[][] sizeClasses, int nSizes, int nPSizes, int directMemoryCacheAlignment)

private static int[]
newSize2idxTab(int lookupMaxSize, short[][] sizeClasses)

private static short[]
newSizeClass(int index, int log2Group, int log2Delta, int nDelta, SizeClasses.SizeClassKey key)

private static int
sizeOf(short[] sizeClass, int directMemoryCacheAlignment)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

keyback to summary
pack-priv final SizeClasses.SizeClassKey key
lookupMaxSizeback to summary
pack-priv final int lookupMaxSize
nPSizesback to summary
pack-priv final int nPSizes
nSizesback to summary
pack-priv final int nSizes
nSubpagesback to summary
pack-priv final int nSubpages
pageIdx2sizeTabback to summary
pack-priv final int[] pageIdx2sizeTab
size2idxTabback to summary
pack-priv final int[] size2idxTab
sizeIdx2sizeTabback to summary
pack-priv final int[] sizeIdx2sizeTab
smallMaxSizeIdxback to summary
pack-priv final int smallMaxSizeIdx

Constructor Detail

SizeClassValueback to summary
pack-priv SizeClassValue(SizeClasses.SizeClassKey key, int directMemoryCacheAlignment)

Method Detail

calculateSizeback to summary
private static int calculateSize(int log2Group, int nDelta, int log2Delta)
newIdx2SizeTabback to summary
private static int[] newIdx2SizeTab(short[][] sizeClasses, int nSizes, int directMemoryCacheAlignment)
newPageIdx2sizeTabback to summary
private static int[] newPageIdx2sizeTab(short[][] sizeClasses, int nSizes, int nPSizes, int directMemoryCacheAlignment)
newSize2idxTabback to summary
private static int[] newSize2idxTab(int lookupMaxSize, short[][] sizeClasses)
newSizeClassback to summary
private static short[] newSizeClass(int index, int log2Group, int log2Delta, int nDelta, SizeClasses.SizeClassKey key)
sizeOfback to summary
private static int sizeOf(short[] sizeClass, int directMemoryCacheAlignment)