HipHopVM 2.2.0: slower, but more compatible

We wrote before about HipHopVM, Facebook’s high-performance PHP runtime, that can be found on Github. It is a production-ready virtual machine that delivers superior performance for PHP scripts. Recently version 2.2.0 was released and it now supports many frameworks. This is a big improvement. First we compare it with the previous version and see how it performs. We tested again on Ubuntu 12.04 (the latest LTS release).

hhvm220_graph

This graph shows the average execution time (of 10 runs) on PHP 5.3.10 (with APC), HipHopVM v2.1.0 and HipHopVM v2.2.0. The Y-axis shows the amount of seconds the execution took (on average) and the numbers on the X-axis represent the following benchmark scripts:

  1. bench1.php: http://www.lornajane.net/posts/2012/proof-that-php-5-4-is-twice-as-fast-as-php-5-3
  2. bench2.php: https://coderwall.com/p/il1tog
  3. bench3.php: http://php.net/manual/en/features.gc.performance-considerations.php
  4. bench4.php: http://akrabat.com/php/php-5-3-is-quicker-than-php-5-2-2/
  5. bench5.php: http://onlinephpfunctions.com/benchmarks
  6. bench6.php: http://www.synet.sk/php/en/220-php-performance-benchmark

This is the raw data:

hhvm220_data

Rewriting under HipHopVM

Symfony on Apache web server requires “mod_rewrite”. If you are running Symfony on HipHopVM you are probably looking for a “mod_rewrite” alternative. Fortunately HHVM has this feature built-in. This is how you configure the VirtualHost in the hhvm.hdf file to achieve rewriting:

VirtualHost {
    * {
        Pattern = .*
        RewriteRules {
            * {
                 pattern = ^(.*)$
                 to = index.php$1
                 qsa = true
            }
        }
    }
}

Conclusion

HipHopVM is getting more and more compatible. Still it does not run all frameworks, but is seems it is getting there. It may look like it is getting slower as it is getting more compatible. When you look at benchmark 5 & 6 you can see that it still has a good performance and that is has hardly become slower. The results from benchmark 1 are a bit worrying, but since that is just a simple object instantiation, I would not value that too much.

What do you think about these numbers? Did you get different results? Please share your thoughts in the comments below.

Share

Benchmarking HipHopVM against PHP 5.3 on Ubuntu 12.04

HipHopVM is Facebook’s high-performance PHP runtime, that is built to be a production-ready virtual machine that delivers superior performance. Facebook was using a PHP-to-C++ compiler (HPHPc), but is now moving to HipHopVM (HHVM) to unify their production and development environments.

HipHopVM Performance

PHP 5.3.10 is the current version of PHP on Ubuntu 12.04 (the latest LTS release). On Ubuntu 12.04 HipHopVM has binary packages available (v2.1.0).

hhvm_speed

This graph shows the average execution time (of 10 runs) on both PHP 5.3.10 (with APC) and HipHopVM v2.1.0. The Y-axis shows the amount of seconds the execution took (on average) and the numbers on the X-axis represent the following benchmark scripts:

  1. bench1.php: http://www.lornajane.net/posts/2012/proof-that-php-5-4-is-twice-as-fast-as-php-5-3
  2. bench2.php: https://coderwall.com/p/il1tog
  3. bench3.php: http://php.net/manual/en/features.gc.performance-considerations.php
  4. bench4.php: http://akrabat.com/php/php-5-3-is-quicker-than-php-5-2-2/
  5. bench5.php: http://onlinephpfunctions.com/benchmarks
  6. bench6.php: http://www.synet.sk/php/en/220-php-performance-benchmark

This is the raw data:

hhvm_speed_data

Note that the memory usage (in bench3.php) is also different:

hhvm_gc

Conclusion

The differences were smaller and less consistent than I expected. Also I was disappointed that HipHopVM did not run my code.

NB: HHVM v2.2.0 is out and it runs Symfony!

What do you think about these numbers? Please share your thoughts in the comments below.

Share

Memcache vs Memcached PHP benchmark

We are talking about the following two PHP memcache clients.

Should you use memcache or memcached? There are some people writing about this:

Memcached 16% faster than Memcache?

Nobody seemed to benchmark the two clients to see which one is faster and that is why I did just that. I tested both clients on the same machine with default settings in Ubuntu 12.04 for both the clients and the server. This is the benchmark script I used:

<?php
// Initialize values: 10000 keys of 20 bytes with 40 bytes of data
$c = 10000;
$values = array();
for ($i=0;$i<$c;$i++) $values[sprintf('%020s',$i)]=sha1($i);
echo "memcache vs memcached: $c keys\n";
// Memcached
$m = new Memcached();
$m->addServer('localhost', 11211);
$start = microtime(true);
foreach ($values as $k => $v) $m->set($k, $v, 3600);
$time = microtime(true)-$start;
echo "memcached set: $time\n";
$start = microtime(true);
foreach ($values as $k => $v) $m->get($k);
$time = microtime(true)-$start;
echo "memcached get: $time\n";
// Memcache
$m = new Memcache();
$m->addServer('localhost', 11211);
$start = microtime(true);
foreach ($values as $k => $v) $m->set($k, $v, 0, 3600);
$time = microtime(true)-$start;
echo "memcache set: $time\n";
$start = microtime(true);
foreach ($values as $k => $v) $m->get($k);
$time = microtime(true)-$start;
echo "memcache get: $time\n";

And this is the output:


maurits@maurits-Aspire-X3960:~$ php memcache.php
memcache vs memcached: 10000 keys
memcached set: 0.91661500930786
memcached get: 0.86234307289124
memcache set: 1.0546097755432
memcache get: 1.0519700050354

We clearly see that memcached is faster than memcache, but to find out how much faster we have to use xdebug profiling (install with “sudo apt-get install php5-xdebug”). We enabled xdebug profiling by setting “xdebug.profiler_enable = 1” in “/etc/php5/conf.d/xdebug.ini”. After running the php script a “cachegrind.out” file is created in the “/tmp” directory. KCachegrind (install with “sudo apt-get install kcachegrind”) can analyze that file and make pretty graphs:

memcache_vs_memcached_3
picture 1: KCachegrind call graph

memcache_vs_memcached_2
picture 2: KCachegrind callee map

memcache_vs_memcached
picture 3: KCachegrind flat profile

Conclusion

The difference is really small, so there are probably better reasons to choose the memcached client over the memcache client 😉

Share