AcquireMagickMemory and multi thread

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
vladimir_ff
Posts: 18
Joined: 2011-11-18T05:12:05-07:00
Authentication code: 8675308

AcquireMagickMemory and multi thread

Post by vladimir_ff »

Hello!
I have test app with two threads. Each thread looks like:

Code: Select all

//reading image from file to buffer
while(true)
{
   Blob blob( imageData, size );
   image.ping( blob );
}
I run this app on a 24-core system and expect loading two cores at 100%.
But it doesn't happen. Each of two cores works at 80-90%.
I explored source code and found this call sequence: Image::ping->PingBlob->CloneImageInfo->AcquireImageInfo->AcquireMagickMemory
There is a special memory manager with blocking (memory_semaphore), so I can't use full power of cores.
Am I right?
Is there any way to have memory manager for each thread?
Or may be other solution?

IM 6.7.6.9
CentOs 6.3
vladimir_ff
Posts: 18
Joined: 2011-11-18T05:12:05-07:00
Authentication code: 8675308

Re: AcquireMagickMemory and multi thread

Post by vladimir_ff »

No idea? Nobody knows?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: AcquireMagickMemory and multi thread

Post by magick »

ImageMagick uses the standard memory methods, malloc(), free(), etc. You can use any memory manager you want. Just call MagickCore::SetMagickMemoryMethods() with three methods with the same signature as malloc(), realloc(), and free().
vladimir_ff
Posts: 18
Joined: 2011-11-18T05:12:05-07:00
Authentication code: 8675308

Re: AcquireMagickMemory and multi thread

Post by vladimir_ff »


"Our custom memory allocation manager implements a best-fit allocation policy using segregated free lists..."

This manager uses semaphores.
How can I make ImageMagick to use pure malloc/free without special policies and blocks?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: AcquireMagickMemory and multi thread

Post by magick »

Our custom memory allocation manager does implement a best-fit allocation policy. However, it only used if you use this configure script option: --enable-zero-configuration. Its likely you did not use this option, therefore ImageMagick is using the standard malloc(), realloc(), and free() memory methods.
Post Reply