#48403 [Fbk->Opn]: shell_exec() is much slower than running from shell
| From: | gregor at hostgis dot com | Date: | Wed, 27 May 2009 18:43:38 +0000 |
| Subject: | #48403 [Fbk->Opn]: shell_exec() is much slower than running from shell | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-137788@lists.php.net to get a copy of this message | ||
ID: 48403
User updated by: gregor at hostgis dot com
Reported By: gregor at hostgis dot com
-Status: Feedback
+Status: Open
Bug Type: Performance problem
Operating System: Linux
PHP Version: 5.2.9
New Comment:
Hi, Jani. Thanks for looking into this so quickly. I will reciprocate
by staying on top of this with equal eagerness; we have paying customers
who would be very keen to see this fixed. I doubt that my problem is
using only 1 decimal place, as the difference between 14 seconds and 84
seconds is not a subtle one. ;)
I find your result surprising, 0.04 seconds -- do you in fact have GDAL
installed and are you manipulating a TIFF? The slowdown is with a task
that takes some time; something like "ls" is trivial.
I would be glad to provide instructions on the installation of GDAL, as
well as our test data and some other commands exhibiting this effect. I
may be able to provide a server and root access as well.
Previous Comments:
------------------------------------------------------------------------
[2009-05-27 10:26:34] jani@php.net
Works fine for me. You should really use 2 decimals for the time. I got
0.044s without PHP, 0.04s with PHP..
------------------------------------------------------------------------
[2009-05-27 07:37:57] gregor at hostgis dot com
Description:
------------
Commands executed via shell_exec() take a lot longer to run than when
run directly from the Unix shell. In the example code below, a task that
takes 0.5-0.7 seconds takes 5 seconds.
This effect is reliable, and a given task's "how much longer it takes
than it should" ratio seems constant. In the simple case below, it takes
8-10 times longer than it should. For a specific more complex test case
at our side, the task consistently takes 14 seconds from shell and 83
seconds from shell_exec()
This effect is apparently identical for the entire family of
process-handling functions: passthru, exec, shell_exec, and popen all
show the exact same "slowness multipliers" as described above.
This report may be similar to http://bugs.php.net/bug.php?id=15746
However, this is for Linux systems and not specific to Windows NT or
NETPBM.
Reproduce code:
---------------
<?php
// gdal_translate converts GIS data
// in this case, simply copy a GeoTIFF with no transforms
$command = 'gdal_translate /tmp/in.tif /tmp/out.tif';
$t0 = microtime(true);
exec($command);
$t1 = microtime(true);
printf("%.1f seconds", $t1 - $t0);
?>
Expected result:
----------------
When run from the shell, this takes 0.5 to 0.7 seconds.
Actual result:
--------------
This takes 5.0-5.5 seconds.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48403&edit=1