From: Cristy Date: Tue, 4 Apr 2017 11:51:41 +0000 (-0400) Subject: Align small memory allocations on the cache line X-Git-Tag: 7.0.5-5~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0a2d73c8d3717f4c414907807b81dc3f3f8c0b0;p=imagemagick Align small memory allocations on the cache line --- diff --git a/MagickCore/memory.c b/MagickCore/memory.c index 318f7274f..985ab26a3 100644 --- a/MagickCore/memory.c +++ b/MagickCore/memory.c @@ -220,7 +220,7 @@ static MagickBooleanType %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AcquireAlignedMemory() returns a pointer to a block of memory at least size -% bytes whose address is aligned on a page boundary. +% bytes whose address is aligned on a cache line or page boundary. % % The format of the AcquireAlignedMemory method is: % @@ -249,8 +249,10 @@ MagickExport void *AcquireAlignedMemory(const size_t count,const size_t quantum) if (HeapOverflowSanityCheck(count,quantum) != MagickFalse) return((void *) NULL); memory=NULL; - alignment=GetMagickPageSize(); size=count*quantum; + alignment=CACHE_LINE_SIZE; + if (size > (GetMagickPageSize() >> 1)) + alignment=GetMagickPageSize(); extent=AlignedExtent(size,CACHE_LINE_SIZE); if ((size == 0) || (extent < size)) return((void *) NULL);