4

I recently analysed performance differences of two test PHP scripts by running them on various combinations of Apache / NGinx / HHVM / ReactPHP.

My question now is if there is an expected performance difference between a PHP script executed on HHVM and the (as much as possible) identical script implemented in Hack (and executed on HHVM)?

Has anyone tried this?

T-Man
  • 51
  • 5

1 Answers1

4

According to a comment on the HHVM blog, as of April 2014 there is no runtime difference due to the types being erased at runtime.

However, once that changes you should be able to expect a small performance increase, considering that HHVM is optimized for Hack, and that static typing is generally faster than dynamic typing.

And a little bit of background:

HHVM had to be developed from the ground up, and is still relatively new. Facebook's codebase was originally in PHP, and moved to Hack as they had time to recode. They are focusing on improving the runtime as a whole, and this is (comparatively) a very minor area of improvement. The change would only affect Hack, so I expect they will delay that until they are running low on other, larger improvements

Community
  • 1
  • 1
Jeremiah Winsley
  • 2,537
  • 18
  • 30
  • Thank you, this is really interesting! Do you have an insight on why they chose to do this, and if it is likely to change? – T-Man Sep 22 '14 at 19:57
  • Updated my answer with a bit of background. – Jeremiah Winsley Sep 22 '14 at 20:02
  • 1
    They're not completely erased -- only generics are actually erased, the others are enforced at runtime too. We just aren't doing a very good job of actually using them to specialize JIT'd code, at least not nearly as much as we could be. I gave a more nuanced answer on Reddit a while ago: http://www.reddit.com/r/PHP/comments/2a2f75/hhvm_framework/cirs2qu. The most important part of my answer there is the end: if you are converting to Hack just for perf benefits, then you have missed an awful lot of the point: the benefits in engineering time and developer efficiency. – Josh Watzman Sep 27 '14 at 16:56