The change was made to reduce the average amount of space wasted on
items that don't exactly match the chunk sizes. With the powers-of-2
scheme, if your item eats 1 byte more than will fit in a chunk, you
will end up with (just over) 50% memory efficiency for that item,
wasting nearly half the space because the item will only fit in a
chunk that's nearly twice as big as needed. With a power of less than
2, you still waste some space, but less of it, and you can fit more
items in a given amount of cache memory.
The value of 1.25 was chosen as a reasonable default value for most
applications; it's tunable on the command line in recognition of the
fact that different factors might be closer to optimal for different
data sets.
At some point someone will probably come up with a memory allocator
that does more efficient packing of objects, but the slab allocator
has the advantage of being lightning-fast and immune to traditional
memory fragmentation. Its memory efficiency is not great but it
remains more or less constant no matter how many items are created and
destroyed, rather than degrading over time.
-Steve
On Nov 11, 2007, at 7:38 PM, dtohuy326 wrote:
Hello all,
I have a question about chunk size factor.That is
when memcached version changed from v1.1.13 to v1.2.0,
the chunk size factor change form '2' to '1.25'.Why to
do this change?Is factor '1.25' a experienced
suitalbe valuse? or 1.25^n is more easy to calculate?
or have some other reason?It confused me a long time.
Expect you for the answer.
--
best regard
dtohuy
_____________________________________________________________________________________
馬上體驗全新Yahoo!奇摩電子信箱2.0。
http://tw.mg0.mail.yahoo.com/dc/landing