RFC: Slab-o-rama (after Rene's suggestion)

"Hugo Santos" <[email protected]> Mon, 23 Apr 2007 07:56:24 +0100
Newsgroups gmane.os.openbeos.kernel.devel
Message-ID <[email protected]>
Hi all,

  After a couple discussions with and suggestions by Travis, i ended
up writing a very simple allocator for some net_buffer stuff. I wrote
Saturday and thus never managed to commit it since berlios has been
down. However, after poking around with it a bit, i moved myself to
implement a slab allocator, originally to be used by the network
stack, but which i think could have a wider area of usage. I've mostly
followed Jeff Bonwick's papers, both his original 94 paper which
introduces the slab allocator as well as his latest 2001 paper which
expands the concept to introduce "magazines" and SMP scalability.

  During the weekend i wrote an initial version and would like now to
gather up your comments. Some will probably not like the style of the
implementation which is heavily template based. The main reason of
this approach was to let the compiler generate direct calls and
provide for more inlining paths and thus improve the performance as
indirect calls can be bad on the branch predictors. Still within the
context of the code style, there are a couple points which i would to
address myself as the status quo doesn't quite satisfy me either (for
instance, the handling of strategy_storage). Please ignore the code
style. :-)

  The code is available at: http://fivebits.net/~hugo/haiku/

  Anyway, this implementation covers most of the Slab and new SMP
extensions (magazines) bits. There is still stuff to do, including
dynamic tuning and reacting to memory pressure (this requires VM
support so i didn't approach it yet).

  The code is pretty generic so it may be used by applications as well
(in fact the only backend i've included is a memalign/malloc based
one). I personally see an interface like this as a candidate to
libroot, both the C interface which is rather simple and the whole C++
interface which allows for more complex usage.

  Let me know of your comments. Most of the code is in Slab.h as my
original idea was to have a lot of this being inlined. A couple
examples (still very very simple, just for test) may be found in
Slab.cpp.

  Hugo

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/