Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73888 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93129 invoked from network); 5 May 2014 13:07:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 May 2014 13:07:49 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain zend.com from 74.125.82.49 cause and error) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 74.125.82.49 mail-wg0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:51549] helo=mail-wg0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/C0-23541-32D87635 for ; Mon, 05 May 2014 09:07:48 -0400 Received: by mail-wg0-f49.google.com with SMTP id m15so2114985wgh.8 for ; Mon, 05 May 2014 06:07:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=Le6UZHaDfcznomf21xX17oJ3K2gVfchGZX/qhUPhNBE=; b=TCMDtLaYaJq6ITC5hRUHNcGipJsd4s7yYX91dC8JxLozjCjZQ3xdrOadSCnnXQMMOo 2v9nNIUFz+csK9NiNekLthqxNFLf+b2qf8UTRLg7Rom82Uf7VzJfOtnFZXBeqjq81iUJ Wsv4e8QN+rHySVqTZ8DYkgL60qHOgNtn+uRDnVcEX+06ffxGmCzTRFEeYCZ7mDLsF9fP TO6eFqSp4blCUR9/C25tyvqz/cApolIgq4HVgWw7MA5df5Jfewsn08kSIS6koNyN1RKY 0K7gjppt5nAiffXhcr/LEZCkpzCVTnIklogK0OoT2MJswDhndG75Cu0lPqy4DEYXCmiY 0o5g== X-Gm-Message-State: ALoCoQnxVOKYRVxV71ikEXqqw6hlkhYrZBKE2AU7saOm6dCh0QHsS1mY+R9EonsL+/XTARftDnah+gfCbXAHkcowW3KkJVxfeeTJqtWU/pKdjVSLjKyX4RuJor9/7a2p+mcX580oNMdg MIME-Version: 1.0 X-Received: by 10.180.78.225 with SMTP id e1mr15893085wix.17.1399295264308; Mon, 05 May 2014 06:07:44 -0700 (PDT) Received: by 10.227.57.133 with HTTP; Mon, 5 May 2014 06:07:44 -0700 (PDT) Date: Mon, 5 May 2014 17:07:44 +0400 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary=f46d043c08642a5a7d04f8a6d170 Subject: =?UTF-8?Q?phpng=3A_=04Refactored_PHP_Engine_with_Big_Performance_I?= =?UTF-8?Q?mprovement?= From: dmitry@zend.com (Dmitry Stogov) --f46d043c08642a5a7d04f8a6d170 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=E2=80=99t 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 =E2=80=93 (0.219 seconds against = 2.175 =E2=80=93 *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=E2=80=99s going to h= ave 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 *), 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 =E2=80=93 20.0% gain (253 vs 211 req/sec) Drupal 6.1 =E2=80=93 11.7% gain (1770 vs 1585 req/sec Qdig =E2=80=93 15.3% gain (555 vs 482 req/sec) ZF test app =E2=80=93 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 =04we feel, we=E2=80=99ve proven enough out to open it up for review, f= eedback and assistance, and wanted to involve the community as soon as we managed to get on a promising direction. There=E2=80=99s more work to do in finishi= ng support of all extensions and continue to make some additional engine improvements. =05Please try the refactored PHP engine and provide feedback re: performanc= e, memory usage and any issues that come up. You may find it in *phpng* branch at *php.net *. Some instructions may be found at *http://wiki.php.net/phpng *. As mentioned, there are some missing extensions so not everything will run. 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=E2=80=99r= e talking about a lot more interesting. Thanks. Dmitry. --f46d043c08642a5a7d04f8a6d170--