A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SlabAllocator Class Reference

#include <SlabAllocator.h>

+ Collaboration diagram for SlabAllocator:

Public Member Functions

 SlabAllocator (const size_t limit, bool opt4hashmap=false)
 
 SlabAllocator (void *memPool, const size_t limit, size_t pageSize, size_t alignment)
 
 SlabAllocator (void *memPool, const size_t limit, bool opt4hashmap=false)
 
 ~SlabAllocator ()
 
void init (const size_t limit, const double factor, const bool prealloc)
 
void * slabs_alloc (const size_t size)
 
void * slabs_alloc_unsafe (const size_t size)
 
void slabs_free (void *ptr, size_t size)
 
void slabs_free_unsafe (void *ptr, size_t size)
 
void * do_slabs_alloc (const size_t size)
 
void do_slabs_free (void *ptr, const size_t size)
 
void do_slabs_free (void *ptr, const size_t size, unsigned int id)
 
unsigned int slabs_clsid (const size_t size)
 
int do_slabs_newslab (const unsigned int id)
 
void * get_page_from_global_pool (void)
 
int grow_slab_list (const unsigned int id)
 
void * memory_allocate (size_t size)
 
void slabs_preallocate (const unsigned int maxslabs)
 
void split_slab_page_into_freelist (char *ptr, const unsigned int id)
 

Private Attributes

size_t mem_limit = 0
 
size_t mem_malloced = 0
 
bool mem_limit_reached = false
 
int power_largest
 
void * mem_base = NULL
 
void * mem_current = NULL
 
size_t mem_avail = 0
 
pthread_mutex_t slabs_lock
 
struct settings_t settings
 
slabclass_t slabclass [MAX_NUMBER_OF_SLAB_CLASSES]
 
bool opt4hashmap = false
 
bool opt4sharedmem = false
 
bool useExternalMemory = false
 

Detailed Description

Definition at line 73 of file SlabAllocator.h.

Constructor & Destructor Documentation

SlabAllocator::SlabAllocator ( const size_t  limit,
bool  opt4hashmap = false 
)

Definition at line 33 of file SlabAllocator.cc.

+ Here is the call graph for this function:

SlabAllocator::SlabAllocator ( void *  memPool,
const size_t  limit,
size_t  pageSize,
size_t  alignment 
)

Definition at line 52 of file SlabAllocator.cc.

+ Here is the call graph for this function:

SlabAllocator::SlabAllocator ( void *  memPool,
const size_t  limit,
bool  opt4hashmap = false 
)

Definition at line 64 of file SlabAllocator.cc.

+ Here is the call graph for this function:

SlabAllocator::~SlabAllocator ( )

Definition at line 86 of file SlabAllocator.cc.

Member Function Documentation

void * SlabAllocator::do_slabs_alloc ( const size_t  size)

Definition at line 311 of file SlabAllocator.cc.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SlabAllocator::do_slabs_free ( void *  ptr,
const size_t  size 
)

Definition at line 381 of file SlabAllocator.cc.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SlabAllocator::do_slabs_free ( void *  ptr,
const size_t  size,
unsigned int  id 
)

Definition at line 359 of file SlabAllocator.cc.

int SlabAllocator::do_slabs_newslab ( const unsigned int  id)

Definition at line 198 of file SlabAllocator.cc.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void * SlabAllocator::get_page_from_global_pool ( void  )

Definition at line 238 of file SlabAllocator.cc.

+ Here is the caller graph for this function:

int SlabAllocator::grow_slab_list ( const unsigned int  id)

Definition at line 224 of file SlabAllocator.cc.

+ Here is the caller graph for this function:

void SlabAllocator::init ( const size_t  limit,
const double  factor,
const bool  prealloc 
)

Init the subsystem. 1st argument is the limit on no. of bytes to allocate, 0 if no limit. 2nd argument is the growth factor; each slab will use a chunk size equal to the previous slab's chunk size times this factor. 3rd argument specifies if the slab allocator should allocate all memory up front (if true), or allocate memory in chunks as it is needed (if false)

Definition at line 99 of file SlabAllocator.cc.

+ Here is the caller graph for this function:

void * SlabAllocator::memory_allocate ( size_t  size)

Definition at line 257 of file SlabAllocator.cc.

+ Here is the caller graph for this function:

void * SlabAllocator::slabs_alloc ( const size_t  size)

Definition at line 287 of file SlabAllocator.cc.

+ Here is the call graph for this function:

void * SlabAllocator::slabs_alloc_unsafe ( const size_t  size)

Definition at line 294 of file SlabAllocator.cc.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int SlabAllocator::slabs_clsid ( const size_t  size)

Definition at line 299 of file SlabAllocator.cc.

+ Here is the caller graph for this function:

void SlabAllocator::slabs_free ( void *  ptr,
size_t  size 
)

Free previously allocated object

Definition at line 349 of file SlabAllocator.cc.

+ Here is the call graph for this function:

void SlabAllocator::slabs_free_unsafe ( void *  ptr,
size_t  size 
)

Definition at line 355 of file SlabAllocator.cc.

+ Here is the call graph for this function:

void SlabAllocator::slabs_preallocate ( const unsigned int  maxslabs)

Definition at line 173 of file SlabAllocator.cc.

+ Here is the call graph for this function:

void SlabAllocator::split_slab_page_into_freelist ( char *  ptr,
const unsigned int  id 
)

Definition at line 248 of file SlabAllocator.cc.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

size_t SlabAllocator::mem_avail = 0
private

Definition at line 114 of file SlabAllocator.h.

void* SlabAllocator::mem_base = NULL
private

Definition at line 112 of file SlabAllocator.h.

void* SlabAllocator::mem_current = NULL
private

Definition at line 113 of file SlabAllocator.h.

size_t SlabAllocator::mem_limit = 0
private

Definition at line 108 of file SlabAllocator.h.

bool SlabAllocator::mem_limit_reached = false
private

Definition at line 110 of file SlabAllocator.h.

size_t SlabAllocator::mem_malloced = 0
private

Definition at line 109 of file SlabAllocator.h.

bool SlabAllocator::opt4hashmap = false
private

Definition at line 118 of file SlabAllocator.h.

bool SlabAllocator::opt4sharedmem = false
private

Definition at line 119 of file SlabAllocator.h.

int SlabAllocator::power_largest
private

Definition at line 111 of file SlabAllocator.h.

struct settings_t SlabAllocator::settings
private

Definition at line 116 of file SlabAllocator.h.

slabclass_t SlabAllocator::slabclass[MAX_NUMBER_OF_SLAB_CLASSES]
private

Definition at line 117 of file SlabAllocator.h.

pthread_mutex_t SlabAllocator::slabs_lock
private

Definition at line 115 of file SlabAllocator.h.

bool SlabAllocator::useExternalMemory = false
private

Definition at line 120 of file SlabAllocator.h.


The documentation for this class was generated from the following files: