[issue18835] Add aligned memroy variants to the suite of PyMem functions/macros

2013-08-31 Thread Raymond Hettinger
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

[issue18835] Add aligned memroy variants to the suite of PyMem functions/macros

2013-08-26 Thread Antoine Pitrou
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

[issue18835] Add aligned memroy variants to the suite of PyMem functions/macros

2013-08-26 Thread STINNER Victor
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

[issue18835] Add aligned memroy variants to the suite of PyMem functions/macros

2013-08-26 Thread Antoine Pitrou
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

[issue18835] Add aligned memroy variants to the suite of PyMem functions/macros

2013-08-25 Thread Raymond Hettinger
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. -- ___

[issue18835] Add aligned memroy variants to the suite of PyMem functions/macros

2013-08-25 Thread Raymond Hettinger
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: