> I am the author of Alchemy Database > http://code.google.com/p/alchemydatabase/ > > I am putting in a change that is adding 8 bytes to my btree-node's > size, changing them from the jemalloc friendly sizes of 1K,2K,4K to > 1036bytes, 2056bytes, 4104bytes ... really irritating, but I need to > add 8 bytes, no getting around it. > > So I need a slab allocator for these exact sizes, there are more than > 3, about 12. > > I was thinking of repurposing slabs.c to allocate the exact slab sizes > I need by hardcoding the values I need in the function slabs_init(). > > It looks pretty easy to do and it has been alluded to already > http://code.google.com/p/memcached/wiki/MemcachedSlabAllocator > "the slab allocator could become truly general purpose, perhaps > another day." > > Has anyone repurposed slabs.c like this, are there any gotchas, is it > a good idea
Don't know of anyone offhand... The code related to the slabber isn't too complex, so you'd get an idea from a read-through. slabs.c just defines what sizes memory is, what to hand out where, etc. Managing it outside of that (hash table, lru, etc) is up to your application. It still has a weakness of not being able to reassign memory if you put it all into one slab class pool. -Dormando
