PHP Classes

PHP Developer working for Google Launches New PHP Compiler

Recommend this page to a friend!
  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog PHP Developer working...   Post a comment Post a comment   See comments See comments (1)   Trackbacks (0)  


Viewers: 50

Last month viewers: 15

Categories: PHP Performance, News

Recently it was launched a new PHP compiler named Recki-CT that generates native machine code that can outperform the same PHP code run by Zend Engine or Facebook HHVM.

Read this article to learn more about this new PHP compiler, how it works and the plans for its future.

Loaded Article


What is Recki-CT?

How does Recki-CT work?

How Fast is Recki-CT?

Future Developments


What is Recki-CT?

Anthony FerraraRecki-CT (Recki Compiler Toolkit) is a project launched by Anthony Ferrara, a long time PHP developer that has joined Google recently as a developer advocate.

Despite he is working at Google, Recki-CT is not really part of his developer advocate work. It is something that he does in the 20% of his work time that Google allows their employees to work on projects of their choice. So, this should not be understood as an official Google project, despite the copyright notices mention Google and contributors need to sign a CLA (Contributor License Agreement).

Recki-CT is a project totally written in PHP itself. It parses PHP code and generates native assembly code as result of the compilation of the PHP code.

How does Recki-CT work?

Anthony was contacted and he was so kind to help clarifying how Recki-CT works and how it can compile PHP code that achieves such impressive performance results.

Basically, Recki is a PHP library that takes some PHP code, parses it to build an Abstract Syntax Tree (AST) using Nikita Popov's PHP-Parser

Then Recki-CT analyses the syntax tree to perform some optimizations. The result is compiled code into an intermediary representation text format. That code is passed to Joe Watkins' JIT-FU extension that emits native code using the libjit library.

The resulting machine code can be executed by calling it like you call a closure function in PHP.

How Fast is Recki-CT?

In terms of speed we need to see it from two points of view. The first is the compilation step. This is not a fast step, not only because it is implemented with PHP code, but also because the parsing, analysis and optimization tasks tend to be slow due to the complexity of such tasks.

Therefore Recki-CT caches the compiled code to avoid taking too much time recompiling the same code over and over again.

As for the actual compiled code, according to the benchmarks published in an article in Anthony's blog, in some cases the resulting code outperforms Zend Engine version included in PHP 5.5, as well HHVM 3.2.

Here are some results taken from that article. Notice that in some cases the tests fail because they run code that is not yet supported by Recki-CT.

php 5.5Recki-CThhvm 3.2hippy-cqb
jumpapaluza(50, 50)11.677461.092401.481921.00000FAIL

Future Developments

Currently Recki-CT does not support all code constructs of PHP. This will be improved over time.

Right now the the last step of compiling to machine code is done at runtime. So Anthony plans to move this step to the actual compilation step and have the resulting machine code cached too.

Another interesting possibility is to take advantage of the built-in AST support that is being included in PHP 7, thanks also to the contribution of Nikita Popov to the PHP 7 development. That would make the actual compilation step faster, as the AST support in Recki-CT is currently is being implemented in PHP code.


2014 has been an awesome year for PHP in terms of important developments that bring extra performance to PHP.

First we had Facebook HHVM and the Hack language bringing amazing features and speed improvements. Then we had the reaction of Zend to bring other speed improvements to PHP 7.

More recently we had Recki-CT, as well Hippy-VM which is another fast implementation of the PHP language using the PyPy technology.

Recki-CT seems to bring some additional interesting aspects when compared to other solutions. One is that it can be used to compile just parts of your PHP code. This means that you do not need to compile all your PHP application to take advantage of its capabilities to speedup parts of your PHP applications that are slow.

Another aspect is that since it is mostly done in PHP, it can run with the Zend Engine based PHP, or even with HHVM or Hippy-VM, as long as the JIT-FU extension is available. So, it is not really an alternative to other PHP engines, but rather something that can boost your PHP code performance further.

One side aspect that is not related to PHP performance is the fact that compiling the code to machine code, this solution may be used eventually to ship compiled code without giving away the source code.

Although it was not the original intention of the project, this aspect may interest developers that are willing to sell their PHP work without giving away the source code.

All these aspects make the future of PHP even more promising and exciting than it already is. Congratulations to Anthony Ferrara and all others that are bring such amazing improvements to PHP.

What do you think? Do you feel is there anything else important that PHP needs to make it even more exciting? Post a comment to tell what you think.

You need to be a registered user or login to post a comment

1,614,673 PHP developers registered to the PHP Classes site.
Be One of Us!

Login Immediately with your account on:


1. Brilliant work - Jacob Fogg (2014-10-06 20:32)
Brilliant work... - 0 replies
Read the whole comment and replies

  Blog PHP Classes blog   RSS 1.0 feed RSS 2.0 feed   Blog PHP Developer working...   Post a comment Post a comment   See comments See comments (1)   Trackbacks (0)