Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87062 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79028 invoked from network); 7 Jul 2015 07:22:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Jul 2015 07:22:51 -0000 Authentication-Results: pb1.pair.com header.from=php_lists@realplain.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php_lists@realplain.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain realplain.com from 216.33.127.82 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 216.33.127.82 mta31.charter.net Solaris 10 1203 Received: from [216.33.127.82] ([216.33.127.82:63970] helo=mta31.charter.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E8/81-48168-84E7B955 for ; Tue, 07 Jul 2015 03:22:50 -0400 Received: from imp09 ([10.20.200.9]) by mta31.charter.net (InterMail vM.8.01.05.02 201-2260-151-103-20110920) with ESMTP id <20150707072245.BYQD10321.mta31.charter.net@imp09>; Tue, 7 Jul 2015 03:22:45 -0400 Received: from mtaout004.msg.strl.va.charter.net ([68.114.190.29]) by imp09 with smtp.charter.net id pKNl1q0050eWGlw05KNlF1; Tue, 07 Jul 2015 03:22:45 -0400 Received: from impout001 ([68.114.189.16]) by mtaout004.msg.strl.va.charter.net (InterMail vM.9.00.018.00 201-2473-150) with ESMTP id <20150707072245.FXHZ30634.mtaout004.msg.strl.va.charter.net@impout001>; Tue, 7 Jul 2015 02:22:45 -0500 Received: from pc1 ([96.35.251.86]) by impout001 with charter.net id pKNl1q0091sc0so01KNltj; Tue, 07 Jul 2015 02:22:45 -0500 X-Authority-Analysis: v=2.1 cv=R/mNGLhX c=1 sm=1 tr=0 a=Is5gsZaFXO8aPum+t7Tz+g==:117 a=Is5gsZaFXO8aPum+t7Tz+g==:17 a=hOpmn2quAAAA:8 a=t0KHGDoOaRkA:10 a=BCPeO_TGAAAA:8 a=N659UExz7-8A:10 a=VvTL7LNR1D2srYcpZrgA:9 a=pILNOxqGKmIA:10 Message-ID: To: "PHP Internals" , "Dmitry Stogov" Cc: "Ferenc Kovacs" , "Yasuo Ohgaki" References: <051CB45EE4B24C7C88C3EABC7E8EE0A2@pc1> Date: Tue, 7 Jul 2015 02:22:45 -0500 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Subject: Re: [PHP-DEV] Move to Fast ZPP? From: php_lists@realplain.com ("Matt Wilmas") Hi again Dmitry, all, ----- Original Message ----- From: "Dmitry Stogov" Sent: Monday, June 29, 2015 > On Sat, Jun 27, 2015 at 12:36 AM, Matt Wilmas > wrote: > >> Hi Dmitry, all, >> >> [...] >> >> Yeah, I knew how the traditional ZPP worked, just wondered about any >> certain "problem area." :-) But it seems it's just the whole thing, so >> much it's doing, besides just the "string format interpretation." >> >> First, only fractions of a % old ZPP is using on WordPress now? That >> doesn't make sense to me... On fast_zpp wiki page, you said last year it >> was taking ~6% of time on Wordpress (before FAST_ZPP, of course). And >> changing key/hot functions to FAST_ZPP saved ~2.5% time. So that should >> have left a few percent of time used by traditional ZPP. >> >> But everything else has gotten faster since then, so therefore, for an >> unchanged old ZPP, its percentage contribution should have gone up? >> Well, >> anyway... >> >> I went ahead and tried implementing my idea (had been awhile since I >> really looked at the FAST_ZPP stuff, and didn't realize it was as simple >> to >> work from). :-) >> >> It uses the same syntax as "FAST_ZPP" (if we/others like/prefer that) and >> a zend_FAST_parse_parameters() function. Code size should be about same >> as >> before, maybe a few more bytes depending on instructions needed (still >> thinking/adjusting). >> >> It seems to have pretty good performance increase! BTW, in quick >> testing, >> I don't see old ZPP using 90% of time even with empty/dummy function. >> Just >> about 50% (with or without ZTS)... >> >> I didn't know how close we could get to the inlined FAST_ZPP, but it >> seems >> the majority of the way there: ~70% in the simple case. (To be clear, 3x >> faster than old.) This was on Windows XP with ancient VC9. >> >> I don't have a patch ready for you to look at yet, since I didn't finish >> changing the macros, etc. >> >> It would be awesome if this could start being used throughout the >> codebase, and not just functions with preferential treatment. :-P Maybe >> you'd even switch back from the inlined version in some places, if >> smaller >> code would be better. >> > > Send you implementation as soon as it's ready. I'll test it. Just an update... I didn't abandon this; quite the opposite! I thought I'd just put the finishing touches on my implementation and have it to you almost a week ago. After my rough initial test version, I made some obvious, simple changes to reduce instructions/code size (slightly). And then analyzing different stuff with GCC and MSVC to see if it could be improved more (not really since fairly straightforward), etc... ~5 days ago when I was done messing and changed the macros to recompile the existing FAST_ZPP parts, I didn't know what the size difference would be vs no FAST_ZPP (traditional). I had overestimated the savings ("maybe a few more bytes" for instructions). It was in the 30-45% range of your inlined version. I made a change to save instructions, but, strangely, it didn't really have the effect on size I thought it would. :-/ BTW, the improvement on Linux with GCC 4.8 was about the same: ~70% of inlined. So roughly ~2/3 speed for ~1/3 space. I also finally installed Valgrind and used Callgrind for the first time. Simple. :^) About same relative reduction in instructions. I really wanted the code size to be smaller if this could get widespread use, and started wondering, "What if...?", "How?", "Why not?", "But..." Then I had a new idea, but wasn't sure what the compilers would do with it. So I spent Sunday prototyping a couple key parts of it outside of PHP. GCC can make a HUGE mess of it, but easily worked around. So it looks good, even better than the ideal I had imagined. Now I just have to do it for PHP... This way saves the lea instructions for each &dest variable (like the inline version), and then some. And just earlier I realized there's a way to save the other instructions (while using the same macro syntax), which would also apply to the previous implementation. So ideally, this means at the CALL site, we should be able to have the zend_fast_parse_... function call: Just mov+mov+lea+call on 64-bit, and that's it. The rest of the stuff (a good amount) can be COMPLETELY optimized away! :-O And in the parse_... function, compared to the *inline* FAST_ZPP, that should get it down to about 3 dozen more instructions per parameter: while + switch + checks in zend_parse_arg_* that would get optimized away when inlined. Well, I'll send the implementation(s) for you to test as soon as I can! > Thanks. Dmitry. - Matt