hi!
On Mon, May 5, 2014 at 3:07 PM, Dmitry Stogov <[email protected]> wrote:
> For people who know me it's not a secret that PHP performance is my main
> responsibility and passion at Zend. Actually, starting from PHP 5.0 we
> already made 6 times speedup on synthetic benchmarks and about 2 times
> speedup on real-life applications. We endlessly made improvements in PHP
> engine and OPCache. However, by PHP 5.5 release we weren’t be able to make
> any serious progress, and among other things started to experiment with
> memory managers, JIT technologies and other potential ideas.
>
> I spent a significant amount of time experimenting with JIT, and even
> created a PoC of transparent LLVM based JIT compiler embedded into OPCache.
> The results on bench.php was just amazing – (0.219 seconds against 2.175 – *10
> times speedup of PHP 5.5*), but on real-life apps we got just few percent
> speedup. This made us look much deeper into some of the runtime
> characteristics and what was truly the bottleneck to making more
> substantial progress. It was clear the VM is already highly optimized, but
> works with data structures that require endless memory allocation,
> deallocation and reference counting. Typical real-life PHP application
> spends about 20% of the CPU time in memory manager, 10% doing hash tables
> operations, 30% in internal functions and only 30% in VM. Of course, we
> tried to JIT only VM code and in most cases it had to perform the same
> memory allocations. So we decided to change focus and work on the big
> bottlenecks. The idea was to change our data types to minimize heap
> allocations. This was a very difficult decision because we had to start
> with a huge refactoring, and we had no idea whether it’s going to have any
> impact or not.
>
> Now I'm glad to present you a result of our recent four month work. It's a
> refactoring of the PHP engine that significantly improves performance,
> memory usage and builds a foundation for a lot more future performance
> improvements incl. JIT. I'll avoid technical details (more details will be
> published at *http://wiki.php.net/phpng <http://wiki.php.net/phpng>*), but
> in few words - we changed the basement trying to keep most of the building
> unchanged. Right now the new engine already makes *10-30% speedup of
> php*not only on benchmarks but on real-life applications as well!
>
> *Some benchmarks we ran so far:*
>
> Wordpress 3.6 – 20.0% gain (253 vs 211 req/sec)
>
> Drupal 6.1 – 11.7% gain (1770 vs 1585 req/sec
>
> Qdig – 15.3% gain (555 vs 482 req/sec)
>
> ZF test app – 30.5% gain (217 vs 166 req/sec)
>
> On some apps we show better results than other PHP implementations. It will
> be great if others here could test this on their apps and compare to their
> existing PHP version to get additional results.
>
> The re-factoring is not finished yet as the focus was to first test whether
> this effort would deliver results. Not all extensions are supported, some
> tests are failing, and we also have more ideas for additional improvement..
>
> But we feel, we’ve proven enough out to open it up for review, feedback
> and assistance, and wanted to involve the community as soon as we managed
> to get on a promising direction. There’s more work to do in finishing
> support of all extensions and continue to make some additional engine
> improvements.
It is an awesome step moving forward, thanks to everyone involved in
this work! I will see how fast we can integrate this branch in our
tests.
> Please try the refactored PHP engine and provide feedback re: performance,
> memory usage and any issues that come up. You may find it in *phpng* branch
> at *php.net <http://php.net>*. Some instructions may be
> found at
> *http://wiki.php.net/phpng
> <http://wiki.php.net/phpng>*. As mentioned, there
> are some missing
> extensions so not everything will run.
Could you move these pages (this one and the internal one) either to
/draft or /rfc please? the latter makes more sense
However I suppose basic windows tests are missing, as well as TS
sapis, right? Is it at least supposed to work in TS mode, by design?
Or should we expect some major issues?
> I would like to say many thanks to Xinchen and Nikita who made significant
> part of presented work.
>
> I think that this engine can make the new major version of PHP we’re
> talking about a lot more interesting.
Do I understand correctly that you target php 6 for these changes, right?
Also one thing is totally missing, and is also caused by something
that becomes a common case, the 64bit support as it should be has been
totally ignored. That makes Anatol work to keep the 64bit branch
almost useless. My take on it is that we should either:
- move your patch to this branch and then merge to master
- merge the 64bit branche then this patch
That being said, I am not sure what requires less effort but I do not
feel comfortable to scratch the 64bit branch and begins from almost
zero.
There is something that we have to improve, drastically,
communication. Such major changes, developed (and still being worked
on) should pop up in the list and in the radar of other developers
much earlier in the process. For two critical reasons:
1. Avoid work conflicts, be for similar features/changes or other
areas being deadly affected by such changes
2. Increase visibility, feedback and cooperations. The earlier other
developers are involved the better it is to get more people involved
in the engine development and maintenance.
I am not sure how to change that or make developers being more open
and stopped hidden developments. Any ideas or thoughts on this topic
are welcome. It is critical and vital for php, a must do.
Cheers,
--
Pierre
@pierrejoye | http://www.libgd.org