[view source]
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.
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);
This document was created by
man2html,
using the manual pages. Time: 17:58:11 GMT, September 08, 2006 |