@InterfaceAudience.Private public class HeapMemStoreLAB extends Object implements MemStoreLAB
The MemStoreLAB is basically a bump-the-pointer allocator that allocates big (2MB) byte[] chunks from and then doles it out to threads that request slices into the array.
The purpose of this class is to combat heap fragmentation in the regionserver. By ensuring that all KeyValues in a given memstore refer only to large chunks of contiguous memory, we ensure that large blocks get freed up when the memstore is flushed.
Without the MSLAB, the byte array allocated during insertion end up interleaved throughout the heap, and the old generation gets progressively more fragmented until a stop-the-world compacting collection occurs.
TODO: we should probably benchmark whether word-aligning the allocations would provide a performance improvement - probably would speed up the Bytes.toLong/Bytes.toInt calls in KeyValue, but some of those are cached anyway
| 构造器和说明 |
|---|
HeapMemStoreLAB() |
HeapMemStoreLAB(org.apache.hadoop.conf.Configuration conf) |
| 限定符和类型 | 方法和说明 |
|---|---|
ByteRange |
allocateBytes(int size)
Allocate a slice of the given length.
|
void |
close()
Close this instance since it won't be used any more, try to put the chunks
back to pool
|
void |
decScannerCount()
Called when closing a scanner on the data of this MemStoreLAB
|
void |
incScannerCount()
Called when opening a scanner on the data of this MemStoreLAB
|
public HeapMemStoreLAB()
public HeapMemStoreLAB(org.apache.hadoop.conf.Configuration conf)
public ByteRange allocateBytes(int size)
allocateBytes 在接口中 MemStoreLABByteRangepublic void close()
close 在接口中 MemStoreLABpublic void incScannerCount()
incScannerCount 在接口中 MemStoreLABpublic void decScannerCount()
decScannerCount 在接口中 MemStoreLABCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.