CPU usage is too high

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
mlin@pelmorex.com

CPU usage is too high

Post by mlin@pelmorex.com »

Hi

I have developed a program in C++ to smooth a png image and cut it into small pieces. We have run this program on IM v6.2.xxx and the CPU
usage is reasonably (on a 8 core computer, it took about 20-30%). After I upgraded IM to v6.6.4-10, The CPU usage goes to ~100%
(100% for all 8 cores). I read the previous discussion on similar topics:

viewtopic.php?f=1&t=14307&hilit=cpu

http://thomasschweitzer.com/2009/08/13/ ... -problems/

I had tried:
1: disable openmp
After disable openmp, my process only uses one cpu instead all 8 CPUs, the time consumed is much longer.
that is not what I want.
2: use nice -n 19
Although my process priority is lowered, the CPU consumption is the same as before
3: compile the IM to Q8:
The CPU usage lowers to ~95% (Q16 is 100%)

my current IM version is:
Version: ImageMagick 6.6.4-10 2010-10-14 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

Any suggestion on how to resolve this issue?
thanks
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: CPU usage is too high

Post by magick »

Trade off CPU for I/O with the MAGICK_AREA_LIMIT environment variable (set it to 0). You can also throttle the CPU with the MAGICK_THROTTLE environment variable. The MAGICK_THROTTLE resource periodically yields the CPU for at least the time specified in milliseconds. Both these options increase the elapsed time for your task.
mlin@pelmorex.com

Re: CPU usage is too high

Post by mlin@pelmorex.com »

magick wrote:Trade off CPU for I/O with the MAGICK_AREA_LIMIT environment variable (set it to 0). You can also throttle the CPU with the MAGICK_THROTTLE environment variable. The MAGICK_THROTTLE resource periodically yields the CPU for at least the time specified in milliseconds. Both these options increase the elapsed time for your task.
Thanks. Tried the suggestions.
Is there a version of IM that is faster which the elapsed time for my task will not increase?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: CPU usage is too high

Post by magick »

ImaegMagick 6.6.4-10 is as fast as it gets but you seem to want to slow it down by throttling the CPU. To comment further we would need to reproduce the problem. Post a URL to a sample image and the command you use to process it. Also post the elapsed time it takes on your host. We'll run it here and look for opportunities for a speed-up.
Post Reply