Thomas (boggyb) wrote,

  • Mood:
  • Music:

Trying to make PHP go faster

Right, so last time I'd successfully installed a profiler and produced an output file. Let's take a look...

Sorting the output by "Total Self" (which is the total amount of time spent executing that particular function, not counting time in subfunctions) the biggest consumers are:

FunctionTotal SelfCalls

That lot is fully half the 4.262 seconds it took to load Craig's HomePortal dashboard, and of that 639ms is spent in classloading and 812ms in include/require functions. Oh, and the PHP files loaded by those functions don't look particularly complex (Mysmarty.php contains an if !defined('basepath'), a require, and a class definition) so I don't think it's doing much real work in that time. This does still suggest that a fair chunk of time is spent just parsing PHP code.

The next step is probably to add a PHP parser/opcode cache and see if that helps. I'm going to pick the Zend OPcache for no particular reason. Unfortunately their website has no documentation whatsoever, but fortunately the tarball does include a README with destructions. So, here goes...

Thomas@Athena:~/zendopcache-7.0.3$ phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
Thomas@Athena:~/zendopcache-7.0.3$ ./configure

Lots of tests...
checking build system type... ./config.guess: unable to guess system type

Well, I know what to do with that at least. It'd be useful if all these autoconf-users updated to something vaguely current (configure claims it was last modified in 2005!).

Thomas@Athena:~/zendopcache-7.0.3$ wget ";a=blob_plain;f=config.guess;hb=HEAD" -O config.guess
Thomas@Athena:~/zendopcache-7.0.3$ wget ";a=blob_plain;f=config.sub;hb=HEAD" -O config.sub
Thomas@Athena:~/zendopcache-7.0.3$ ./configure
Lots of pointless tests (why is it checking for a Fortran compiler anyway?)...
Thomas@Athena:~/zendopcache-7.0.3$ make

zendopcache-7.0.3/zend_accelerator_util_funcs.c: In function `zend_clone_zval':
zendopcache-7.0.3/zend_accelerator_util_funcs.c:236: error: `zend_uintptr_t' undeclared (first use in this function)

Well that didn't take long to fail. Some searching throws up this bug for a different PHP extension which exactly matches what's happening here. Which would suggest that the latest Zend OPcache hasn't actually been tested with PHP 5.2 (despite claiming to support that version). Anyway... I added typedef unsigned long zend_uintptr_t; to /usr/include/php5/Zend/zend_types.h and tried again:

zendopcache-7.0.3/Optimizer/zend_optimizer.c: In function `zend_optimizer':
zendopcache-7.0.3/Optimizer/zend_optimizer.c:310: error: `ZEND_ACC_INTERACTIVE' undeclared (first use in this function)

Unfortunately there's almost nothing online relating to this error, and a quick grep through the headers in /usr/include/php5 didn't throw it up either. My PHP-fu isn't anywhere near strong enough to start digging into the internals so I've given up at this point. I have at least raised a bug about the compiler errors, so let's see where that goes...
Tags: nas adventures

  • Computer specs

    The first part of the long-overdue computer rebuild posts! Back in May, I finally brought my desktop kicking and screaming into the current…

  • Skyward Sword HD: for SCIENCE!

    One thing I've noticed from playing through Skyward Sword HD is how... underwhelming the skyward strike appears, at least to begin with. It takes a…

  • Random quote

    pleaseremove, setting a work quiz: "No, I'm going to get my wrong answers right"

  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment