my imagemagick 's efficiency

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
rhinos
Posts: 4
Joined: 2011-08-13T20:05:39-07:00
Authentication code: 8675308

my imagemagick 's efficiency

Post by rhinos »

I have a question in the efficiency of imagemagick between the system precomiled rpm package and the version established from source code . Same system , rhel 5, x86_64. can anyone help me ?

My file size
4.0K ./107.gif


SERVER A, the Imagemagick version: ImagImageMagick-6.2.8.0-4.rpm

Code: Select all

[root@SERVERA]# time convert 107.gif -resize 100 100.gif

real    0m0.676s
user    0m0.667s
sys     0m0.009s

SERVER B , the Imagemagick version ImageMagick-6.7.1-0.tar.gz .

Code: Select all

[root@SERVERB]# time convert 107.gif -resize 100 100.gif

real    0m2.724s
user    0m12.075s
sys     0m1.294s

Then ,i replaced the SERVERB 's imagemagick with ImageMagick-6.2.8.0-4.el5_1.1.rpm

Code: Select all

[root@SERVERB]# time convert 107.gif -resize 100 100.gif

real    0m0.981s
user    0m0.968s
sys     0m0.014s
My compile option
./configure && make && make install

On SERVERB, i reinstall the imagicmagic under the /opt dir(./configure --prefix=/opt --with-quantum-depth=16 --disable-dependency-tracking --with-x=yes --without-perl ), when i strace the convert,
i got

Code: Select all

30217 execve("/opt/bin/convert", ["/opt/bin/convert", "107.gif", "-resize", "101", "2e.gif"], [/* 23 vars */]) = 0
30217 brk(0)                            = 0x7ba000
30217 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b7c527ec000
30217 uname({sys="Linux", node="smscp", ...}) = 0
30217 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
30217 open("/opt/lib/tls/x86_64/libMagick.so.10", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 stat("/opt/lib/tls/x86_64", 0x7fff582ba060) = -1 ENOENT (No such file or directory)
30217 open("/opt/lib/tls/libMagick.so.10", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 stat("/opt/lib/tls", 0x7fff582ba060) = -1 ENOENT (No such file or directory)
30217 open("/opt/lib/x86_64/libMagick.so.10", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 stat("/opt/lib/x86_64", 0x7fff582ba060) = -1 ENOENT (No such file or directory)
30217 open("/opt/lib/libMagick.so.10", O_RDONLY) = 3
30217 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\252\1\0\0\0\0\0"..., 832) = 832
30217 fstat(3, {st_mode=S_IFREG|0755, st_size=3223353, ...}) = 0
30217 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b7c527ed000
30217 mmap(NULL, 3235720, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b7c527ee000
30217 mprotect(0x2b7c528fa000, 2097152, PROT_NONE) = 0
30217 mmap(0x2b7c52afa000, 40960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10c000) = 0x2b7c52afa000
30217 close(3)                          = 0
30217 open("/opt/lib/libWand.so.10", O_RDONLY) = 3
30217 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360?\1\0\0\0\0\0"..., 832) = 832
30217 fstat(3, {st_mode=S_IFREG|0755, st_size=1358187, ...}) = 0
30217 mmap(NULL, 2706392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b7c52b04000
30217 mprotect(0x2b7c52b96000, 2097152, PROT_NONE) = 0
30217 mmap(0x2b7c52d96000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x92000) = 0x2b7c52d96000
30217 close(3)                          = 0
30217 open("/opt/lib/libjpeg.so.62", O_RDONLY) = -1 ENOENT (No such file or directory)
ON SERVERA,the rpm version ,
starce result,i got

Code: Select all

18373 execve("/usr/bin/convert", ["convert", "107.gif", "-resize", "101", "2.gif"], [/* 21 vars */]) = 0
18373 brk(0)                            = 0x610d000
18373 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2af3abaa4000
18373 uname({sys="Linux", node="smscp", ...}) = 0
18373 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
18373 open("/etc/ld.so.cache", O_RDONLY) = 3
18373 fstat(3, {st_mode=S_IFREG|0644, st_size=74331, ...}) = 0
18373 mmap(NULL, 74331, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2af3abaa5000
18373 close(3)                          = 0
18373 open("/usr/lib64/libMagick.so.10", O_RDONLY) = 3
18373 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\225\302\2144\0\0\0"..., 832) = 832
18373 fstat(3, {st_mode=S_IFREG|0755, st_size=1791992, ...}) = 0
18373 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2af3abab8000
18373 mmap(0x348cc00000, 3985032, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x348cc00000
18373 mprotect(0x348cd69000, 2093056, PROT_NONE) = 0
18373 mmap(0x348cf68000, 315392, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x168000) = 0x348cf68000
18373 mmap(0x348cfb5000, 97928, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x348cfb5000
18373 close(3)                          = 0
18373 open("/usr/lib64/libWand.so.10", O_RDONLY) = 3
18373 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`@\201\2144\0\0\0"..., 832) = 832
18373 fstat(3, {st_mode=S_IFREG|0755, st_size=699672, ...}) = 0
18373 mmap(0x348c800000, 2792088, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x348c800000
18373 mprotect(0x348c8a7000, 2097152, PROT_NONE) = 0
18373 mmap(0x348caa7000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa7000) = 0x348caa7000
18373 close(3)                          = 0
18373 open("/usr/lib64/liblcms.so.1", O_RDONLY) = 3
18373 read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0q\300\2131\0\0\0"..., 832) = 832

there are lots of open system call 'open' in source install version, and the first search location doesn't exist. is it the cause?

Code: Select all

[root@SERVERB]   sed '/open/!d' e1.out 
30217 open("/opt/lib/tls/x86_64/libMagick.so.10", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/opt/lib/tls/libMagick.so.10", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/opt/lib/x86_64/libMagick.so.10", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/opt/lib/libMagick.so.10", O_RDONLY) = 3
30217 open("/opt/lib/libWand.so.10", O_RDONLY) = 3
30217 open("/opt/lib/libjpeg.so.62", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/etc/ld.so.cache", O_RDONLY) = 3
30217 open("/usr/lib64/libjpeg.so.62", O_RDONLY) = 3
30217 open("/opt/lib/libz.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/usr/lib64/libz.so.1", O_RDONLY) = 3
30217 open("/opt/lib/libpthread.so.0", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/lib64/libpthread.so.0", O_RDONLY) = 3
30217 open("/opt/lib/libfreetype.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/usr/lib64/libfreetype.so.6", O_RDONLY) = 3
30217 open("/opt/lib/libdl.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/lib64/libdl.so.2", O_RDONLY) = 3
30217 open("/opt/lib/libm.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/lib64/libm.so.6", O_RDONLY) = 3
30217 open("/opt/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/lib64/libc.so.6", O_RDONLY) = 3
30217 open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
30217 open("/proc/meminfo", O_RDONLY)   = 3
30217 open("/opt/lib/ImageMagick-6.2.8/config/coder.xml", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/opt/share/ImageMagick-6.2.8/config/coder.xml", O_RDONLY) = 3
30217 open("/opt/share/doc/ImageMagick-6.2.8/coder.xml", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/opt/share/ImageMagick-6.2.8/coder.xml", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/home/wangzhiqian/.magick/coder.xml", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("coder.xml", O_RDONLY)       = -1 ENOENT (No such file or directory)
30217 open("/opt/lib/ImageMagick-6.2.8/modules-Q16/coders/gif.la", O_RDONLY) = 3
30217 open("/opt/lib/gif.a", O_RDONLY)  = -1 ENOENT (No such file or directory)
30217 open("/etc/ld.so.cache", O_RDONLY) = 3
30217 open("/lib64/tls/x86_64/gif.a", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/lib64/tls/gif.a", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/lib64/x86_64/gif.a", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/lib64/gif.a", O_RDONLY)    = -1 ENOENT (No such file or directory)
30217 open("/usr/lib64/tls/x86_64/gif.a", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/usr/lib64/tls/gif.a", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/usr/lib64/x86_64/gif.a", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/usr/lib64/gif.a", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/usr/share/locale/locale.alias", O_RDONLY) = 3
30217 open("/usr/share/locale/zh_CN.GBK/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/usr/share/locale/zh_CN.gbk/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/usr/share/locale/zh_CN/LC_MESSAGES/libc.mo", O_RDONLY) = 3
30217 open("/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3
30217 open("/usr/lib64/gconv/GBGBK.so", O_RDONLY) = 3
30217 open("/usr/lib64/gconv/GBK.so", O_RDONLY) = 3
30217 open("/opt/lib/ImageMagick-6.2.8/modules-Q16/coders/gif.so", O_RDONLY) = 3
30217 open("/usr/share/locale/zh.GBK/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/usr/share/locale/zh/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("107.gif", O_RDONLY)         = 3
30217 open("/opt/lib/ImageMagick-6.2.8/config/magic.xml", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/opt/share/ImageMagick-6.2.8/config/magic.xml", O_RDONLY) = 3
30217 open("/opt/share/doc/ImageMagick-6.2.8/magic.xml", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/opt/share/ImageMagick-6.2.8/magic.xml", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("/home/wangzhiqian/.magick/magic.xml", O_RDONLY) = -1 ENOENT (No such file or directory)
30217 open("magic.xml", O_RDONLY)       = -1 ENOENT (No such file or directory)
30217 open("107.gif", O_RDONLY)         = 3
30217 open("2e.gif", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3


thx,
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: my imagemagick 's efficiency

Post by glennrp »

You didn't mention whether both were Q16 builds. I think they both are, but
"convert | head -2" will tell for sure.
rhinos
Posts: 4
Joined: 2011-08-13T20:05:39-07:00
Authentication code: 8675308

Re: my imagemagick 's efficiency

Post by rhinos »

glennrp wrote:You didn't mention whether both were Q16 builds. I think they both are, but
"convert | head -2" will tell for sure.
thx glennrp for your reply. yes, they both were Q16 builds, , why the differences. what should i do about the Imagemagick performance,

Code: Select all

Version: ImageMagick 6.7.1-0 2011-08-14 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP 

Code: Select all

Version: ImageMagick 6.2.8 03/31/08 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html
Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLC 
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: my imagemagick 's efficiency

Post by magick »

Most likely the slow-down is an improved color reduction algorithm. To test, save the image as PNG for both 6.2.8 and 6.7.1 and measure the execution time. What are the dimensions of your input image? We're getting these times on our Fedora system:
  • sh-4.2$ time ImageMagick-6.2.8/utilities/convert logo: -resize 100 logo.png

    real 0m0.038s
    user 0m0.025s
    sys 0m0.012s

    sh-4.2$ time ImageMagick-6.7.1/convert logo: -resize 100 logo.png

    real 0m0.024s
    user 0m0.061s
    sys 0m0.005s
rhinos
Posts: 4
Joined: 2011-08-13T20:05:39-07:00
Authentication code: 8675308

Re: my imagemagick 's efficiency

Post by rhinos »

magick wrote:Most likely the slow-down is an improved color reduction algorithm. To test, save the image as PNG for both 6.2.8 and 6.7.1 and measure the execution time. What are the dimensions of your input image? We're getting these times on our Fedora system:
  • sh-4.2$ time ImageMagick-6.2.8/utilities/convert logo: -resize 100 logo.png

    real 0m0.038s
    user 0m0.025s
    sys 0m0.012s

    sh-4.2$ time ImageMagick-6.7.1/convert logo: -resize 100 logo.png

    real 0m0.024s
    user 0m0.061s
    sys 0m0.005s
thx magick.!!

1 the dimensions of the input image as follows
  • Image name - 107.gif
    Image: 107.gif
    Format: GIF (CompuServe graphics interchange format)
    Class: PseudoClass
    Geometry: 20x20
    Type: PaletteMatte
    Endianess: Undefined
    Colorspace: RGB
    Channel depth:
    Red: 8-bits
    Green: 8-bits
    Blue: 8-bits
    Alpha: 1-bits

    Image size - 2.8kb
    Image resolution - 72x72
    Image compression - LZW
2 and on my system,got this
  • convert
    [root@ImageMagick-6.2.8]# time convert logo: -resize 100 logo.png

    real 0m0.097s
    user 0m0.082s
    sys 0m0.015s
    [root@ImageMagick-6.7.1]# time ./convert logo: -resize 100 logo.png

    real 0m0.089s
    user 0m0.823s
    sys 0m0.011s
3. 107.png
meta data:
  • Image name - 107.png
    Format: PNG (Portable Network Graphics)
    Class: DirectClass
    Geometry: 20x20
    Type: PaletteMatte
    Endianess: Undefined
    Colorspace: RGB
    Channel depth:
    Red: 8-bits
    Green: 8-bits
    Blue: 8-bits
    Alpha: 1-bits
    Image size - 7.5e+02
    Image resolution - 72x72
    Image compression - Zip
i execute the time command
  • [root@ImageMagick-6.2.8]# time convert 107.png -resize 101 2.png

    real 0m0.096s
    user 0m0.092s
    sys 0m0.005s
    [root@ImageMagick-6.7.1]# time ./convert 107.png -resize 101 2.png

    real 0m0.063s
    user 0m0.760s
    sys 0m0.008s
magic, i don't know why the 6.7.1 which from src builded cost much more user time, thx again, looking forward to your reply!
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: my imagemagick 's efficiency

Post by glennrp »

Try timing conversion to null:

time convert 107.gif -resize 100 null:

This tells you whether the problem exists in the encoder or
somewhere else.
rhinos
Posts: 4
Joined: 2011-08-13T20:05:39-07:00
Authentication code: 8675308

Re: my imagemagick 's efficiency

Post by rhinos »

glennrp wrote:Try timing conversion to null:

time convert 107.gif -resize 100 null:

This tells you whether the problem exists in the encoder or
somewhere else.
  • [root@SERVERB]# time convert 107.gif -resize 100 null:

    real 0m0.065s
    user 0m0.058s
    sys 0m0.007s
    [root@SERVERB]# time ./convert 107.gif -resize 100 null:

    real 0m0.053s
    user 0m0.533s
    sys 0m0.030s
The problem is not encoder. Use /usr/bin/time, i got follows,why so many cpu context switches in my src building version:
  • [root@SERVERB]/usr/bin/time -v convert 107.gif -resize 100 100.gif
    Command being timed: "convert 107.gif -resize 100 100.gif"
    User time (seconds): 1.00
    System time (seconds): 0.01
    Percent of CPU this job got: 99%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:01.01
    Average shared text size (kbytes): 0
    Average unshared data size (kbytes): 0
    Average stack size (kbytes): 0
    Average total size (kbytes): 0
    Maximum resident set size (kbytes): 0
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 0
    Minor (reclaiming a frame) page faults: 2354
    Voluntary context switches: 1
    Involuntary context switches: 8

    Swaps: 0
    File system inputs: 0
    File system outputs: 0
    Socket messages sent: 0
    Socket messages received: 0
    Signals delivered: 0
    Page size (bytes): 4096
    Exit status: 0
    [root@SERVERB]# /usr/bin/time -v ./convert 107.gif -resize 100 100.gif
    Command being timed: "./convert 107.gif -resize 100 100.gif"
    User time (seconds): 27.82
    System time (seconds): 1.05
    Percent of CPU this job got: 944%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:03.05
    Average shared text size (kbytes): 0
    Average unshared data size (kbytes): 0
    Average stack size (kbytes): 0
    Average total size (kbytes): 0
    Maximum resident set size (kbytes): 0
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 0
    Minor (reclaiming a frame) page faults: 329584
    Voluntary context switches: 936
    Involuntary context switches: 779

    Swaps: 0
    File system inputs: 0
    File system outputs: 0
    Socket messages sent: 0
    Socket messages received: 0
    Signals delivered: 0
    Page size (bytes): 4096
    Exit status: 0
thx.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: my imagemagick 's efficiency

Post by glennrp »

There have been some recent changes in the quantization function that might affect
this. Does IM-6.7.1-8 or later still show the performance bug?
Post Reply