Hi, --
I am reading memcached source code and got a question on this function:
do_slabs_alloc_chunked, it is called by do_slabs_alloc if the request
size is larger than the slabclass size. I am curious why we don't just
move to a slabclass with larger size instead? Also, I am not sure I
understand the way it calculated the number of chunks needed:
int csize = p->size - sizeof(item_chunk);
unsigned int chunks_req = size / csize;
if (size % csize != 0)
chunks_req++;
later on, we store the first chunk in do_item_alloc as follows:
if (it->it_flags & ITEM_CHUNKED) {
item_chunk *chunk = (item_chunk *) ITEM_data(it);
chunk->next = (item_chunk *) it->h_next;
chunk->prev = 0;
chunk->head = it;
/* Need to chain back into the head's chunk */
chunk->next->prev = chunk;
chunk->size = chunk->next->size - ((char *)chunk - (char *)it);
chunk->used = 0;
assert(chunk->size > 0);
}
That means the first item has an item_chunk header next to item header,
then the csize calculation is wrong, isn't it? Say if csize equals 2, we
will actually need 3 chunks, because the first chunk will have more meta
data (item+item_chunk), am I missing something here?
thanks
yuantao
--
---
You received this message because you are subscribed to the Google Groups
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.