php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58633 5.3 + imagick = Abnormal CPU Spike
Submitted: 2009-04-15 16:23 UTC Modified: 2009-05-01 18:33 UTC
From: xing at mac dot com Assigned:
Status: Closed Package: imagick (PECL)
PHP Version: 5_3 CVS-2009-04-15 (dev) OS: Centos 5.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: xing at mac dot com
New email:
PHP Version: OS:

 

 [2009-04-15 16:23 UTC] xing at mac dot com
Description:
------------
Tested this with latest ImageMagick install and both 2.2.2 and 2.3.0beta with same result.

When paired with 5.3DEV04-15-2009 snapshot, the following very simple image resizing script would require an usually high amount of CPU processing time. On a quad core xeon system, the script wold cause 300% cpu usage.

This is not the case with 5.2.X where cpu usage is normal, in the single digitis, and the script runs very fast, as expected.

I ran this no other extension active except for imagick to finally isolate the problem to this.

Reproduce code:
---------------
size = 25;


$pic_data = file_get_contents("../static/images/default.png");        

or

$pic_data = blob from db;



$im = thumbnail::resize_blob($pic_data, $size, $size);
$output = $im->getimageblob();
$outputtype = $im->getFormat();
--------------------------------

thumbnail class

----------------

<?
class thumbnail {
	
	static public function resize_blob($blob, $i_width, $i_height) {
		$image = new Imagick();
		
		$image->readimageblob($blob);
		
		$image->cropThumbnailImage($i_width, $i_height);
	
		return $image;	
	}
}
?>




Expected result:
----------------
Very fast scaling of a 150x150png image/blob to 25x25png.

Actual result:
--------------
Extremely slow result with extremely high CPU spike. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-15 19:07 UTC] xing at mac dot com
The problem is also occurring with 5.2.9 with imagick 2.2.2. Going to recompile imagick and downgrade the ImageMagick to an older version to see if its related to the lib and perhaps not the extension afterall.
 [2009-04-16 01:18 UTC] xing at mac dot com
Sorry to have wasted your time but I have finally drilled down the problem and its not PHP or ImageMagick or this extension. 

Turns out the latest updates, around 300 or so RPM packages pushed down to the Centos 5.2 general population contained some new offending library that ImageMagick doesn't like. 

I could not reproduce this problem until I had an identical slave machine where it runs perfect, stop web processes, perform the massive yum update, then restart the web process (still on the old kernel so no physical), and bug appears where the image processing script starts chewing up 300%+ cpu usage. 

Sigh. I don't know where to do on this one. Expect to recommend people not to update their CentOS machines until more come out of this. I don't have enough background or skills to track this problem down. I'm sure over the next 2-3 weeks when the new RPMs gets slowly adopted, more light will come out of this.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 02:01:28 2024 UTC