PHP

Recommended Flags

Large speedups were measured on PHP with profile-based optimization (a.k.a. "feedback directed optimization") which is enabled with the -xprofile compiler flag which works very well with -xipo=1. Therefore the recommended flags are:

-g -fast -xipo -xprofile=<collect|use> -zlazyload -xtarget=generic
  • The script make_fdo.pl included in the the php_files.tar archive (downloadable in the Build Scripts section below) automates the process of building and training a binary using profile feedback. Once the files are untar'ed, a single command will build a feedback directed optimized version of PHP.
  • The linker option -zlazyload delays the loading of shared objects until they are actually needed. Because PHP has dozens of dynamically linked libraries this can provide a large performance gain, especially for short calls to PHP. In web servers the performance gain from reduced startup time and less memory use (15% lower in our internal installation) can be very significant.

If you do not wish to use the build_train.pl script then compiler flags can be set by setting the environment variable CFLAGS before running configure (which takes a long time), or if configure has already been run by directly modifying the "CFLAGS_CLEAN =" line in "Makefile".

A more simple set of flags yielding a binary with decent performance is:

-g -fast -zlazyload

Compile time with these flags is just a few minutes when using parallel make (e.g. dmake/gmake -j 32) on a UltraSPARC T1-based system.

Performance vs. Compiler Optimization Level

Optimization Level PHPlens Performance
SunFreeware.com (compiled at -O2 with GCC) 48%
CFLAGS = "-O4 -g" 100%
CFLAGS = "-fast -g" 104%
CFLAGS = "-fast -xprofile -xipo -g" 114%
  • The PHPlens benchmark was adapted from the source code available for download here. The tests were modified to enable them to be run from the command line as opposed to only from a web server. This makes it possible to do performance analysis with tools such as Analyzer and Spot and also makes it easy and fast to compare performance of a single binary on multiple platforms.
  • The "GCC O2" package was downloaded from SunFreeware.com.

Configure Invocation

export CC=cc
export CXX=CC
export CFLAGS="-g -fast -xalias_level=basic -zlazyload -xtarget=generic"

./configure --prefix=<dir> --with-apxs2=<apache path>/bin/apxs --enable-fastcgi --enable-discard-path \
--enable-force-redirect --enable-libxml --with-iconv=/usr/local --with-gd --with-zlib \
--enable-ftp --with-pdflib

Build Notes

Use the latest Sun Studio C compiler for optimal performance.

Known Compile Issues

Because the PHP makefile creates libraries of object files that are later statically linked, if the -xipo flag is used then make must be done serially (i.e. do not use the -j flag for dmake/gmake) with current Studio compilers.

Build Scripts

The script make_fdo.pl included in php_files.tar will build and train PHP with feedback directed optimization by using the -xprofile and -xipo compiler flags. The training workloads are the 2,000+ test cases that are invoked by make test and also a short, simple real world benchmark called train.php (included in php_files.tar). To use the automated build script do the following steps:

  • Save php_files.tar to the PHP source code root directory (where configure was run)
  • Type tar -xvf php_files.tar
  • Type ./make_fdo.pl

Because the training workload includes the entire PHP test suite it should provide speedups on a very wide variety of applications. Sun-internal tests indicate that this feedback-optimized version speeds applications up to 10% versus a non-feedback-optimized binary, and there are no known applications that exhibit a performance regression. Build time can take over an hour, so until it is verified that PHP has been configured correctly it might be best to compile with -fast.

Source Code

Get the latest version of PHP here.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact