Graalphp: An Efficient PHP Implementation Built on GraalVM
github.com
github.com
The same will hold true for a Truffle implementation of PHP. It will need to support the C interface components like PDO database drivers and the Laravel web framework.
The linked project was created as part of a graduate thesis and demonstrates the feasibility of GraalVM/Truffle as a performant polyglot platform. I'm not convinced that Ruby/Python/PHP integration with Java Bytecode is an important use case moving forward. It could have been when Rails/Django/Laravel were on top of the web framework game but the demand for this use case is diminishing.
When you have a JIT based language you want as much to be executed in that language, jumping back and forth between PHP and C is a drawback from a JIT perspective.
However there exist many PHP C extensions that are just thin wrappers around large C libraries like cURL, it is not really feasible to implement that in pure PHP.
But with the introduction of a foreign function interface with PHP 7.4 that has made it possible to call C libraries with ease, as long the C library doesn't do too much macro magic, and to my understanding upcoming Java release ships with a much improved native bridge with better support for native types, these two thing could lead to, guessing here, that you only need to implement the bridge for each implementation but share the rest of the PHP wrapper code for that C library.
However the foreign function interface introduced in PHP 7.4 is signigfanctly slower that the old style C extension of Zend PHP, but to my understanding is that future evolution of the JIT could theoretically reduce that performance impact.
The Truffle solution to this is to run the C extension in the same JIT, so that's it's not a barrier to optimisation anymore.
Laravel does not have any C PHP modules in its codebase. While it makes use of drivers provided by them, it does not have any components that are written in C.
Also Truffle will let you run C extensions unlike regular jvm implementations due to the polyglot nature of Graal and Sulong
What makes a PHP version implemented in a JVM 9x faster than PHP implemented in C?
PHP 8 also introduces a JIT compiler, which is presumably less mature but more complete: https://wiki.php.net/rfc/jit
It's easy being faster when you're doing less.
A majority of the dynamic compilation research goes into JVMs. (The remainder being apportioned mostly to the javascript vms and the clr, with mike pall waving his luajit hat in the distance.)
An overwhelming majority of GC research also goes into JVMs, thanks to Jikes RVM.
Ever seen a java Spring project start in 0.015s, or a java rest service living in 16-32mb of ram? With graal these things are now possible.
The kind of things they are benchmarking aren't what people typically use PHP for.
I guess PHPs core types are very inefficient and the team behind PHP lacks time to really do a rewrite. A prime example is the PHP "array". Its not a list, its not an array, but more of a weird object thing. PHP is full of these weird things that are probably hard to optimize (in the PHP runtime)
PHP might not be suited to every application, but it's certainly not slow.
- 11: php-ngx-pgsql
- 12: workerman-pgsql
- 22: workerman
- 23: php-ngx-mysql
- 25: Swoole
Here you see a trend, workerman and swoole are BOTH nodejs clones, they have a event loop and are non-blocking. This means you CANNOT use 95% of core PHP because its blocking by nature. These are all a non-starter for 99.9% of PHP based apps. Also swoole is a PHP C-extension, not a "installable" framework like say Symfony is, taht said these are NOT frameworks at all, not sure why they are on the list?
Heres the REAL rankings of the PHP frameworks that are used in the wild:
- 299: codeigniter
- 323: fatfree
- 369: cakephp
- 370: symfony
- 377: laravel
PHP occupies the lower bottom of the ranking, and will probably always be there becuase og how PHP is built. The core model of execution is always going to be slower than a "running" program. This is evident with the nodejs clones.
[edit]: clarification
[0]: Please note that was the impression I got from reading anything Oracle related in HN, not personal experience. I don't otherwise know what I'm talking about.
Signed: .NET developer very interested in the new developments in the Java World but heard too many scare stories.
Community edition runs any program that runs on GraalVM Enterprise.
As far as I know, there’s no difference between any of the clouds as far as basic payment structure. If you don’t want to be locked in on a contract, you just give a credit card and pay the publicly posted rate. Exactly how are you a hostage in that position?
Maybe because there are businesses out there that care about support?
Is there any difference anymore? I’m not sure there is.
> I have no idea why people would use Oracle Java for new projects
Expert support, for example.
[0] https://www.peachpie.io/ [1] https://www.peachpie.io/benchmarks
Gut feeling: Any attempts on JITting see huge benefits just because of this.
That's like comparing your CPU against a competing product with 2/3 of the cores disabled.
It fares pretty well in [techempower](https://www.peachpie.io/2018/06/performance-progress-report....).
See the benchmarking charts there: https://github.com/gotzmann/comet
Also I assume the polyglot and native image features of GraalVM will work?
GraalVM uses its own GC, and has some limitations: https://github.com/oracle/graal/blob/master/substratevm/Limi... (basically it needs to statically know what will be accessed via reflection, so it can add those to the native-image).
In theory, sure it can be made to work with VisualVM. But I'd be surprised if it works out of the box.