Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Slab Profile Support

thinkingfish edited this page · 3 revisions

The exponentially growing slab classes work well for generic workload. In some cases, however, you may want to tune them to host objects of specific sizes only, and these sizes may not perfectly line up with an exponential growth model.

Twemcache supports a customized way of specifying slab classes via a new command line option: “-z <size1,…,sizeN>“. What it does is instead of deciding a series of chunk sizes by minimum/maximum chunk size and growth factor, it generates slab classes according to the sizes passed in via command line option. This makes slab profile a good way to trade flexibility for increased memory efficiency.

Here is an example:

$ src/twemcache -z 128,512,1024,20480
[Thu Jul 12 21:29:15 2012] mc.c:1185 twemcache-2.4.0 started on pid 9373 with 4 worker threads
[Thu Jul 12 21:29:15 2012] mc.c:1192 configured with debug logs disabled, asserts disabled, panic disabled, stats enabled, klog enabled
[Thu Jul 12 21:29:15 2012] mc_slabs.c:74 slab size 1048576, slab hdr size 32, item hdr size 54, item chunk size 128, total memory 67108864
[Thu Jul 12 21:29:15 2012] mc_slabs.c:81 class   1: items    8191  size     128  data      74  slack      96
[Thu Jul 12 21:29:15 2012] mc_slabs.c:81 class   2: items    2047  size     512  data     458  slack     480
[Thu Jul 12 21:29:15 2012] mc_slabs.c:81 class   3: items    1023  size    1024  data     970  slack     992
[Thu Jul 12 21:29:15 2012] mc_slabs.c:81 class   4: items      51  size   20480  data   20426  slack    4064
Something went wrong with that request. Please try again.