Page 1 of 1

Solaris 10 and ImageMagick

Posted: 2009-03-17T07:19:59-07:00
by bozac
Hello all,

I'm having some efficiency problems with ImageMagick 6.5.0 that is built as 64bit binary on Solaris 10/08.
If I build it as 32bit binary it uses 1,9s for resizing 6.5MB image from command line with convert. The resize of the same image with 64bit binary takes 2,9s. On Fedora 64 it takes 1.5s and that's the timing I was going for. It's a quad core computer.
I'm guessing the error must be in my compile and build flags.

I'm compiling it with Sun Studio 12.
flags -xO3 -xopenmp -m64.
Crashes with -fast, -xO5 doesn't seem to make any diferrence.

Any suggestions, what Am I doing wrong?

Best regards, boza.

Re: Solaris 10 and ImageMagick

Posted: 2009-03-17T09:00:34-07:00
by magick
In your case is the problem start-up time, the resize algorithm, OpenMP, or something specific to your processor, compiler, or OS? We have seen that OpenMP is more efficient on some architectures than others. Set the MAGICK_THREAD_LIMIT to 1 and 2 and see if that makes an improvement:
  • set MAGICK_THREAD_LIMIT=1
    convert myimage.png -resize 200% myimage.jpg
Now try 2. You can also disable OpenMP with the --disable-openmp option on the ImageMagick configure script command line.

To see if startup-time is a factor, try resizing several times:
  • convert myimage.png -resize 200% -resize 50% -resize 200% -resize 50% -resize 200% -resize 50% myimage.jpg
If the execution time is closer on each of your host computers it may be the startup-time is a factor otherwise the resize algorithm is the factor.

As an experiment, modify magick/resize.c and change WorkLoadFactor from 0.265 to 0.0 and then 100.0. This changes the algorithm direction from column-wise to row-wise.

You could try a different resize algorithm. Try -scale for example:
  • convert myimage.png -scale 200% myimage.jpg
If none of these options reveal why the process is slower on your Solaris host, you need to profile the execution of the algorithm to determine where most of the time is spent.

Can you post a URL to your image and the command you are using? We'll download it and runs some timing experiments on our systems.

Re: Solaris 10 and ImageMagick

Posted: 2009-03-19T04:39:44-07:00
by bozac
Thank you for such a quick replay.

We did some benchmarking on Solaris and we got to this results.

Scale is faster for 1 second, but still 0.6 - 0.7 slower than 32 bit build

WorkLoadFactor from 0.265 to 0.0 and then 100.0
0.0 - around 3 sec... slightly slower
100 - same as original

set MAGICK_THREAD_LIMIT=1/2 - no difference

when setting a wrong command line, eg. convert strehe.jpg -reize 640x480 strehe_small.jpg, it takes 1.5 sec to exit with an error? Possible slow start?

command line
(64 bit) convert strehe.jpg -resize 640x480 strehe_small.jpg (~ 2.8 sec)
(32 bit) convert strehe.jpg -scale 640x480 strehe_small.jpg (~ 1.7 sec)

Tested on (quadcore) Xeon E5420@2.50GHz and Core2Duo E7200@2.53GHz

configure line
./configure --prefix=/opt/im-CC CC=cc --disable-static --with-quantum-depth=8 --without-perl --without-magick-plus-plus CFLAGS="-xO5 -xtarget=native -m64 -xipo" CXX=CC

truss dump with timestamps suggests that reading of something (original image?) takes ~ 1.4 sec for 64bit build. The same reading takes 0.7 sec on 32 bit build.

Here is URL for the image http://static.kiberpipa.org/~daedalus/pic/strehe.jpg

Any other ideas?

thanks, boza

Re: Solaris 10 and ImageMagick

Posted: 2009-03-19T07:05:15-07:00
by magick
For comparison, on our 64-bit Redhat 5.2 4-core Xeon @ 3.00GHZ with 16GB of memory we get the expected sub-second results for your image:
  • -> identify -version
    Version: ImageMagick 6.5.0-3 2009-03-19 Q8 OpenMP http://www.imagemagick.org
    Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
    -> zsh -c 'time convert strehe.jpg -resize 640x480 strehe_small.jpg'
    convert strehe.jpg -resize 640x480 strehe_small.jpg 1.49s user 0.05s system 210% cpu 0.729 total
    -> zsh -c 'time convert strehe.jpg -scale 640x480 strehe_small.jpg'
    convert strehe.jpg -scale 640x480 strehe_small.jpg 0.65s user 0.03s system 100% cpu 0.689 total
We're not sure why you are getting a performance hit on your servers. We currently do not have access to a Solaris server to investigate further.

Re: Solaris 10 and ImageMagick

Posted: 2009-03-20T01:46:20-07:00
by bozac
I'll try to experiment with compile flags some more. I'm sure the problem is my build and as there is no binary for 64bit Solaris to test, I'll just have to figure out how to make it work. I'm not going to give up on IM yet. :)

If I get any results I'll let you now.

thanks,
Boza