Page 1 of 1

CPU usage is too high

Posted: 2010-10-14T08:47:57-07:00
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

Re: CPU usage is too high

Posted: 2010-10-14T08:58:02-07:00
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.

Re: CPU usage is too high

Posted: 2010-10-14T10:15:18-07:00
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?

Re: CPU usage is too high

Posted: 2010-10-14T10:36:06-07:00
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.