[php-src] Issue #8203: Ahead of Time Compiler/AOT for PHP8?
| From: | iluuu1994 | Date: | Wed, 16 Mar 2022 08:31:22 +0000 |
| Subject: | [php-src] Issue #8203: Ahead of Time Compiler/AOT for PHP8? | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-240355@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8203
Comment Author: iluuu1994
Hi @appifys!
I think what you're suggesting could make sense (it's also something that gets discussed
frequently internally) but unfortunately it's impossible to tell how much of a difference it
would actually make.
> and many have decided to use Rust over it.
I think it's important to note that even in the best case scenario with all the optimization
and compilation, PHP will likely always be factors slower than C/C++/Rust. It not only comes down to
the type of execution (interpretation of source code, interpretation of opcodes, JIT, etc) but also
how the language is designed and what optimizations are possible.
PHP is very dynamic, that's one of its strengths in terms of usability but also one of its
weaknesses when it comes to performance. The fact that you can defined classes/functions in
if statements or include different version of them from different files makes it
impossible to make any kind of assumptions about their types or behavior. So if our primary goal was
to optimize performance we might also have to tweak the languages behavior to better fit this goal.
Also note that there are some good ways to improve PHPs performance.
* There's approaches like [Roadrunner](https://roadrunner.dev/),
[php-pm](https://github.com/php-pm/php-pm) and the likes which keep workers running to avoid the
cost of bootstraping for each request. The JIT also has better chances of making a difference in
long-standing processes.
* Requires more work, but you can use things like [varnish](https://varnish-cache.org/) to cache
things that don't change between requests