[Python-Dev] Activating pymalloc
Martin v. Loewis
martin@v.loewis.de
16 Mar 2002 10:30:50 +0100
Tim Peters <tim.one@comcast.net> writes:
> [martin@v.loewis.de]
> > I also wonder whether it might be sensible to space the size classes
> > 16 bytes apart, thus reducing the number of classes to 16.
>
> I don't think so. What's the upside? Reducing the size of usedpools?
Reducing the overhead memory allocated from the system. With 64 pools,
and each pool having 4k, on average, the allocator will waste 128k.
You are probably right that the wasted pad bytes will outnumber any
"static" overhead.
If you have a size class of 256 bytes, you will waste 224 bytes at the
end of each page, since 32 bytes of pool_header go into the beginning
of each page, and the last 224 bytes won't satisfy a 256 byte request.
So on a 4k page, the size class 256 currently wastes, on average, 224
+ 15 * 4 = 284 bytes (assuming that the average object wastes 4 bytes),
or 7%. So it may be worthwhile to increase the pool size.
Regards,
Martin