[Python-Dev] CPython optimization: storing reference counters outside of objects

Cesare Di Mauro cesare.di.mauro at gmail.com
Tue May 24 19:40:47 CEST 2011


2011/5/24 Stefan Behnel <stefan_ml at behnel.de>

> Maciej Fijalkowski, 24.05.2011 13:31:
>
>  CPython was not designed for CPU cache usage as far as I'm aware.
>>
>
>  That's a pretty bold statement to make on this list. Even if it wasn't
> originally "designed" for (efficient?) CPU cache usage, it's certainly been
> around for long enough to have received numerous performance tweaks in that
> regard.
>
> Stefan


Maybe a change on memory allocation granularity can help here.

Raising it to 16 and 32 bytes for 32 and 64 bits system respectively
guarantees that an access to ob_refcnt and/or ob_type will put on the cache
line some other information for the same object, which is usually required
by itself (except for very simple ones, such as PyNone, PyEllipsis, etc.).

Think about a long, a tuple, a list, a dictionary, ecc.: all of them have
some critical data after these fields, that most likely will be accessed
after INCRef or type checking.

Regards,
Cesare
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110524/957fe2ee/attachment.html>


More information about the Python-Dev mailing list