[issue18835] Add PyMem_AlignedAlloc()

STINNER Victor report at bugs.python.org
Thu Nov 2 07:37:03 EDT 2017


STINNER Victor <victor.stinner at gmail.com> added the comment:

"C11 aligned_alloc() / free() would be more comfortable but isn't available on MSVC."

Is it common to require the allocated memory block to be filled with zeros? In Python, calloc() is not the most common allocator. I only found 5 places where calloc is used:

Modules/_ssl.c:5172:        _ssl_locks = PyMem_Calloc(_ssl_locks_count,
Modules/gcmodule.c:1689:        g = (PyGC_Head *)PyObject_Calloc(1, size);
Modules/gcmodule.c:1717:_PyObject_GC_Calloc(size_t basicsize)
Objects/bytesobject.c:83:        op = (PyBytesObject *)PyObject_Calloc(1, PyBytesObject_SIZE + size);
Objects/listobject.c:176:        op->ob_item = (PyObject **) PyMem_Calloc(size, sizeof(PyObject *));


"posix_memalign() performance isn't that great. hand-rolled aligned_calloc() is the fastest."

I'm not sure that the cost of the memory allocator itself defeats the gain of aligned memory on algorithms. I expect data processing to be much more expensive than the memory allocation, no?

Again, the unknown remains the benchmark result.

Can anyone write a quick benchmark to measure the gain of aligned memory? 4 years ago, Raymond Hettinger wanted to use it for the set and collection.deque types.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue18835>
_______________________________________


More information about the Python-bugs-list mailing list