PHP Performance |
|
2024-11-24 |
|
|
14 |
|
|
Let's have a look at the callgraphs. First Apache-PHP-APC.
And now HipHop-PHP.
If you are reading this on the Web, right click and open each image in a new tab or download them
and look at them locally.
Look for the big-ticket items on each graph.
PHP
- • zif_preg_replace 28.63%
- • ap_pass_brigade 27.45%
- • zend_print_variable 13.10%
- • zif_strototime 6.49%
- • zif_date 4.32%
- • php_request_startup 4.13%
HipHop PHP
- • HPHP::i_clickable 25.82%
- • HPHP::TimeZone::Current 19.66%
- • HPHP::Transport::sendRaw 16.44%
- • HPHP::Variant::o_invoke_few_args 8.61%
- • HPHP::f_twit_nav 4.7%
One item stands out here. HPHP::TimeZone::Current probably gets the current timezone. That's known to
be pretty slow which is why in PHP we define that in our php.ini file, but HipHop PHP doesn't read the
php.ini file. Let's try hardcoding a default timezone into our app.
<?php
date_default_timezone_set("America/Los_Angeles");
Benchmark
~> siege -b -t30s -c5 http://twit2.localhost
** SIEGE 2.68
** Preparing 5 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 12066 hits
Availability: 100.00 %
Elapsed time: 29.54 secs
Data transferred: 37.79 MB
Response time: 0.01 secs
Transaction rate: 408.46 trans/sec
Throughput: 1.28 MB/sec
Concurrency: 4.98
Successful transactions: 12066
Failed transactions: 0
Longest transaction: 0.05
Shortest transaction: 0.00
Ok, the world makes sense again. HipHop PHP is a bit faster than Apache-PHP-APC for this case. It was never going
to be a big boost since this app spends most of its time in pcre making links clickable and fetching stuff from MySQL.
There are no heavy userspace abstraction layers that HipHop can sink its teeth into here.