ID: 48403 User updated by: gregor at hostgis dot com Reported By: gregor at hostgis dot com Status: Bogus Bug Type: Performance problem Operating System: Linux PHP Version: 5.2.9 New Comment:
> [email protected] > Any exec() function implies fork() > This may explain the time it takes I'm not sure I follow you. When I watch the 'top' and 'ps axu' output, the shp2img or gdal_translate task is running the whole time. It is not spending 68 seconds forking and then running the job in 14 seconds. This same program from CLI, does not exhibit this slow execution. If fork() is being slow, surely it would affect the CLI version? And if I run the shp2img command from a four-line Bourne shell CGI script, it runs in 14 seconds -- that seems to eliminate Apache and fork() as likely culprits. What I find bizarre, is that the shp2img process has exactly the same 'top' and 'ps axu' output in both cases: 59 MB RSS, 115 MB VSZ, 9.8 MB shared memory, 99-100% CPU. Overall system CPU usage hovers at 40%, with only flickers of "wait" -- this too is identical regardless of how shp2img is started. > [email protected] > It could also be a memory issue. > If you are running up against the per-process memory-limit > then the code may run much slower as it has to > try to do the same image operations in less memory. I have memory_limit set to 256 MB Since shp2img for this case uses 60 MB, this should be plenty. Still, I have upped it to 1024 MB (we have a lot of RAM to play with) and this had no effect. I will run some profiling/timing stuff from within shp2img, since its debug output includes tmestamps, and get back to you with those. Previous Comments: ------------------------------------------------------------------------ [2009-05-27 21:22:11] [email protected] It could also be a memory issue. The fork overhead would be a constant on all shell execs. However, manipulating a large image is a memory-intensive operation. If you are running up against the per-process memory-limit then the code may run much slower as it has to try to do the same image operations in less memory. But again, I don't see how this could be called a PHP issue. Check your per-process limits and see if increasing them makes a difference. ------------------------------------------------------------------------ [2009-05-27 21:18:48] [email protected] Any exec() function implies fork(). This means the apache process (and potentially all its threads) have to be forked before the exec(). This may explain the time it takes (and this is why apache2 as a separate daemon to spawn CGI processes). ------------------------------------------------------------------------ [2009-05-27 21:07:57] gregor at hostgis dot com > This proves it's not bug: > run from shell - 14 seconds > PHP on CLI - 14 seconds I disagree. It means that the bug is evident only when running under the webserver, which introduces a few more variables. > And since you're using 3rd party extensions (Zend Optimizer) > -> bogus. Please contact Zend for support. I have disabled Zend Optimizer. It had no effect on the times at all: 13-15 for CLI, 80-85 for the same command being run in a ten-line PHP program. ------------------------------------------------------------------------ [2009-05-27 20:02:43] [email protected] This proves it's not bug: run from shell - 14 seconds PHP on CLI - 14 seconds And since you're using 3rd party extensions (Zend Optimizer) -> bogus. Please contact Zend for support. ------------------------------------------------------------------------ [2009-05-27 19:43:53] gregor at hostgis dot com > Perhaps you can provide me the same image to test with The file is available for a short time at this URL: http://www.cartograph.com/images.tmp/2043.tif.gz It's a 3 GB TIFF, but gzipped for faster download. > Apart from different file, I did exactly same as you. I find the result of 0.04 seconds fishy, though. I assume that you have GDAL installed when you run the test? > You didn't specify whether you run that test under > some webserver or using PHP CLI? Here's where we get into how I narrowed it down to being something about PHP and Apache. run from shell - 14 seconds PHP on CLI - 14 seconds PHP as Apache DSO - 84 seconds Perl CGI - 14 seconds I would have to set up a dedicated test server in order to test other scenarios, such as disabling Zend Optimizer or running PHP as CGI. On our production server, those are not an option. Note that the 14/84 test is for a shp2img using this same TIFF and a mapfile -- the gdal_translate was <1 second to 4 seconds. I will be glad to provide those as needed, if the gdal_translate test fails to replicate our results on your environment. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/48403 -- Edit this bug report at http://bugs.php.net/?id=48403&edit=1
