Re: [eigen] Clean aligned memory allocation |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
On Tue, Feb 2, 2016 at 2:46 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:Since this "slop" isn't measurable from our side, measuring it is not trivial. One universal way to approximate it is to look at process stats such as resident set size (RSS) or virtual set size, say in `ps`. Specific allocators may also expose functions to query actually allocated sizes; IIRC, jemalloc does.Yes, here are some numbers for different buffer sizes (first number), allocated numerous times (second number), with either 16 or 32 bytes alignment:2000 Bytes x1000 /16Bhandmade: 2625536posix: 2621440_mm_malloc: 4677632malloc: 26296322048 Bytes x1000 /16Bhandmade: 3137536posix: 2621440_mm_malloc: 4681728malloc: 26214402050 Bytes x1000 /16Bhandmade: 3137536posix: 3137536_mm_malloc: 5705728malloc: 314163216 Bytes x100000 /16Bhandmade: 3821568posix: 2195456_mm_malloc: 3833856malloc: 21954562048 Bytes x100000 /32Bhandmade: 257576960posix: 206180352_mm_malloc: 4117790722000 Bytes x100000 /32Bhandmade: 206176256posix: 206176256_mm_malloc: 411787264
_mm_malloc is definitely pretty bad, and indeed our handmade version can waste a significant amount of bytes in worst cases.Unfortunately, posix_memalign is also pretty bad regarding realloc: since there is no "posix_realloc_align", we have to do it by hand by explicitly allocating a new buffer and doing the copy whereas in many(?) cases std::realloc amounts to a nearly no-op. Ok, I'll try to come up with some numbers....gael
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |