Graalphp: An efficient PHP implementation on GraalVM
Graalphp is an experimental just-in-time (JIT) compiler and runtime for PHP 7.4+ hosted on GraalVM. A research project I started in 2020 at the Advanced Software Technologies (AST) lab at ETH Zurich. Graalphp implements a small subset of the PHP 7 specification and shows promising results in synthetic benchmarks. You find its source-code on GitHub.
Abstract
PHP is a popular, weakly typed, general purpose programming language. Originally designed for building dynamic web pages, the language has since gained wide adoption in server-side web development. In this work, we describe the design and implementation of graalphp, an experimental compiler and runtime for PHP hosted on Truffle and GraalVM. GraalVM is a virtual machine that supports execution of multiple languages, which are implemented as Abstract Syntax Tree (AST) interpreters based on Truffle. GraalVM uses Graal as its JIT compiler to compile frequently executed code fragments to machine code. We implement a subset of the PHP language to run synthetic benchmarks by The Computer Language Benchmarks Game. We compare peak performance of our implementation against PHP 7 as well as alternative implementations such as HHVM, JPHP and an early alpha version of PHP 8. Experimental results indicate that our runtime reaches competitive results with performance gains of up to 859% compared to PHP 7. These preliminary results suggest that a Truffle-hosted PHP implementation might be significantly faster than existing language implementations.
Technical Talk
Report and Preliminary Results
Please consider the technical report and source-code. The following figures are excerpts from the report.
Peak Performance
Warm-up
Web Coverage and Discussions
Found a typo or a mistake? Edit this Page on Github and submit a Pull Request. Thank you.