High CPU load when converting images

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Posts: 1
Joined: 2017-03-10T09:45:13-07:00
Authentication code: 1151

High CPU load when converting images

Post 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

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 ?

Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: High CPU load when converting images

Post 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.
snibgo's IM pages: im.snibgo.com
User avatar
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: High CPU load when converting images

Post by magick »

You can also throttle the CPU with a "throttle" security policy.
Posts: 1
Joined: 2017-11-27T13:17:02-07:00
Authentication code: 1152

Re: High CPU load when converting images

Post 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:
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!
Post Reply