Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84246 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48228 invoked from network); 3 Mar 2015 16:07:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Mar 2015 16:07:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.169 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.217.169 mail-lb0-f169.google.com Received: from [209.85.217.169] ([209.85.217.169:44497] helo=mail-lb0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9E/CE-03783-82CD5F45 for ; Tue, 03 Mar 2015 11:07:06 -0500 Received: by lbiv13 with SMTP id v13so19326531lbi.11 for ; Tue, 03 Mar 2015 08:07:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=eAyBwPr1rAsFWlg/UoIKRLioAuCjOICdnla3ZF+CcwE=; b=sgv0msqArTQjM/wQ0PaP0vUKNa71/O+V6r8JvTHJDw0ZMoTO8IORoqA39KrWsjsxap MIZ4vLimLwK1fA3ZWKPJuVc7fEYniEDi+M/3QMxk/SoM9De+41gec6taGQGbSFLUUdRP isvwm/i3sE+xRLmU1LB4iTjD5A6INGgSK8D5lZrMQqzC2JrAtnkOyKiQ60gV8p/SCLWr DyvO9G1JwlzRTJ3vGJqZZgwHtnluWgLpulXlC1ezPaEldi8qM6qDh7a7CyRZ4hHIevCZ lKi/pfsjRtXkq5YZWgHfqRpsg1asIie6r7Oe5eaXtpjQo7qoelJF3kPrWB435+vWTeov d5mA== MIME-Version: 1.0 X-Received: by 10.112.239.1 with SMTP id vo1mr10272330lbc.110.1425398821953; Tue, 03 Mar 2015 08:07:01 -0800 (PST) Received: by 10.25.43.9 with HTTP; Tue, 3 Mar 2015 08:07:01 -0800 (PST) In-Reply-To: <4ee494ad54939f8147b0038a503b88e8@mail.gmail.com> References: <54F08FF3.3040404@seld.be> <63262a9c0edd51bbf38df2a00c87340e@mail.gmail.com> <9977a20c9d756489f41e666d23c89e3f@mail.gmail.com> <9656140ae786d42e7b0da11dbd416a61@mail.gmail.com> <4ee494ad54939f8147b0038a503b88e8@mail.gmail.com> Date: Tue, 3 Mar 2015 11:07:01 -0500 Message-ID: To: Zeev Suraski Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: Zend JIT Open Sourced From: ircmaxell@gmail.com (Anthony Ferrara) Zeev, On Tue, Mar 3, 2015 at 10:57 AM, Zeev Suraski wrote: >> -----Original Message----- >> From: Anthony Ferrara [mailto:ircmaxell@gmail.com] >> Sent: Tuesday, March 03, 2015 5:44 PM >> To: Zeev Suraski >> Cc: PHP Internals >> Subject: Re: [PHP-DEV] Re: Zend JIT Open Sourced >> >> Zeev, >> >> On Tue, Mar 3, 2015 at 8:05 AM, Zeev Suraski wrote: >> >> So I do apologize to the person. I don't to the code. >> > >> > I wanted to verify whether my gut was correct (minimal amount of >> > output, and stdout is in fact buffered - output shouldn't move the >> > needle) and asked Dmitry to rerun the C test on the same system, but >> > this time with the output code completely commented out: >> > real 0m0.011s (+- 0.01) >> > user 0m0.011s (+- 0.01) >> > sys 0m0.001s >> > >> > Apologies to the code might be in order :) >> > >> > The source of the JIT engine's edge is, as Dmitry and Andi said, the >> > CPU-specific optimizations that gcc -O2 doesn't generate, and >> > therefore it can actually be faster than a generic native executable >> > in some (I would guess not all that common) cases. >> >> So, let's put that to the test, shall we. I compiled and ran the "JIT" >> compiler (can we please stop calling it that, it's not). along side PHP >> 5.5, PHP >> 7 and GCC -O0 through -O3. >> >> I also turned on the ob_start and off (commenting out the ob_start and >> ob_end_flush lines): >> >> https://docs.google.com/spreadsheets/d/1b4yFh0i62haDoQBRf8pOoi63OLr >> xRbecHSj9sQpD5Nk/edit?usp=sharing >> >> With ob_start, the "JIT" was fastest. Without it, it was more than 2x >> slower >> (slightly faster than -O0). >> >> Raw results (average): >> >> GCC -O0: 0.0258 >> GCC -O1: 0.0160 >> GCC -O2: 0.0144 >> GCC -O3: 0.0140 >> "JIT" /w ob_start: 0.011 >> "JIT" /wo ob_start: 0.0238 >> 5.5 /w: 1.273 >> 5.5 /wo: 1.301 >> 7 /w: 1.492 >> 7 /wo: 1.545 >> >> I used identical code to what Dmitry posted earlier, with the one >> exception >> that ob_start was commented out for the "/wo" runs. > > > Anthony, > > What you demonstrate here is that direct output slows PHP down (at least > php-cli), but not that it's the reason that PHP runs faster. > As we don't really care about the output layers when benchmarking > Mandelbrot - but rather at how fast the algorithm is executed, eliminating > output in both tests is the simplest and most accurate to benchmark the raw > performance of the execution engine. And the (very experimental) JIT engine > wins here. It wins on uneven ground. Which was the very initial point that I made. One writes to interactive output within the loop (even if buffered, it's flushed 69 times), and one doesn't. Apples-to-oranges. And the test that I just made proves that. > If you *really* want to test the raw performance difference, get rid of the > output code altogether in both the PHP and C versions. I haven't tried > that, but as I do believe our output buffering code is a lot more > complicated than that of glibc's streams - my guess is that the gap between > the two implementations would actually grow bigger, and in PHP's favor. We > already know that the PHP version with the output (using the output > buffering layer) runs as fast as the C version with no output at all. GCC at -O1 and higher will run in 0 seconds. Because the loop will be dead-code and hence eliminated. It is idempotent (no side effects) and the result of the program doesn't depend on it, so it's eliminated. You'd need to make the computation meaningful with a result that you can return for it to be live code. Anthony