Page 1 of 1

High CPU load when converting images

Posted: 2017-03-10T09:56:37-07:00
by PPROBill
We are using version 6.7.2-7 of ImageMagick and are experiencing HIGH CPU loads very randomly. Happening about once per day over the course of a few thousand convert operations happening.

Version: ImageMagick 6.7.2-7 2016-06-16 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP

The article in the link (http://www.daniloaz.com/en/high-cpu-loa ... agemagick/) describes our exact problem but since it was posted several years ago I would have thought this bug may have been addressed by now. Is this still an issue with version 6.7 ? Is the solution of limiting ImageMagic to a single core the best approach to resolve?




[Notes from Linked Article]
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The way to force ImageMagick to use a single processor or core when performing an image conversion is using the environment variable MAGICK_THREAD_LIMIT. This variable should be set to 1 and be available in the runtime environment of the convert command. So edit the /etc/environment file and add the line MAGICK_THREAD_LIMIT=1 as shown below:

# cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
LANG="es_ES.UTF-8"
LANGUAGE="es_ES.UTF-8"
MAGICK_THREAD_LIMIT=1

Then open a new command shell, since the current one will not load such environment variable until we log into the system again.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Any current experience by others with High CPU loads using version 6.7 ?

Thanks,
Bill

Re: High CPU load when converting images

Posted: 2017-03-10T10:18:28-07:00
by snibgo
v6.7.2-7 is very old. I suggest you consider an upgrade. Old versions of IM don't get bug-fixes.

But any version of IM can cause a high CPU load. Is that a problem? IM usually runs as fast as it can, using whatever CPU is available. For some tasks, most of the time is spent on disk I/O so average CPU utilisation is low. But some tasks are CPU intensive, so those will have high CPU load.

A high CPU load doesn't, of itself, indicate a bug.

Limiting the number of threads on a multi-processor system will also limit the CPU load.

Re: High CPU load when converting images

Posted: 2017-03-10T12:36:43-07:00
by magick
You can also throttle the CPU with a "throttle" security policy.

Re: High CPU load when converting images

Posted: 2017-11-27T13:21:54-07:00
by ricardo.pesciotta
Hi @PPROBill,

I'm having the same issue.
I deploy my app which uses javscript to access imagemagick on a container, and the version is also old: 6.7.7.10-6ubuntu3.9
Locally it processes very fast, and I'm on a multi core machine.
But on the container, the same image takes about 4 minutes of 100% CPU to complete.

I'm going to try to set the env var to force IM to use a single thread, but not sure this will solve the problem.
In my case, I have no chance of updating the IM version, so I'm reaching out to check if by any chance by now you've got it to work.

Looking forward to your feedback!