My last post was about the 32-bit integer issue i was having with PHP. And besides setting up a 64-bit server one of the solutions is to compile PHP with the CFLAGS mentioned in my previous post.
Intrigued by the fact that my 32-bit Ubuntu installation did not suffer from the same issue. I started to read the PHP5 changelog for Ubuntu.
CFLAGS=”-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64″ ./configure
But this has a negative side effect. Namely PHP running 50% slower then it should be. And to my surprise Ubuntu applies the CFLAGS above when compiling PHP5 for a 32-bit platform. So that would mean PHP on Ubuntu is always running 50% slower? Well according to this is should be the case.
I downloaded php-5.3.8 from php.net and compiled two versions. One with the CFLAGS set for large files. And one normal without any changes. After that i downloaded the benchmark script from php-benchmark-script.com. And did a couple of runs on each of the two installs. The results are stunning.
PHP-5.3.8 compiled with large file support:
- test_math : 4.414 sec.
- test_stringmanipulation : 4.968 sec.
- test_loops : 3.529 sec.
- test_ifelse : 2.344 sec.
- Total time: : 15.255 sec.
PHP-5.3.8 compiled without large file support:
- test_math : 2.274 sec.
- test_stringmanipulation : 2.286 sec.
- test_loops : 1.619 sec.
- test_ifelse : 1.228 sec.
- Total time: : 7.407 sec.
That’s pretty much a 50% speed decrease. One more thing i tried is adding the ‘AC_SYS_LARGEFILE’ macro to configure.in and rebuild the configure script. But this had no effect at all.
- $ cd php-5.3.8
- $ vi configure.in (add AC_SYS_LARGEFILE somewhere)
- $ export PHP_AUTOCONF=/usr/share/autoconf2.59
- $ ./buildconf –force
I then tried two things. First i build without the CFLAGS. But this didn’t seem to do much. Then i used the same configure script with the CFLAGS for large file support. But there was no speed increase measurable.
So why would Ubuntu have made the choice to compile PHP with the large file support on a 32-bit platform? Are there really that much developers that work on large files in web / cli applications written in PHP? Enough to sacrifice a 50% speed decrease?
I don’t really know the answer to that. But i will do my large file processing on 64-bit machines. And will compile PHP from scratch from now on. Until i have upgraded my aging hardware.