Lychee icon indicating copy to clipboard operation
Lychee copied to clipboard

With imagick extension enabled, pic upload and rotate performance degrades badly

Open 73blazer opened this issue 6 years ago • 4 comments

Detailed description of the problem [REQUIRED]

Imagemagick enabled installation, picture upload and rotate performance goes way up. 58s to upload one 8mb photo, 23s to rotate it within the lychee application.

Steps to reproduce the issue

Steps to reproduce the behavior:

  1. Install lychee w/imagick php extension enabled 2.Upload a photo - time how long it takes
  2. rotate the photo - time how long it takes

Output of the diagnostics [REQUIRED]

Diagnostics
-------
Warning: Using 32 bit PHP, recommended upgrade to 64 bit
Error: PHP zip extension not activated
Warning: Dropbox import not working. dropbox_key is empty.




System Information
--------------
Lychee Version (release):        4.0.8
DB Version:                      4.0.8

composer install:                --no-dev
APP_ENV:                         production
APP_DEBUG:                       false

System:                          AIX
PHP Version:                     7.4
Max uploaded file size:          500M
Max post size:                   500M
SQLite Version:                  3.32.3

Imagick:                         1
Imagick Active:                  1
Imagick Version:                 1802
GD Version:                      bundled (2.1.0 compatible)




Config Information
--------------
version:                         040008
check_for_updates:               0
sorting_Photos_col:              takestamp
sorting_Photos_order:            ASC
sorting_Albums_col:              max_takestamp
sorting_Albums_order:            ASC
imagick:                         1
skip_duplicates:                 0
small_max_width:                 0
small_max_height:                360
medium_max_width:                1920
medium_max_height:               1080
lang:                            en
layout:                          1
image_overlay:                   1
image_overlay_type:              desc
default_license:                 none
compression_quality:             90
full_photo:                      1
delete_imported:                 0
Mod_Frame:                       1
Mod_Frame_refresh:               30
thumb_2x:                        1
small_2x:                        1
medium_2x:                       1
landing_page_enable:             0
landing_owner:                   Snyderworld.org
landing_title:                   Snyderworld.org
landing_subtitle:                Everything
landing_facebook:                https://www.facebooksucks.com
landing_flickr:                  https://www.flickrsucks.com
landing_twitter:                 https://www.twittersucks.com
landing_instagram:               https://instagramsucks
landing_youtube:                 https://www.googleisevil.com
landing_background:              dist/cat.jpg
site_title:                      Lychee v4
site_copyright_enable:           1
site_copyright_begin:            1994
site_copyright_end:              2020
additional_footer_text:          
display_social_in_gallery:       0
public_search:                   0
SL_enable:                       0
SL_for_admin:                    0
public_recent:                   0
recent_age:                      1
public_starred:                  0
downloadable:                    0
photos_wraparound:               1
map_display:                     0
zip64:                           1
map_display_public:              0
map_provider:                    Wikimedia
force_32bit_ids:                 0
map_include_subalbums:           0
update_check_every_days:         3
has_exiftool:                    0
share_button_visible:            0
import_via_symlink:              0
has_ffmpeg:                      1
location_decoding:               0
location_decoding_timeout:       30
location_show:                   1
location_show_public:            0
rss_enable:                      0
rss_recent_days:                 7
rss_max_items:                   100
prefer_available_xmp_metadata:   0
editor_enabled:                  1
lossless_optimization:           0
swipe_tolerance_x:               150
swipe_tolerance_y:               250
local_takestamp_video_formats:   .avi|.mov
log_max_num_line:                1000
unlock_password_photos_with_url_param: 0

About

Browser and system

Client is Win 10 w/Firefox 83.0 Server is AIX 7.2

Imagick extension:
imagick

imagick module => enabled
imagick module version => 3.4.4
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
Imagick compiled with ImageMagick version => ImageMagick 7.0.10-44 Q16 powerpc 2020-11-26 https://imagemagick.org
Imagick using ImageMagick library version => ImageMagick 7.0.10-44 Q16 powerpc 2020-11-26 https://imagemagick.org
ImageMagick copyright => © 1999-2020 ImageMagick Studio LLC
ImageMagick release date => 2020-11-26
ImageMagick number of supported formats:  => 247
ImageMagick supported formats => 3FR, 3G2, 3GP, A, AAI, AI, APNG, ART, ARW, ASHLAR, AVI, AVS, B, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, C, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUBE, CUR, CUT, DATA, DCM, DCR, DCRAW, DCX, DDS, DFONT, DNG, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, FAX, FILE, FITS, FL32, FLV, FRACTAL, FTP, FTS, G, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, HALD, HDR, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, JBG, JBIG, JNG, JNX, JPE, JPEG, JPG, JPS, JSON, K, K25, KDC, LABEL, M, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, O, ORA, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PS, PS2, PS3, PSB, PSD, PTIF, PWP, R, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGB565, RGBA, RGBO, RGF, RLA, RLE, RMF, RW2, SCR, SCREENSHOT, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TM2, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBM, WMV, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, Y, YCbCr, YCbCrA, YUV

Directive => Local Value => Master Value
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.skip_version_check => 0 => 0

===========================

I'm not saying this is a bug, but probably something related to this setup? If I disable imagick so it uses GD, it's 6-8s per photo upload and rotate produces an error (Whoops, something went wrong in red bar across the top with nothing in the log) If I make my own test.php to use some basic imagick functions from the imagick extension, rotate, scale, crop etc .. and other basic functions are quite fast, nearly instant <1s. I also use a couple imagick functions in another php app I wrote , albeit just very basic scale and rotate there but they work with no delay.

Any idea what's tanking the performance on the imagick functions within my lychee install or how to further debug this to figure out where /what function is taking the time?

THis is not an upgrade , i'm new to lychee, this is all a fresh install on 4.0.8 only.

73blazer avatar Nov 27 '20 20:11 73blazer

No worries, it is not something has been added recentrly as there has been no change in Lychee with respect to using imagick since version 3.

That being said, it is a very surprising behavior. While not being directly related this in interesting: https://github.com/ImageMagick/ImageMagick/issues/1007

ildyria avatar Nov 28 '20 14:11 ildyria

It doesn't seem to be picture related, I did 900 pics from a directory last night from various cameras and sources and sizes and while it does 6 at a time (can I increase that?!) each batch of 6 takes 58s. Somethings hanging it up. Interestingly videos upload instantly, with the ffmpeg activated as well.

I'm not convinced it's the imagick extension as I can use those in other php and it's very fast at least the basic functions. I can use imagemagick convert on the command line and it's very fast. The server is 24 power7 cpu with 512gb of ram w/half free and ssd's. It's not the server. It's something else in the stream of gd vs. imagick is my guess. What's the debug method in this application, is there a way to watch it progressing, can I add some out stmts in a few places around the imagick processing that will show me which call is taking the time?

73blazer avatar Nov 28 '20 15:11 73blazer

Well.... I think it is my imagick. I found one function that seems to not perform, Imagick::resizeImage takes 19s and pegs 4 cores during that time. Indeed convert resize from command line also takes same basic amount. hmm. Imagick::scaleImage is <1s. . Well, we can't have that. I looked for the Imagick commands being used in this application and it appears it's using ORIENTATION if I test that in standalone php, yup, 19s per operation. Yikes. I see lychee is using Imagick::profileImage as well and that also takes 19s. So some of my imagick functions are fast and other functions very slow. I will see if I can find some options in my imagemagick compile that will perhaps improve that. I compiled that one myself with the native AIX/IBM compiler xlC, which sometimes doesn't play well with open source software.

73blazer avatar Nov 28 '20 16:11 73blazer

yup, that was it. Problem solved. recompiled imagemagick with gcc and ... everything's fast now.. Can't say I've run into that issue before where some commands are speedy and others are dirt slow.

New pic upload is 2-3s, rotate is 1s.

73blazer avatar Nov 28 '20 19:11 73blazer