3 ms·
On the subject of papers, for those who have not read them Jeff Bonwick's work on the Solaris slab allocator is well worth reading. https://www.usenix.org/lega
by gbrown_ 10y ago
On the subject of papers, for those who have not read them Jeff Bonwick's work on the Solaris slab allocator is well worth reading.
https://www.usenix.org/legacy/publications/library/proceedings/bos94/full_papers/bonwick.a https://www.usenix.org/legacy/publications/library/proceedin...
https://www.usenix.org/legacy/event/usenix01/full_papers/bonwick/bonwick_html/index.html https://www.usenix.org/legacy/event/usenix01/full_papers/bon...
Pretty much every OS kernel has adopted the techniques outlined in these papers.
- eatbitseveryday 10y agoThese ideas are also excellent. While slab allocators can be very fast and space-efficient, they are meant to be used in scenarios where you know in advance what object sizes are, as each slab cache only allocates one kind of object. The kernel is a great use case, because you know which structs will be frequently allocated/destroyed, thus create a slab cache for just that one data structure (and others for other structs). And the kernel itself does not change frequently, nor does it allocate objects of sizes imposed by user-space (like a file system or key-value store would have to). Memcached employs (-ed ?) its own allocator that is almost analogous to a slab allocator. It creates each cache not from understanding specific object sizes (since it cannot - it is a key-value store), but from a range of sizes incremented by some runtime constant. This can lead to really severe memory bloat in some instances. Memory allocators are not easy. Even "general-purpose" allocators are not truly meant for general-purpose allocation; the DSA paper mentioned above states (page 6 top left): > It has been proven that for any possible allocation algorithm, there will always be the possibility that some application program will allocate and deallocate blocks in some fashion that defeats the allocator's strategy, and forces it into severe fragmentation