> On memcached version 1.4.5-1ubuntu1, there are two entries for the ‘-
> I’ parameter in the memcached(1) man page.
>
> -I     Override the size of each slab page in bytes.  In mundane
> words, it adjusts the maximum item size that memcached will accept.
> You can use the suffixes K and M to  specify  the size as well, so use
> 2000000 or 2000K or 2M if you want a maximum size of 2 MB per object.
> It is not recommended to raise this limit above 1MB due just to
> performance reasons.  The default value is 1 MB.

I have no idea who wrote this. It's not in the original source tree.

> -I <size>  Override the default size of each slab page. Default is
> 1mb. Default is 1m, minimum is 1k, max is 128m. Adjusting this value
> changes  the  item  size  limit.  Beware that this also increases the
> number of slabs (use -v to view), and the overal memory usage of
> memcached.
>
> It seems to me that the first entry is misleading.  The parameter does
> not "adjust the maximum item size;" rather, the parameter adjusts the
> slab page size, and the number of items stored in each slab page.
> These two entries should be combined into one entry.

No, that second part is a side effect, and doesn't affect performance. It
primarily increases the maximum item size, by way of increasing the max
page size.

> The second entry could be further clarified by saying that reducing
> the page size below the 1 megabyte default page size will result in an
> increased number of slabs.

Uhhh. Can you post the output of `memcached -vvv` with your -I
adjustments? If you reduce the max page size it most certainly reduces the
number of slabs. It will increase the number of slab *pages* available.
Which doesn't affect anything.

> By the way, '-I 10M' does not work.  Neither does '-I 10m'.  I
> discovered that you have to specify the byte size, i.e., '-I
> 10485760'.

Can you try building from source via http://memcached.org/ (you don't have
to do a make install, just ./memcached blah blah)? That most certainly
WFM, and given the above magic manpage entry I'm assuming some overzealous
package maintainer broke this. In fact there're tests in the test tree
which verify that syntax works...

> Please correct my understanding, if I am missing something.

I tried, did I help?

> Also, I do not understand the warning, "It is not recommended to raise
> this limit above 1MB due just to performance reasons."  What exactly
> are the performance issues?
>
> If my default chunk size is 480 bytes and if I am storing items in 416
> byte chunks and 448 byte chunks, then, I can store more chunks in 10
> megabytes pages than I can in 10 kilobyte pages.  So, why wouldn't I
> opt to store my chunks in 10 megabyte pages (rather than 10 kilobyte
> pages or even 1 megabyte pages)?  The vast majority of my chunks are
> 448 byte chunks.  So, it seems to me that I can use my memory more
> efficiently by opting for 10 megabyte slab pages.  What, if anything,
> is behind the "peformance" warning?

IF ANYTHING. So ominous.

Using a non-brokeassed build of memcached, start it with the following
examples:

memcached -vvv -I 128k
memcached -vvv -I 512k
memcached -vvv -I 1M
memcached -vvv -I 5M
memcached -vvv -I 10M
memcached -vvv -I 20M

You'll see that the slab sizes get further apart. You're missunderstanding
what everything is inside the slabber.

- slab page is set (1M by default)
- slab classes are created by starting at a minimum, multiplying by a
number (1.2 by default?) and repeating until the slab class size is equal
to the page size (1M by default)
- when you want to store an item:
  - finds slab class (item size 416 bytes would go into class 8, so long
as the key isn't too long)
  - try to find memory in class 8. No memory? Pull in one *page* (1M)
  - divide that page into chunks of size 480 bytes (from class 8)
  - hand back one page chunk for the item
  - repeat
- memory between your actual item size, and the slab chunk size, is wasted
overhead
- the further apart slab classes are, the more memory you waste (perf
issue #1)

If you give memcached a memory limit of 60 megs, and a max item size of
10 megs, it only has enough pages to give one page to 6 slab classes.
Others will starve (tho it's actually a little more complicated than
that, but that's the idea).

-Dormando

Reply via email to