Symfony 2.3 achieves 100% HHVM compatibility
July 1, 2015 • Published by Javier Eguiluz
HHVM is an open-source virtual machine designed for executing programs written in Hack and PHP. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance for PHP applications.
During these last past months, HHVM and the upcoming PHP 7 version have engaged in an epic battle to become the fastest PHP engine. At Symfony we are thrilled because this fierce competition will ultimately benefit all of us.
Our HHVM compatibility journey started on December 2013, when Joseph Bielawski added HHVM to the list of tested PHP engines on Travis CI (see commit). Shortly after, Fabien made the first code change to improve HHVM compatibility:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// Add support for HHVM in the getting of the PHP executable
// @see https://github.com/symfony/symfony/pull/9882
class PhpExecutableFinder
{
// ...
public function find()
{
if (defined('HHVM_VERSION') && false !== $hhvm = getenv('PHP_BINARY')) {
return $hhvm;
}
// ...
}
}
That was the first code change, but tens of other changes followed. Some of them were tricky, like the one solved by Christophe Coevoet in the 10,000th Symfony Pull Request:
1 2 3 4 5 6 7 8 9 10
// src/Symfony/Component/Console/Application.php
// HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is
// a 64 bit integer: https://github.com/facebook/hhvm/issues/1327
$width = $this->getTerminalWidth()
? $this->getTerminalWidth() - 1
: (defined('HHVM_VERSION')
? 1 << 31
: PHP_INT_MAX)
;
The hard work made by the Symfony Community always put us at more than 99% HHVM compatibility according to their project compatibility charts. The last needed push to achieve the 100% milestone for Symfony 2.3 was led by Nicolas Grekas in the PR 15,146
This last pull request fixed all the issues found on the Debug, DependencyInjection, Filesystem, Form, HttpFoundation, Process and Routing components. However, due to some HHVM issues or lacking PHP features, in some cases our only choice was to skip the test entirely:
1 2 3
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('HHVM behaves differently in this test case.');
}
After these changes were merged, Travis finally displayed a green result for Symfony 2.3 tests run on HHVM:
Now it's time to celebrate, but soon we'll get right back to work in order to achieve 100% HHVM compatibility for the rest of maintained Symfony branches.
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
A overview for this can be found at my site: http://hhvm.h4cc.de/graphs/
You can also upload a composer.lock files to check HHVM compatibility of your application.
http://hhvm.com/frameworks/
A screenshot with the result of tests is showed. This information says nothing for me. It's a figure with no context.
@Felix the benefit is that you can run Symfony 2.3 on HHVM engine, which is orders of magnitude faster than doing it in PHP 5.3 or 5.4 engines. In recent PHP engines the performance differences are not that abysmal.
This is not "in some cases" that our only choice was to skip the test entirely.
This is the ONLY case that our only choice was to skip the test entirely.
100% hhvm compat is 100% honest. We did not skip any single tests because of errors, issues nor bugs. The single missing "feature" of hhvm is this one: strict notices. Kudos to hhvm for what they did: parity is close enough so that the delta can be handled in exactly the same way as we handle deltas between PHP versions.
And regarding the skipped tests and lacking features, I considered in that phrase all the code related to Symfony, including Monolog, Twig, Doctrine, etc. If you look for in the Symfony source code, you'll find lots of skipped tests and even some lacking features due to the different behavior of HHVM.
And BTW, for the reader again, you'll be happy to know that just a few days after this post, Symfony now enforces 100% HHVM for all branches!