org.apache.hadoop.hbase.regionserver
Class MemStoreLAB

java.lang.Object
  extended by org.apache.hadoop.hbase.regionserver.MemStoreLAB

public class MemStoreLAB
extends Object

A memstore-local allocation buffer.

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


Nested Class Summary
static class MemStoreLAB.Allocation
          The result of a single allocation.
 
Constructor Summary
MemStoreLAB()
           
MemStoreLAB(org.apache.hadoop.conf.Configuration conf)
           
 
Method Summary
 MemStoreLAB.Allocation allocateBytes(int size)
          Allocate a slice of the given length.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemStoreLAB

public MemStoreLAB()

MemStoreLAB

public MemStoreLAB(org.apache.hadoop.conf.Configuration conf)
Method Detail

allocateBytes

public MemStoreLAB.Allocation allocateBytes(int size)
Allocate a slice of the given length. If the size is larger than the maximum size specified for this allocator, returns null.



Copyright © 2011 The Apache Software Foundation. All Rights Reserved.