

HipHop VM: now at 98.5% PHP framework parity, 16% faster - jamesgpearce
http://www.hhvm.com/blog/2813/we-are-the-98-5-and-the-16

======
shin_lao
I'm not sure I understand. Is this the framework that "compiles" PHP?

Is the 15% performance increase relative to vanilla PHP or to a previous
version of HHVM?

~~~
plorkyeran
HipHop was the PHP -> C++ compiler. HHVM is a JIT-compiled implementation of
PHP.

The 15% increase is relative to HHVM at the beginning of the 3-week sprint
they just completed. HHVM was already far faster than vanilla PHP when it was
first publicly announced over a year ago.

~~~
ed
That's more interesting. How much faster is hhvm overall?

~~~
LogicalBorg
The Wikipedia article
([https://en.wikipedia.org/wiki/HipHop_for_PHP](https://en.wikipedia.org/wiki/HipHop_for_PHP))
says "up to 6x", however, about 2x speedup versus plain PHP was a more typical
experience for me when I used it before.

~~~
seunosewa
So basically it's as fast as using PHP with an opcode cache?

~~~
sanxiyn
No, 2x speedup relative to PHP with an opcode cache.

------
togasystems
Other than Facebook, does anybody have HipHop running in production? Any big
caveats?

~~~
ams6110
Other than Facebook, does anybody _need_ HipHop?

~~~
McGlockenshire
You're confusing HipHop with HHVM.

HipHop took PHP code and basically turned it into a statically compiled C++
application. The resulting binary acted directly as a web server. It was
pretty fast, but very limited.

HHVM is an actual JITing virtual machine for PHP. It's still huge (one of the
project pages say that the binaries are nearly a hundred megs), but it's now a
real-world reimplementation of PHP, capable of doing anything PHP can,
including eventually being run by mere mortals with normal code.

------
elwell
Nice! CodeIgniter is at 100% now. I've been contemplating the switch to hhvm
for my startup, now it seems likely.

~~~
dpcx
Don't take this the wrong way, but you're actually developing _new_
applications with CodeIgniter? Ugh...

~~~
Gigablah
Yeah, Laravel is pretty much the modern framework for people who can't divorce
themselves from CodeIgniter.

~~~
dan15
What does Laravel do that other frameworks like FuelPHP and Yii don't do? I
hear a lot about it but don't hear a lot about why it's so much better than
others.

~~~
Gigablah
On the surface most of the popular PHP frameworks are not much different from
each other. Basic MVC separation, some sort of dependency injection container
(actually a service locator), Composer and standardized autoloading, etc. Once
you dig into the coding aesthetics then the differences start to become clear.
Yii isn't PSR compliant, both FuelPHP and Laravel make liberal use of Facades
and/or __callStatic to preserve the style of static function calls that are
prevalent in CodeIgniter. I guess what makes Laravel stand out is the sheer
amount of documentation and examples that are available, both on the website
and in the code itself. This makes it really easy to get started.

Me, I'm not really keen on the Component::function() syntax. Feels like a
crutch to me. Especially when people go out of their way to avoid specifying
namespaces by abusing class_alias. Plus you're not really saving that many
keystrokes compared to, say, $this->app['component']->function(). (Yes, I like
Silex).

~~~
codelust
$this->app['component']->function() gives me an instant headache. Which is why
I always wind up giving up on Symfony/Silex after trying it out every now and
then.

OTOH, I had a much easier time with Laravel, though it uses some of the same
Symfony components under the hood.

------
Keyframe
Hmmm Laravel at 100%. This is now getting interesting!

~~~
dubcanada
Drupal is also 100%, that's actually really nice. Want a quick performance
boost on your Drupal site, replace PHP with HHVM

~~~
rb2k_
This is core though, from what I hear contrib still breaks (haven't tried
myself)

~~~
Jgrubb
I tried it two days ago after they made the fastcgi announcement. My day job
sites are fairly big with what I consider a pretty large number of contrib
modules. I managed to get it up and running, but the HHVM logs were full of
notices and it finally bombed out after several requests (not enough to really
warm up the VM) on something related to apachesolr, and another one related to
GD, which is strange because we use imagemagick, but whatever. Sad Trombone.

The really cool part though, it truly was "drop in". Every bit of my existing
nginx/fpm configs worked as is, so once it's a bit further along, it's just a
matter of shutting down fpm and firing up HHVM.

There were also a couple of gotchas in the setup related to the fact that
their apt installer installed HHVM configs that don't assume Fastcgi, so it
took a little bit to figure out the correct edits to the init script and HHVM
config so it'd listen on :9000 instead of :80, but all in all that it worked
at all was really fun for a minute. Very excited about this project.

------
sideproject
Is there a good tutorial on installing HHVM on server and then running your
PHP app?

~~~
frik
Yes, on the official wiki:
[https://github.com/facebook/hhvm/wiki/_pages](https://github.com/facebook/hhvm/wiki/_pages)

First read the page related to your Linux/BSD e.g. "Prebuilt Packages on
Ubuntu 12.04"

Then read the page "Using nginx as Front Server to HipHop"

As last step read this blog article how to write/edit the config file
(/etc/hhvm.hdf): [http://www.hhvm.com/blog/113/getting-wordpress-running-on-
hh...](http://www.hhvm.com/blog/113/getting-wordpress-running-on-hhvm)

Read this and copy things you need from the _documentation_ :
[https://github.com/facebook/hhvm/blob/master/hphp/doc/option...](https://github.com/facebook/hhvm/blob/master/hphp/doc/options.compiled)

This is how I got HHVM working.

To sum up:

    
    
      * you need a little bit of basic Linux knowledge
      * install Linux or BSD (e.g. Ubuntu 12.04 LTS) (64-bit)
      * install Nginx (or since last week HHVM also supports Apache with FastCGI)
      * install HHVM
      * install MySQL or MariaDB, etc.
      * create a web directory where you place your php files
      * edit the hhvm.hdf (config file)
      * start hhvm
    

Btw. a lot of blog posts you find with Google search are still about the old
HpHp (the former and now outdated PHP to C++ translator also called HipHop
from FB)... so better skip third party blog posts older than January 2013 ;)

------
AlexanderDhoore
I wonder how hard it would be (for me) to take php and change all function
names to be consistent. All PascalCase and spelled out (no awful
abbreviations). Then download the documentation and change it there as well.

~~~
meritt
Ahh yes, take the most criticized aspect of Java -- the obscene verbosity --
and cram it into PHP. Sounds wonderful.

~~~
AlexanderDhoore
I'll take a long function name over an incomprehensible one any day.

~~~
1qaz2wsx3edc
While you're at it why don't you fix: (needle, haystack), (haystack, needle)?
:P

~~~
Domenic_S
With array functions, the needle is first. With string functions, the haystack
is first.

[https://gist.github.com/salathe/1672543](https://gist.github.com/salathe/1672543)

~~~
1qaz2wsx3edc
This still doesn't convince me it was ever a beneficial design.

~~~
Domenic_S
I didn't claim it was beneficial, just consistent.

------
debacle
The performance increase in relative to the previous release of HHVM.

------
digitalnalogika
Does anyone have an easy method of testing HHVM on your website?

I was thinking of recording the production requests for x amount of time and
replaying them on HHVM so you could see if responses are identical, there are
no crashes, state of the database is same afterwards, etc.?

~~~
girvo
A good test suite? ;)

Seriously though, I decided that if I had a project that was difficult to
test, that I knew had hairy code that used some funky features it was best to
just stick to APC. All my new projects are being built on HHVM directly with
test suites as I go.

Edit; that was a while back now, though. What frameworks and libraries are you
using? Run their test suites through HHVM and if they all pass, you'll be
fine. Facebook use it themselves now apparently.

------
thevert
What does a Lockdown implies?

~~~
nbm
I'm not sure about the particulars of this one, but a lockdown is generally a
period where you are encouraged to prune away unnecessary and/or lower-
priority requests for your time.

There generally aren't a lot of status meetings, team meetings, project
meetings, and so forth at Facebook, but you might want to turn down a request
to present at another team's meeting, or turn down those requests to interview
- they can wait, or another person can be found.

People tend to make progress on lower-priority work items in between higher-
priority work items - things like migrating onto a new library or version of a
service, or maybe migrating from one set of machines to another if you aren't
using one of the high-level service management systems. This is necessary to
prevent these things from becoming interrupt items down the line, but during a
lockdown period, it's okay to let these slide for a bit.

If the whole team does this, then suddenly you're spending a lot more time
together. Instead of potentially working on different parts of the software
like you usually do, you can all focus on a particular class of problem - in
this case, performance and parity. That means everyone has that context loaded
up, and you can have better discussions and quicker code reviews.

------
ohashi
I see a lot of familiar frameworks and CMSs except one. Wordpress. Any idea
why Drupal and Joomla would be listed without WordPress?

~~~
ptarjan
Wordpress' unit test suite was just too gnarly to get running with our test
harness. Send us a pull request if you can get it working.

[https://github.com/facebook/hhvm/blob/master/hphp/test/frame...](https://github.com/facebook/hhvm/blob/master/hphp/test/frameworks/run.php)

~~~
michaelmior
It seems at the moment there's no way to have a DB server available when
running tests. Is that correct? Until that happens, I don't imagine WP tests
will be able to run.

------
dekz
Hey guys, congrats on the release. Any news about Hack coming out any time
soon?

------
danso
With the recent discussion on the origins of PHP function names, and about
what, if anything, can be done to fix PHP without ruining it...I'm curious
about what happens at Facebook. Besides HipHop, do they maintain a strict PHP
style among their developers? Even if HipHop can handle all of PHPs
variations, I imagine there's time saved by writing optimally-designed (for
the human) code, too?

~~~
meowface
For core language features like that, there really is no way to "fix" it. Just
pick a better language.

~~~
stusmall
Poor choice of function names are the easiest of problems to fix. Write an
internal base framework that you use and _strongly_ discourage the use of
functions outside of it. Even if the new set of APIs are as simple as just
forwarding the call to the standard PHP one with reversed arguments, using one
example people complain about all the time. This isn't hard to do, doesn't
require a lot of upfront work (add APIs as you go) on a new project, and won't
give you too much (if any) of a performance hit. You don't need to burn the
house down because you don't like how the furniture is arranged.

~~~
meowface
PHP has so many more problems than that, though. I don't think it's worth the
effort. It'd be like replacing the rotting floorboards of a house that has
mold spores in every corner and a caved-in roof.

~~~
dubcanada
wow, you really hate PHP. That that mold infested roof caved in house runs a
great deal of the web.

~~~
smrtinsert
In what universe? Maybe to maintain wordpress applications, but thats just one
product. I don't know that codes in php anymore.

~~~
stusmall
We are literally in a thread about one of the biggest names in tech and
something they invent to help with their massive PHP codebase.

~~~
kibibu
Yeah, but Facebook is just a collection of Wordpress plugins.

See:
[http://wordpress.org/plugins/facebook/](http://wordpress.org/plugins/facebook/)

;)

