Performance improvements in PHP 5.4.0

One day I looked at a presentation about the upcoming PHP 5.4.0. I just stared at the slide 3 when I saw the numbers for performance and memory usage improvements. I said to myself: I have to make a test. I downloaded PHP 5.4.0alpha2, run “.configure” with mysql options and “make” and started the php cli command. And a mysql error popped up.

Today I looked at qa.php.net and a beta version was available. I ran the commands again and this time it worked. This are the results I got testing a rather complex (lots of posts and plugins) WordPress blog:

Run 5 times PHP 5.3.5 PHP 5.4.0beta1
Exec. time from 884 to 1004 ms from 641 to 777 ms
Mem. usage 26.00 MiB 14.75 MiB

For me it’s quite impressive. Script was executed in 25% less time and PHP process used 43% less memory. I can’t wait to install this on my production server, because waiting a half a second to generate a page (for my current configuration) is a little excessive.

8 Comments.

  1. Weihnachtsmann

    Wow, this is really interesting. I’ve never seen such interesting PHP tests in real environment. It would be even more interesting if you could compare this data to newer versions of PHP. Thanks 4 sharing so far!

  2. Of course i have the same feeling like you, it’s impressive 😀

    I’m waiting final version so i can use it in production server.

  3. DSmidge – what hosting do you use? How much out of that is waiting for the database?

    Thanks for the post, this is indeed impressive.

  4. I have my own server at home: AMD Phenom II, 6 cores, 2.8GHz. But if I’d make a purchase now, I would go for Intel Xeon E3-12×0. The aim is to have the fastest core possible – two cores are more than enough.

    Unfortunately, lots of hosting servers are configured the opposite way – lots of slow cores in a single CPU.

    Querying the database takes only 11 miliseconds (92 queries), because I have a big query cache and a temp space mounted on RAM drive.

  5. PHP is sooo slow, compared to everything else, that 25% mean exactly nothing 🙁

    • It’s still better then nothing. In my case it takes off a quarter of a second of the page loading time. But I agree with you – complex apps should be written in something else.

  6. Use APC cache and or varnish cache: will make your php website fly 😉

    • I doesn’t really help much with WordPress + lots of plugins. The majority of time if consumed for executing scripts and not compiling php code to binaries (these binaries are then be stored by APC for subsequent calls).