[Sheepdog] [PATCH 3/5] sheep: add a slab allocator

Christoph Hellwig hch at infradead.org
Tue Nov 15 09:04:09 CET 2011


On Tue, Nov 15, 2011 at 11:16:44AM +0800, Liu Yuan wrote:
> From: Liu Yuan <tailai.ly at taobao.com>
> 
> This allocator is on top of malloc/free pair and it is just faster for
> object storage, because it preallocate space and the allocation/deallocation
> just need some simple pointer calcalations. The chunk size for object is from
> 16 bytes to 128k bytes. No technical limit to chunk size, they are just macros.
> 
> Usage:
> 	id = slabs_clsid(object size); # this will preallocate a slab sized by object size.
> 	object_ptr = slabs_alloc(id);
> 	slabs_free(object_ptr, id);
> 
> This code is based on the slabs.c in project Memcached.

Do you have any benchmarks to prove benefits?  I recently looked into
using some sort of a slab allocator for xfs_repair, but in the end just
using an efficient threading allocator (tcmalloc) proved to be a) much
faster and b) use less memory.




More information about the sheepdog mailing list