cp_mempool

Section: libcprops - cp_mempool (3)
Updated: SEPTEMBER 2006
Index Return to Main Contents [view source]
 

NAME

cp_shared_mempool - a shareable memory pool implementation

 

DESCRIPTION

cp_shared_mempool is a collection of cp_mempool objects. cp_shared_mempool allows sharing cp_mempool instances that serve the same allocation size. Call cp_shared_mempool_register to request an allocation size and use the returned cp_mempool.

cp_shared_mempool may also be used for aribitrary sizes allocations, but this does not necessarily improve performance. Tests on Open BSD show significant gains, whereas tests on Linux show a performance degradation for generic allocation operations. Using cp_shared_mempool to share cp_mempool objects between cp_* data structures does not reduce performance. The test results are not conclusive and performance characteristics may also be application specific. For best results, benchmark performance for your application in realistic deployment scenarios before deciding whether to use cp_shared_mempool.

After instantiating a cp_shared_mempool, you may set one of CP_SHARED_MEMPOOL_FASTER or CP_SHARED_MEMPOOL_SMALLER. If FASTER is set, requests for unregistered allocation sizes will return the requested size rounded up to the machine word size, after instantiating a cp_mempool serving the requested size if none exists. This could potentially use up large amounts of memory. If SMALLER is set, unregistered allocation sizes are rounded up to the next bit. E.g. a request for 513 bytes will return a chunk of 1024 bytes. This might also use up large amounts of memory.

 

INTERFACE

the following is a summary of functions provided by <cprops/mempool.h>.

cp_shared_mempool *cp_shared_mempool_create();
cp_shared_mempool *
      cp_shared_mempool_create_by_option(int mode,
                                         int size_hint,
                                         int page_count);
void cp_shared_mempool_destroy(cp_shared_mempool *pool);
cp_mempool *cp_shared_mempool_register(cp_shared_mempool *pool,
                                        size_t size);
void *cp_shared_mempool_alloc(cp_shared_mempool *pool, size_t size);
void *cp_shared_mempool_calloc(cp_shared_mempool *pool, size_t size);
void cp_shared_mempool_free(cp_shared_mempool *pool, void *p);  

SEE ALSO

cp_shared_mempool_create(3), cp_shared_mempool_destroy(3), cp_shared_mempool_register(3), cp_shared_mempool_alloc(3), cp_shared_mempool_free(3), cp_mempool(3)


 

Index

NAME
DESCRIPTION
INTERFACE
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 17:58:11 GMT, September 08, 2006
SourceForge.net Logo