Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

What's a PHP Engine? Anything that can run PHP code

Slide 3

Slide 3 text

Why Creating a PHP Engine?

Slide 4

Slide 4 text

1. To Increase Performances

Slide 5

Slide 5 text

2. To Attract some parts of the biggest web dev ecosystem

Slide 6

Slide 6 text

Let's go on a trip!

Slide 7

Slide 7 text

The Civilized Territories

Slide 8

Slide 8 text

The Zend Engine by official PHP Engine appeared first in PHP 4 Zend Engine III for PHP 7

Slide 9

Slide 9 text

Zend Engine: How it works Execution Time PHP Code ⬇ compiled to Op Code ▶ executed by Zend VM ▶ executed by Processor

Slide 10

Slide 10 text

HHVM Hip Hop Virtual Machine by Perfomances = $$$$$$$

Slide 11

Slide 11 text

HHVM: How it works Execution Time PHP Code ⬇ compiled to Op Code ▶ compiled by JIT to Machine Code ▶ executed by Processor

Slide 12

Slide 12 text

The Binary Compilers Back to the roots!

Slide 13

Slide 13 text

Roadsend PHP Direct compiler from PHP to native binaries Started in 2007, abandonned in 2012 www.roadsend.com

Slide 14

Slide 14 text

Roadsend PHP How it works Compilation Time PHP Code ⬇ compiled to Machine Code in Native Binaries Execution Time Machine Code from Native Binaries ▶ executed by Processor

Slide 15

Slide 15 text

Hip Hop PHP by Performances! Transpile PHP to C++ Superseded by HHVM (Hip Hop VM), as not dynamic enough (no eval)

Slide 16

Slide 16 text

Hip Hop PHP How it works Compilation Time PHP Code ⬇ transpiled to C++ Code ⬇ compiled to Machine Code in Native Binaries Execution Time Machine Code from Native Binaries ▶ executed by Processor

Slide 17

Slide 17 text

The Perl Lost World

Slide 18

Slide 18 text

Perl, What's that? Used to be the most popular language for the Web (made CGI popular!) around 2000s System and development oriented Still used a lot as "ops" language apt-get, dpkg rpm

Slide 19

Slide 19 text

Introducing Perl 6

Slide 20

Slide 20 text

Building Perl 6 VM

Slide 21

Slide 21 text

"Parrot is a virtual machine aimed at running all dynamic languages." Implementations started for 38 languages, included: Java, Lua, Brainfuck, C, Python, Ruby, Perl 6, .... , PHP Proudly still in development since 2000 www.parrot.org

Slide 22

Slide 22 text

Pipp: Pipp is Parrot's PHP Part of the all dynamic languages effort Last commit: 8 years ago github.com/bschmalhofer/pipp

Slide 23

Slide 23 text

How Pipp works Execution Time PHP Code ⬇ compiled to Parrot Code ▶ executed by Parrot VM ▶ executed by Processor

Slide 24

Slide 24 text

The Java Land

Slide 25

Slide 25 text

Quercus "So using PHP with Grails is a quick and painless endeavor." Java class usage and Unicode compliance provide Zend standard exts (cURL, PDO, ...) One of the rare alt PHP Engine able to run full applications (Drupal, Wikimedia) Unfortunately, not actively maintained quercus.caucho.com $string = new java.lang.StringBuffer("Unicode string ✈");

Slide 26

Slide 26 text

Quercus: How it works Execution Time PHP Code ⬇ transpiled to Java Code ▶ compiled by javac to Byte Code ▶ executed by JVM ▶ executed by Processor

Slide 27

Slide 27 text

JPHP Benefits properly from the JVM JIT Debug via the xdebug protocol 1.1x faster than PHP 7 Wants to allow PHP on Android Don't provide Zend standard exts Active but not a lot of contributors

Slide 28

Slide 28 text

