I notice a slowdown in my server when using ImageMagick to resize some photos. Doing a htop
shows that there are several similar convert
commands (7) being executed at the same time on the same image. Is this normal for ImageMagick, or did my code somehow execute Imagemagick's convert
mulitple times on the same image?
I am using ImageMagick ImageMagick 6.7.9-6 2012-09-18
.
convert --version
Version: ImageMagick 6.7.9-6 2012-09-18 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP
Additional Info
Logging
The log shows that there are no duplicate calls to convert
to resize the same image twice.
To debug this, one needs more details.
"... several similar convert commands at the same time..." : how many is 'several' exactly?!
How many CPU (cores) does this system have?
How 'similar' exactly, what are the differences within this similarity?!
What are the parent:child relationships between these similar commands?! ( pstree
command)
How big is your typical input image?!
Please also report the full output of convert -version
.
This seems to be a web service, guessing from the input JPEG's directory that can be seen in the screenshot. *Are you sure that there are not several convert commands started by the web service for every upload? -- Are you sure that the web service isn't contacted multiple times by the web client for every image to be converted?*
Update:
If your convert -version
reports as one feature OpenMP
, then your ImageMagick is multi-threaded, enabling it to simultaneously run multiple threads to process one large image. This can increase efficiency very greatly when it comes to process large image files. (But it can slow down overall performance greatly too, if you process many small files...)
My guess is that you don't see multiple (16) concurrent processes in the htop
output, but multiple (16) concurrent execution threads .
For the typical use case of processing small files, you should try it with automatic multi-threading disabled, by setting this environment variable:
MAGICK_THREAD_LIMIT=1
You can also benchmark your ImageMagick command to get closer to the optimal number of threads to be used. Adding -bench iterations
prints the elapsed time and efficiency for one or more threads of the specific command:
convert \
-bench 40 \
/home/photos/public_html/2012/0926/some.jpg \
-resize 300 \
null:
Your ImageMagick 6.7.9 is able to apply progressive threading while benchmarking a command. (It doesn't make much sense to test with -bench
in non-OpenMP installations...)
See also this discussion in the official ImageMagick forum .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.