Crate slab_alloc [] [src]

An ObjectAlloc which allocates objects in contiguous slabs and caches constructed objects.

Design

The SlabAlloc is based largely on the slab allocator design originally inroduced in the SunOS 5.4 kernel and described in depth in The Slab Allocator: An Object-Caching Kernel Memory Allocator. This implementation stays somewhat true to the original design, although it includes a number of performance improvements and modifications for user-land.

The SlabAlloc provides a number of performance benefits:

  • As with any ObjectAlloc, object caching reduces the overhead of object initialization in many cases.
  • As with any ObjectAlloc, only needing to allocate objects of a particular size and alignment allows for optimizations not available to general-purpose allocators.
  • Internal and external fragmentation are kept to a minimum.
  • A "coloring" scheme described in Section 4 of the original paper improves cache utilization.

Structs

SlabAlloc

A typed slab allocator.

SlabAllocBuilder

A builder for SlabAllocs.

UntypedSlabAlloc

An untyped slab allocator.

UntypedSlabAllocBuilder

A builder for UntypedSlabAllocs.

Traits

BackingAlloc

A pair of UntypedObjectAllocs to provide memory for a slab allocator.