On Sat, 4 Jul 2020, Shweta Agrawal wrote:
> > the rest is free memory, which should be measured separately.
> free memory for a class will be : (free_chunks * chunk_size)
> And total memory reserved by a class will be : (total_pages*page_size)
>
> > If you're getting evictions in class A but there's too much free memory in classes C, D, etc
> > then you have a balance issue. for example. An efficiency stat which just
> > adds up the total pages doesn't tell you what to do with it.
> I see. Got your point.Storage overhead can help in deciding the chunk_size and growth_factor. Let me add storage-overhead and free memory as well for
> calculation.
Most people don't have to worry about growth_factor very much. Especially
since the large item code was added, but it has its own caveats. Growth
factor is only typically useful if you have _very_ statically sized
objects.
> One curious question: If we have an item of 500Bytes and there is free memory only in class A(chunk_size: 100Bytes). Do cache evict items from class with
> largeer chunk_size or use multiple chunks from class A?
No, it will evict an item matching the 500 byte chunk size, and not touch
A. This is where the memory balancer comes in; it will move pages of
memory between slab classes to keep the tail age roughly the same between
classes. It does this slowly.
> Example:
> In below scenario, when we try to store item with 3MB, even when there was memory in class with smaller chunk_size, it evicts items from 512K class and
> other memory is blocked by smaller slabs.
Large (> 512KB) items are an exception. It will try to evict from the
"large item" bucket, which is 512kb. It will try to do this up to a few
times, trying to free up enough memory to make space for the large item.
So to make space for a 3MB item, if the tail item is 5MB in size or 1MB in
size, they will still be evicted. If the tail age is low compared to all
other classes, the memory balancer will eventually move more pages into
the 512K slab class.
If you tend to store a lot of very large items, it works better if the
instances are larger.
Memcached is more optimized for performance with small items. if you try
to store a small item, it will evict exactly one item to make space.
However, for very large items (1MB+), the time it takes to read the data
from the network is so large that we can afford to do extra processing.
> To unsubscribe from this group and stop receiving emails from it, send an email to
memcached+...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/memcached/5e76fa4f-7e06-468a-8b10-d99ab89d7ec2o%40googlegroups.com.
>
>