HHVM and Elgg

Facebook created a very fast php JIT compiler, called HHVM. A few weeks ago I decided to give it a test run.

It is not easy to get it up and running and for the Dutch guys we wrote an article on how to implement this and links to gists on creating services, but I guess with google translate it could also be useful to others.

Anyway, after getting it up and running the performance improvements are impressive. On average a page load improved 30 to 40%.

I only found one incompatibility with Elgg and has been investigated by Facebook (issue 2843) and the Elgg team, but not yet resolved. There is a workaround, just disable the failing function. What you loose is making paragraphs in comments automatically.

Although the performance improvements is impressive, I am not running it in a production environment because the HHVM services is not stable enough. It crashes once or twice a day without a stack trace. This can be circumvented using service monitoring tools and just restart the service but my feeling is that it is not what you want for a production environment. I also used the 3.2.0 dev version, which is not their stable release but the stable release gave to much trouble compiling.

The cool thing is that if Elgg or Facebook can solve this rather small thing one way or the other, Elgg can be added to the list of compatible frameworks. Technical detail of the issue is complicated, but a workaround should be simple

HHVM is in my opinion a project to keep track of and very promising.

  • Glad to hear you were able to get this up and running (mostly). I've been hearing good things about it as well.

  • @rjcalifornia, as to your pm request here is the english version of the implementation guide.

  • @Gerard Thanks for the English version

     

    How often crashes occur? How stable is it?

  • That depends, on one semi production instance it never crashes, on another one once a day. But the lack of stack traces until now leaves no clues on where the code fails. Haven't done much effort on this yet, but will find the bug. Hope it is my code, and I actually did something stupid, that makes it easier to fix. Keep you posted

  • @Gerard I am asking this because we are looking for ways to optimize our elgg powered product for a project we are applying to.

    I will have to try the next couple of days.

  • Good luck, there is a way to use HHVM in a clustered way like FB is using it themselves. I have not tried that yet, but it can provide you with unlimited power on the application layer. With memcache (which is supported) you can also stretch the db layer, at some point you will only be hit at writes to the db which will clutter up the master instance. But before you do, you potentially could stretch to tens of millions of users.
     

  • Update: We have found the cause of the instability with HHVM and Elgg. In our case we needed to tweak the memory configuration of HHVM. Default memory allocation of data chunks was too small (64 MB) for some of the pages. We stretched it to 256 or 512 MB in other settings and that is sufficient in our case. Maybe other sites could do well with the default config or even maybe need more memory. Anyway, this is a link to our server settings

    Still very happy with the performance improvements.

  • Hi Gerard, I´m trying with HHVM and the performance improvements are amazing, about 50% less time of page load, and this results only intalling NGINX + HHVM (without memcache or pagespeed), but I´m having problems loading large pages, I get this error:

    \nFatal error: Call to undefined method DOMText::setAttribute from context ElggAutoP in ../nginx/.../engine/classes/ElggAutoP.php on line 174

    I´m testing with different memory configuration, but problem persist.

    Do you have any suggestion to solve this issue?, I love HHVM!!

    This is my actual config of server.ini:

    ; php options

    pid = /var/run/hhvm/pid
    hhvm.log.level = Warning
    hhvm.log.always_log_unhandled_exceptions = true
    hhvm.log.runtime_error_reporting_level = 8191
    hhvm.mysql.typed_results = false

    ; hhvm specific

    hhvm.server.port = 9000
    hhvm.server.type = fastcgi
    hhvm.server.default_document = index.php
    hhvm.log.use_log_file = true
    hhvm.log.file = /var/log/hhvm/error.log
    hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc

    ;####
    hhvm.server.fix_path_info = true
    hhvm.server.enable_magic_quotes_gpc = false
    hhvm.server.enable_keep_alive = true
    ;hhvm.server.enable_ssl = true
    hhvm.log.access_log_default_format = "%h %l %u %t \"%r\" %>s %b"
    hhvm.log.runtime_error_reporting_level = Warning
    ;hhvm.server.apc.enable_apc = true
    hhvm.server.request_timeout_seconds = 120
    hhvm.mysql.slow_query_threshold = 10000
    hhvm.jit_asize = 67108864
    hhvm.jit_global_data_size = 67108864
    hhvm.jit_acold_size = 67108864
    hhvm.jit_afrozen_size = 22554432
    hhvm.eval.perf_pid_map = false

    date.timezone = America/Los_Angeles
    default_socket_timeout = 120

    Thanks @Gerard for your great work with HHVM and Elgg.

     

  • @Evan thanks for the info, I´ve read it carefully but I don´t understand if is there a solution, I´ve added this code to ElggAutoP.php:

    if ($autop instanceof DOMText) {die($html);}

    ...but the page loading still fails, where must I put it?, is this the solution? 

    One annotation, the same page loads perfectly If the user is logged out.

Performance and Scalability

Performance and Scalability

If you've got a need for speed, this group is for you.