Facebook makes PHP 9x faster via virtual machine (HHVM?)

The JIT compilation can be slower for certain tasks, but the idea is that you are doing these tasks over and over and over again. That initial slowdown should be outweighed in a typical application, after which point you start to see the 5-10x performance gains. For a fair comparison, there is a flag to turn it off for small one-off tasks. It tries to optimize common code paths so it runs faster the next time, but obviously this takes time.

I noticed my test suites were running about 2x faster, but if I run them 100 or 1000 times repeatedly, it runs almost 10 times faster.
 
Yes, I noticed that. The first few requests are always an order of magnitude slower but then the JIT kicked in and it runs faster than that. However, I used loader.io to stimulate user requests and for every page that I tried, HHVM uses more CPU, more memory but average response time is slower. I picked up a graph from my review (writing :D)

php5-fpm 3094 requests, 952ms
https://loader.io/reports/b5e5e00b502676f449bc78e937b14551/results/542560ca92e3a52a67bbfc0e613a7850

hhvm 2315 requests, 1267ms
https://loader.io/reports/b5e5e00b502676f449bc78e937b14551/results/fa570787307554a80c60bb31b645fdaa

The tests were run on the same server, put behind nginx, after a reboot. 100 concurrent users in one minute.
 
@xfrocks That's a bit disappointing, but thanks for sharing the results. Was it against PHP 5.5 with opcache enabled?

Yes.

Code:
root@server1:~# php5-fpm -v
PHP 5.5.3-1ubuntu2.2 (fpm-fcgi) (built: Feb 28 2014 20:06:14)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies

Code:
oot@server1:~# php5-fpm -i | grep opcache
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 0 => 0
opcache.force_restart_timeout => 180 => 180
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 4 => 4
opcache.load_comments => 1 => 1
opcache.log_verbosity_level => 1 => 1
opcache.max_accelerated_files => 2000 => 2000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 64 => 64
opcache.optimization_level => 0xFFFFFFFF => 0xFFFFFFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_timestamps => On => On
 
@xfrocks That's a bit disappointing, but thanks for sharing the results. Was it against PHP 5.5 with opcache enabled?
I guess our workload is not optimized yet in HHVM. In XenForo, PHP doesn't do much anyway, we just get data from database, change it a little bit push it out with templates. I think the template part is the bottleneck (using eval by default). I'm doing tests with template as public to see how that works. Should be faster with both hhvm and php5-fpm though.
 
Some great work being done here guys. Thanks for all your testing and benchmarking which helps us all. :)
 
So, having a quick play with a debian install.

Code:
Server version: 10.0.10-MariaDB-1~wheezy-log mariadb.org binary distribution

Code:
# php -v
HipHop VM 3.0.1 (rel)
Compiler: tags/HHVM-3.0.1-0-g97c0ac06000e060376fdac4a7970e954e77900d6
Repo schema: a1146d49c5ba0d6db903beb3a4ed8a3766fef182

Code:
# nginx -v
nginx version: nginx/1.5.12

All up and working with a test install of XF
 
All up and working with a test install of XF
Working, definitely, but has it been beneficial? That's my question.

It's an exciting technology but I have no plans to use it if php-fpm outperforms it when it comes to the type of stuff XenForo does.
 
Working, definitely, but has it been beneficial? That's my question.

It's an exciting technology but I have no plans to use it if php-fpm outperforms it when it comes to the type of stuff XenForo does.
In my case, no. It's on a test VPS, done simply to see if I could get it working. I'd not use it on my live site any time soon, as my current nginx/php-fpm set up works perfectly well.
 
In my case XF with a ton of addons runs with HHVM much faster than with PHP-FPM (2-3 times faster). These results were taken on hhvm 2.4, currently running 3.1 (nighty). The huge benefit from 3.0.1+ is mysqli support and no crash every half an hour. Can't make new tests as I currently have no php-fpm installed.
 
In my case, no. It's on a test VPS, done simply to see if I could get it working. I'd not use it on my live site any time soon, as my current nginx/php-fpm set up works perfectly well.
Can you experiment on mine?
 
Top Bottom