JPHP samples: Multithreading $thread = new Thread(function () { $i = 0; while (true) { $i++; echo $i, "\n"; sleep(2); // every 2 seconds } }); $thread->start(); // start thread

Slide 29

Slide 29 text

JPHP samples: UI $form = new UIForm(); $form->size = [600, 300]; $form->title = 'My Program'; $button = new UIButton(); $button->text = 'Click Me'; $button->on('click', function(MouseEvent $e) { UIDialog::message('Hello World'); }); $form->add($button); $form->show();

Slide 30

Slide 30 text

JPHP How it works Compilation Time PHP Code ⬇ compiled to Byte Code Execution Time Byte Code ⬇ compiled by JIT to Machine Code ▶ executed by Processor

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

The Snake Country

Slide 33

Slide 33 text

HippyVM started at uses (JIT inside) Not actively maintained anymore

Slide 34

Slide 34 text

HippyVM Performances

Slide 35

Slide 35 text

HippyVM: How it works Execution Time PHP Code ⬇ transpiled by HippyVM to RPython ▶ compiled by PyPy JIT into Machine Code ▶ executed by Processor

Slide 36

Slide 36 text

MS World

Slide 37

Slide 37 text

Phalanger "improves the performance, allows to use modern environments ... compiles legacy PHP code" Not maintained anymore phalanger.codeplex.com

Slide 38

Slide 38 text

Phalanger: how it works Compilation Time PHP Code ⬇ compiled to Common Intermediary Language Execution Time Common Intermediary Language Code ⬇ compiled by .Net JIT to Machine Code ▶ executed by Processor

Slide 39

Slide 39 text

PeachPie Superseds Phalanger Benefits from the Roslyn compiler platform Target PHP 7.1 syntax First item in the FAQ:"PHP sucks, why port this horrendous language to .NET?" www.peachpie.io

Slide 40

Slide 40 text

PeachPie Benchmarks

Slide 41

Slide 41 text

PeachPie: how it works Compilation Time PHP Code ⬇ compiled to Common Intermediary Language Execution Time Common Intermediary Language Code ⬇ compiled by .Net JIT to Machine Code ▶ executed by Processor

Slide 42

Slide 42 text

The Land of the Little Ones

Slide 43

Slide 43 text

PH7 - The Embedded PHP Engine Build for real embedded hardware Embedded VM similar to Zend VM Dedicated to IoT and home routers ph7.symisc.net

Slide 44

Slide 44 text

PH7 - Distinctive Features Full type hinting Native UTF-8 support. Function arguments can take any complex expressions as their default values. "Correct and consistent implementation of the ternary operator." echo (true?'true':false?'t':'f');

Slide 45

Slide 45 text

PH7 code sample #define PHP_PROG "" #include #include #include "ph7.h" int main(void) { ph7 *pEngine; ph7_vm *pVm; ph7_init(&pEngine); ph7_compile_v2(pEngine, PHP_PROG, -1 &pVm, 0); ph7_vm_exec(pVm,0); }

Slide 46

Slide 46 text

PH7 - How it works Compilation Time C code with PHP code inside ⬇ compiled to Machine Code with PHP code inside Execution Time Machine code with PHP Code inside ⬇ PHP code compiled to Op Code ▶ executed by Embedded VM ▶ executed by Processor

Slide 47

Slide 47 text

The Rusted Land

Slide 48

Slide 48 text

Tagua VM Written in Rust Security Focused: Safety First! Benefits from the LLVM platform github.com/tagua-vm/tagua-vm

Slide 49

Slide 49 text

Tagua VM - How it works Execution Time PHP Code ⬇ compiled to Op Code ▶ executed by Tagua VM ▶ executed by Processor

Slide 50

Slide 50 text

The Future? JIT on Zend Engine Implemented as part of opcache Uses LLVM as backend github.com/zendtech/php-src/tree/zend- jit/ext/opcache/jit

Slide 51

Slide 51 text

Conclusion That's a big world out there! The Leaders Zend Engine HHVM The Challengers Peache Pie Tagua VM

Slide 52

Slide 52 text

Thank you! Questions?