HipHop

HipHop is an open source PHP to C++ translator developed by Facebook.

HipHop support in MediaWiki is currently at an early stage of development. It should not be used by anyone except for developers wishing to improve the HipHop support.

Running MediaWiki under HipHop
For information on installing HipHop, see the HipHop wiki. To compile MediaWiki with HipHop:

This will create a compiled binary at. To run a test server, use:

This will start an HTTP server which listens on port 8080. MediaWiki will be accessible at.

To run a maintenance script:

Currently, to reduce build time, only a small subset of MediaWiki files are compiled by default.

Interpreter
HipHop has both a compiler and an interpreter. For the maximum speedup, we want as much code to be compiled as possible. However, the build process is slow (~30 minutes), so it seems reasonable to interpret the configuration files.

It's possible to interpret arbitrary code with eval or include called from a compiled program. In fact, this is how the hphpi binary works -- it is written in PHP.

File level code can be compiled like any other code. To execute compiled files, use:

where the path is relative to $IP. To cause a file to be executed in interpreted mode, use:

Both of these forms will work in Zend PHP. When you want to make sure a class or function exists, do not use code such as:

This will cause the file to be interpreted, regardless of whether the class exists already, which is usually not what was desired.

Declarations
The following things are available from the startup of the compiled binary:


 * Class declarations
 * Function declarations
 * Constants created with define with a name and value easily determined at compile time

It's not possible to put code which you wish to execute at runtime in the file level of the same file that contains such declarations. Because the class or function already exists at startup, including the file leads to a duplicate definition error.

Although all classes are available from startup, calling class_exists on them will return false. This is a HipHop bug. To work around it, use  instead. This works by using the Reflection extension.

Differences compared with Zend PHP

 * Many extensions have only "stub" implementations, which apparently means that they have classes with the right methods, but the methods do nothing.
 * MySQL is the only supported DBMS.
 * Some functions have incomplete implementations:
 * error_log: The message type is ignored, the string is just sent to the server log
 * method_exists: The first parameter must be an object. Checking for static methods is not possible.
 * Most php.ini settings are gone. ini_get and ini_set only work for a few selected settings:
 * error_reporting
 * memory_limit
 * max_execution_time
 * hphp.build_id
 * arg_separator.output
 * upload_max_filesize
 * log_errors
 * error_log
 * notice_frequency
 * warning_frequency
 * include_path

Some other differences are listed in the inconsistencies file in the HipHop source.

To do
These tasks are available for anyone to work on:


 * Output compression is broken for large pages. Binary garbage is displayed. Isolate and report upstream.
 * Preview is broken, the server aborts when $wgParser->parse is called from EditPage::getPreviewText. Isolate and report upstream.
 * Make the PHPUnit tests work.
 * Compile and test all core special pages and other core features.
 * Design a build system which will allow MW extensions to be easily added to builds. If possible, it should work with a plain /trunk checkout, without needing to move extensions to /trunk/phase3/extensions.
 * Fix any extensions that you are interested in.
 * Fix the notices and warnings that HipHop generates at runtime, as far as possible.
 * Benchmarking & profiling:
 * Benchmark the CPU usage of various kinds of request, comparing HipHop with Zend.
 * Profile CPU usage in HipHop and identify targets for optimisation.
 * Maybe look at using xhprof