Class SkipListArena

  • public class SkipListArena
    extends java.lang.Object
    SkipList allocation buffer to reduce memory fragment. Adapted from HBase project.

    The SkipListArena is basically a bump-the-pointer allocator that allocates big (default 2MB) byte[] chunks from and then handles it out to threads that request slices into the array.

    The purpose of this class is to combat heap fragmentation in the bookie. By ensuring that all KeyValues in a given SkipList refer only to large chunks of contiguous memory, we ensure that large blocks get freed up when the SkipList is flushed.

    Without the Arena, 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.

    • Field Detail

      • chunkSize

        final int chunkSize
      • maxAlloc

        final int maxAlloc
    • Method Detail

      • allocateBytes

        public SkipListArena.MemorySlice 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.