Raymond Hettinger added the comment:
> Adding yet another API to allocate memory has a cost
Please don't FUD this one to death. Aligned memory access is sometimes
important and we currently have no straight-forward way to achieve it. If
you're truly worried about adding single new function t
Antoine Pitrou added the comment:
> What is the alignment of a cacheline? Can a line starts at any
> address?
If it could, Raymond wouldn't be asking for this feature ;-)
Cachelines are typically aligned at whatever their size is. So,
a 64-byte cacheline will be aligned at a 64 bytes boundary.
P
STINNER Victor added the comment:
The default allocator for PyObject is PyType_GenericAlloc(). If the type has
the Py_TPFLAGS_HAVE_GC flag, PyType_GenericAlloc() calls _PyObject_GC_Malloc().
It is the case for the set type. _PyObject_GC_Malloc() adds an header of
sizeof(PyGC_Head) (12 bytes on
Antoine Pitrou added the comment:
Unless the memory allocator actually supports it, this means you lose a whole
lot of memory for padding, though... Memory which will sit there unused at the
end of another cacheline.
Note that the current small object allocator, if not disabled, *should* alrea
Raymond Hettinger added the comment:
I should also mention posix_memalign() for Unix/Linux systems.
On systems without a clean way to provide aligned memory, we can always fall
back to regular malloc(). The API wouldn't guarantee alignment but would
comply when possible.
--
___
New submission from Raymond Hettinger:
Currently, we have little to no control over the alignment of memory returned
by the PyMem functions.
I suggest variants such as PyMem_Alloc32(n) and PyMem_Alloc64(n) to return
suitably aligned data blocks.
GNU C provides memalign() for this purpose: