Slowness in converting as of imagemagick 6.8.9-8

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.
anatolik
Posts: 5
Joined: 2014-10-17T13:55:07-07:00
Authentication code: 6789

Re: Slowness in converting as of imagemagick 6.8.9-8

Post by anatolik »

Here is build configuration reported by ./configure

Code: Select all

Host system type: x86_64-unknown-linux-gnu
Build system type: x86_64-unknown-linux-gnu

                  Option                        Value
-------------------------------------------------------------------------------
Shared libraries  --enable-shared=yes		yes
Static libraries  --enable-static=yes		yes
Module support    --with-modules=yes		yes
GNU ld            --with-gnu-ld=yes		yes
Quantum depth     --with-quantum-depth=16	16
High Dynamic Range Imagery
                  --enable-hdri=yes		yes

Install documentation:		yes

Delegate Configuration:
BZLIB             --with-bzlib=yes		yes
Autotrace         --with-autotrace=no		no
Dejavu fonts      --with-dejavu-font-dir=default	none
DJVU              --with-djvu=no		no
DPS               --with-dps=no		no
FFTW              --with-fftw=no		no
FlashPIX          --with-fpx=no		no
FontConfig        --with-fontconfig=yes		yes
FreeType          --with-freetype=yes		yes
GhostPCL          None				pcl6 (unknown)
GhostXPS          None				gxps (unknown)
Ghostscript       None				gs (9.15)
Ghostscript fonts --with-gs-font-dir=/usr/share/fonts/Type1	/usr/share/fonts/Type1/
Ghostscript lib   --with-gslib=yes		yes
Graphviz          --with-gvc=no		
JBIG              --with-jbig=no		no
JPEG v1           --with-jpeg=yes		yes
JPEG-2000         --with-jp2=		
LCMS v1           --with-lcms=no		no
LCMS v2           --with-lcms2=yes		yes
LQR               --with-lqr=yes		yes
LTDL              --with-ltdl=yes		yes
LZMA              --with-lzma=yes		yes
Magick++          --with-magick-plus-plus=yes	yes
OpenEXR           --with-openexr=yes		no
OpenJP2           --with-openjp2=yes		yes
PANGO             --with-pango=yes		yes
PERL              --with-perl=yes		/usr/bin/perl
PNG               --with-png=yes		yes
RSVG              --with-rsvg=yes		yes
TIFF              --with-tiff=yes		yes
WEBP              --with-webp=yes		yes
Windows fonts     --with-windows-font-dir=	none
WMF               --with-wmf=yes		yes
X11               --with-x=			yes
XML               --with-xml=yes		yes
ZLIB              --with-zlib=yes		yes

X11 Configuration:
      X_CFLAGS        = 
      X_PRE_LIBS      = 
      X_LIBS          = 
      X_EXTRA_LIBS    = 

Options used to compile and link:
  PREFIX          = /usr
  EXEC-PREFIX     = /usr
  VERSION         = 6.8.9
  CC              = gcc -std=gnu99 -std=gnu99
  CFLAGS          = -I/usr/include/lqr-1 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -pthread -fopenmp -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -Wall -march=x86-64 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
  CPPFLAGS        = -pthread -D_FORTIFY_SOURCE=2 -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2
  PCFLAGS         = 
  DEFS            = -DHAVE_CONFIG_H
  LDFLAGS         = -Wl,-O1,--sort-common,--as-needed,-z,relro
  LIBS            = 
  CXX             = g++
  CXXFLAGS        = -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -pthread
  FEATURES        = DPC HDRI OpenCL OpenMP Modules
  DELEGATES       = bzlib mpeg fontconfig freetype gslib jng jpeg lcms lqr lzma openjp2 pango png ps rsvg tiff webp wmf x xml zlib
anatolik
Posts: 5
Joined: 2014-10-17T13:55:07-07:00
Authentication code: 6789

Re: Slowness in converting as of imagemagick 6.8.9-8

Post by anatolik »

Here is a call graph for this function

Code: Select all

   - __memcpy_avx_unaligned
      - 37.02% ReadPixelCachePixels.part.10
         - 77.59% GetAuthenticPixelCacheNexus
              GetCacheViewAuthenticPixels
            - MorphologyPrimitive._omp_fn.0
               + 86.67% gomp_thread_start
               + 13.33% GOMP_parallel
         + 22.41% GetVirtualPixelsFromNexus
      - 34.26% GetVirtualPixelsFromNexus
         - GetCacheViewVirtualPixels
            - 89.44% MorphologyPrimitive._omp_fn.0
               + 87.50% gomp_thread_start
               + 12.50% GOMP_parallel
            - 10.56% MorphologyPrimitive._omp_fn.1
               + 82.35% gomp_thread_start
               + 17.65% GOMP_parallel
      - 28.72% WritePixelCachePixels.part.15
         - SyncAuthenticPixelCacheNexus
            - 82.22% MorphologyPrimitive._omp_fn.0
               + 86.49% gomp_thread_start
               + 13.51% GOMP_parallel
            - 17.78% HorizontalFilter._omp_fn.3
               + 83.33% gomp_thread_start
               + 16.67% GOMP_parallel
anatolik
Posts: 5
Joined: 2014-10-17T13:55:07-07:00
Authentication code: 6789

Re: Slowness in converting as of imagemagick 6.8.9-8

Post by anatolik »

One of the Arch developers (Jan Steffens) hunted down the issue and here is proposed fix for ImageMagick http://sprunge.us/YQcX
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Slowness in converting as of imagemagick 6.8.9-8

Post by magick »

Disable OpenCL, and see if that fixes the problem. Add --disable-opencl to your configure script command line. Rebuild ImageMagick and time your command. Now add --disable-opencl --disable-openmp, rebuild, and time your command. Post the times here. In some cases, either of OpenMP or OpenCL can cause slow-downs for some ImageMagick options.
anatolik
Posts: 5
Joined: 2014-10-17T13:55:07-07:00
Authentication code: 6789

Re: Slowness in converting as of imagemagick 6.8.9-8

Post by anatolik »

The problem is that canWriteProfileToFile() has sideeffect - it removes profile file and requires regeneration. The fix is to use "append" flag instead of "write". This does not truncate the file content. See the patch I posted earlier http://sprunge.us/YQcX
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Slowness in converting as of imagemagick 6.8.9-8

Post by magick »

Right, we have that patch applied already. We were curious about the run-times with and without OpenCL and OpenMP on Arch Linux.
Post Reply