From:             [EMAIL PROTECTED]
Operating system: Windows 2000 Server
PHP version:      4.1.1
PHP Bug Type:     Performance problem
Bug description:  Process exec() is slow from webserver - running from shell is ok ...

Summary:

Running a PHP script which calls exec() from withing Apache runs terribly
slow or times out.  Running same from the command prompt returns in
seconds.

Details:
I (and other NT users) have run into performance issues running PHP 4.1.1
with the NETPBM distribution.    When running thumbnailing operations via.
webpages, the performance (throughtput) of the system is dismal.

Running the same PHP script manually from the command shell completes
operations in under a second which usually timeout when executed from a
webpage.

A full "ready to run" repro of this problem is available via. a small ZIP
file at http://www.green-bean.com/bugfiles/slowrepro.zip.   This contains
the required NETPBM files.   If these are already installed on your
system, you can run the script below with slight modifications.

Thanks,
Nigel.
----
Repro:

<?
// Full repro kit including executables available from
http://www.green-bean.com/bugfiles/slowrepro.zip
//

// Location of your NETPBM distribution
// We're using
http://prdownloads.sourceforge.net/gallery/netpbm1.1-gallery1.0-win32.tgz
// 
$pbmroot = "netpbm";

// JPG input file (from http://www.green-bean.com/DallasChristmasHat.jpg)
$file = "DallasChristmasHat.jpg";


function fs_exec($cmd, &$results, &$status, &$time) {
    // We can't redirect stderr with Windows.  Hope that we won't need
to.
    $time_st = time();
    $x = exec("$cmd", $results, $status);
    $time = time() - $time_st;
}

$quiet = "-quiet";

// JPEG to PNM
$cmd_to_pnm    = "$pbmroot\\jpegtopnm $quiet $file > out\\$file.pnm";

print "<br>Exec: $cmd_to_pnm\n";
fs_exec($cmd_to_pnm, $results, $status, $elapsed);
print "<br>Elapsed: $elapsed secs\n<br>Status: $status";

// PNM to scaled PNM
$cmd_scale_pnm = "$pbmroot\\pnmscale  $quiet -xysize 150 150
out\\$file.pnm > out\\$file.scale.pnm";

print "<br>Exec: $cmd_scale_pnm\n";
fs_exec($cmd_scale_pnm, $results, $status, $elapsed);
print "<br>Elapsed: $elapsed secs\n<br>Status: $status";

// PNM scaled to JPG
$cmd_to_jpg    = "$pbmroot\\ppmtojpeg $quiet out\\$file.scale.pnm
--quality=150 > out\\tn_$file";

print "<br>Exec: $cmd_to_jpg\n";
fs_exec($cmd_to_jpg, $results, $status, $elapsed);
print "<br>Elapsed: $elapsed secs\n<br>Status: $status";

?>
-- 
Edit bug report at http://bugs.php.net/?id=15746&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=15746&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=15746&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=15746&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=15746&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=15746&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=15746&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=15746&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=15746&r=submittedtwice

Reply via email to