Announcement

#1 2020-07-09 06:09:31

gnurob
Member
2016-10-29
20

CPU Utilization On Image Resize / First Load

How's it going,

I've seen some older threads about high CPU utilization, and certain hosting providers complaining about i.php and potentially banning Piwigo users. This may be related to an ImageMagick bug when OpenMP is compiled in (run convert -version to check your system). On my system this runs the Apache2 process over 100% and triggers a flurry of system monitoring warnings: each and every time a page is loaded with an image for the first time.

There is a great article explaining the problem here: https://www.daniloaz.com/en/high-cpu-lo … agemagick/

Unfortunately what works on the command line doesn't necessarily translate into PHP. This is as far as I managed to solve this problem, figured I'd plant a seed here.

Cheers


Piwigo version: 2.10.2
PHP version: 7.3.11-1
MariaDB version: 10.3.18
Piwigo URL: http://

Offline

 

#2 2020-07-09 06:32:51

gnurob
Member
2016-10-29
20

Re: CPU Utilization On Image Resize / First Load

Changing $conf['graphics_library'] = 'auto' (defaults to 'imagick') to 'ext_imagick' reveals convert running high on the CPU. Just one 25 MP JPG results in 10-15% for approximately 20 seconds on an idle rack server. It would seem the external command is throttled, but it does prolong the process.

$conf['graphics_library'] = 'gd' avoids the problem altogether.

For anyone that may know the PHP code behind using ImageMagick:

imagick::RESOURCETYPE_THREAD (integer)

Set maximum parallel threads. This constant is available if Imagick has been compiled against ImageMagick version 6.7.8 or higher.

Imagick::setResourceLimit ( int $type , int $limit ) : bool

Offline

 

#3 2020-07-09 06:35:14

executive
Member
2017-08-16
1214

Re: CPU Utilization On Image Resize / First Load

That article talks about version 6.5.7 which is 10 years old. Surely this isn't still a problem in 7.0.10?

Offline

 

#4 2020-08-02 04:16:21

gnurob
Member
2016-10-29
20

Re: CPU Utilization On Image Resize / First Load

Well, I am converting 60 megapixel JPEG images, and possibly uncovering a bug that fast CPUs have been obscuring, however I did find this bug applied to Debian 9--10 years down to 3 years.

In any case, I made the second post here to benefit anyone that may be struggling with slow image processing so that they may be aware of alternatives.

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact