Performance drop after upgrade from 6.6.1 to 6.6.6

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
axelrose
Posts: 96
Joined: 2008-12-16T06:01:27-07:00

Performance drop after upgrade from 6.6.1 to 6.6.6

Post by axelrose »

Hello all,

I got used to this little benchmark

Code: Select all

convert logo: -resize 1000% -bench 5 /tmp/logo.png
When using

Code: Select all

Version: ImageMagick 6.6.1-10 2011-01-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP OpenCL 
I get this result:

Code: Select all

Performance: 5i 0.118568ips 37.030u 0:42.170
After upgrading and using

Code: Select all

Version: ImageMagick 6.6.6-10 2011-01-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP OpenCL
it runs much slower

Code: Select all

Performance: 5i 0.00441158ips 991.000u 18.889666664602039248:53.380
The reported time is a bit unreadable. It takes more than 8 minutes ...
All versions were compiled by myself under MacOS X 10.6.5 with identical libraries.

Perhaps there is still something strange with the PNG enocder (??)
Regards, Axel.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by fmw42 »

the PNG encoder is being worked on extensively for quite a few releases now. see the changelog at http://www.imagemagick.org/script/changelog.php. Try the latest version 6.6.6.10 or the beta of 6.6.7.0
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by anthony »

In the mean time try forceing the coder using png32: or png24: for the image output
EG:

Code: Select all

   convert .....  png32:image.png
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
axelrose
Posts: 96
Joined: 2008-12-16T06:01:27-07:00

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by axelrose »

Using png24 or png32 doesn't help. It is still awfully slow:

Code: Select all

> ImageMagick-6.6.6-10/bin/convert logo: -resize 1000% -bench 5 tif:/tmp/logo.png
Performance: 5i 0.427716ips 16.320u 0.19483333428867430359:11.690
> ImageMagick-6.6.6-10/bin/convert logo: -resize 1000% -bench 5 png24:/tmp/logo.png
Performance: 5i 0.00508182ips 959.850u 16.398333330950816134:23.900
That's 11 seconds for TIFF and 34 minutes for PNG24.
(note that the number formatting of -bench is not ideal)
Regards, Axel.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by fmw42 »

you could replace -resize with -scale for faster results, but he quality will not be as good when enlarging.

I hope this is a typo in your command

tif:/tmp/logo.png

you will get a tif image with a png suffix -- not a good idea
axelrose
Posts: 96
Joined: 2008-12-16T06:01:27-07:00

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by axelrose »

I hope this is a typo in your command
No. I didn't care about the actual file or the actual operation.
My point is that generating large PNGs is awfully slow compared to other image formats.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by fmw42 »

try again now in IM 6.6.7.0 and see if any improvement. there has been a lot of changes to improve PNG features, but I don't know what the timing expense is for that.
axelrose
Posts: 96
Joined: 2008-12-16T06:01:27-07:00

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by axelrose »

I used 6.6.7 from svn.
It still takes ages to create a large PNG with my benchmark.

Regards, Axel.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by anthony »

Presumably the new PNG coder is doing something that takes a lot of time.

Have you tried specifying the specific internal PNG format using either
png32:filaename.png

or using the new PNG coder -define settings.
Look at the header of the coder/png.c source file for the latest defines.

I think the developer is currently working more on getting it 'right' rather than getting is 'fast'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
axelrose
Posts: 96
Joined: 2008-12-16T06:01:27-07:00

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by axelrose »

time ImageMagick-6.6.7/bin/convert logo: -resize 1000% png32:/tmp/logo.png

needs more than 3 minutes

time ImageMagick-6.6.1-10/bin/convert logo: -resize 1000% png32:/tmp/logo.png

runs in less than 10 seconds (same results for "png24" or "png")

both IM versions are linked against libpng 1.4.4

otool -L ImageMagick-6.6.1-10/bin/convert | grep png
ImageMagick-6.6.1-10/lib/libpng14.14.dylib (compatibility version 19.0.0, current version 19.0.0)
otool -L ImageMagick-6.6.7/bin/convert | grep png
ImageMagick-6.6.7/lib/libpng14.14.dylib (compatibility version 19.0.0, current version 19.0.0)

6.6.7 is from svn

I looked into "coders/png.c" but couldn't spot the mentioned #ifdef.
What define would make a difference?

Thanks, Axel.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by anthony »

I took a look.
Previously there were comments on command line option -define settings tha could be used to control PNG coder. these seem to have disappeared.


NOTE I was referring to documentation in the source NOT compile time #ifdef's
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
axelrose
Posts: 96
Joined: 2008-12-16T06:01:27-07:00

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by axelrose »

Just as a reminder and another viewpoint

convert logo: -resize 1000% tmp.tif

takes 2 seconds

convert logo: -resize 1000% tmp.png

takes 2 minutes with 6.6.7-2 on my machine.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by glennrp »

Working on this. Anthony, the comments are around line 9210.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by glennrp »

The culprit seems to be the call to GetNumberColors(() in the BUILD_PALETTE section.
Testing now to see if I can safely remove the call.
axelrose
Posts: 96
Joined: 2008-12-16T06:01:27-07:00

Re: Performance drop after upgrade from 6.6.1 to 6.6.6

Post by axelrose »

Wonderful.

Thanks for correcting this. PNG conversion are back to normal speed in my tests.


Thanks, Axel.
Post Reply