Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84248 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53275 invoked from network); 3 Mar 2015 16:32:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Mar 2015 16:32:24 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.212.181 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.212.181 mail-wi0-f181.google.com Received: from [209.85.212.181] ([209.85.212.181:37482] helo=mail-wi0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9A/CF-03783-512E5F45 for ; Tue, 03 Mar 2015 11:32:24 -0500 Received: by wibhm9 with SMTP id hm9so963052wib.2 for ; Tue, 03 Mar 2015 08:32:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc:content-type; bh=jWdIXVz8cw3a0uNfQ9yRBVZOuVcbQZ2Luc5qXcgm27o=; b=SWlqicP7G+tgwTtly4wfmtNJpQHLZ6vMJhnNKyBAAPujPmkd1DvvbMm1QvxKYxJPma DOm+x9vAuf/yjRcYwWl0jMEXhQnSzqVMB2nwcwXjBIIJgyAl/3W4tzzp/WzNvnX+h2TY KcgM3VQbXEwYiB27tFepJ35Nb+Hc/93iok4jhXITsBikdyxqRpsUmcxY9SqlHr1hRB6B cyXqhqtMR/a9hSPE6LPSjvVR99rWASiL51RJmmqtJyB4daSppS1Y2gNRUdDSE1AxTWi+ Rq2bpt/8HqdPMU1CSp6mBu9SAYRDbQ7+R0a7EBMsfIgHCqEx0J8an+GhBIKUhTs7C6KW 94rw== X-Gm-Message-State: ALoCoQk4Vi8nYzFssHJhoqBm21tfqCxpLmtNbPxQDFLa3duCjH3chmR8W3kdgRzW2KN4CpMO3XOp9/m1TWU82IAbdga/E0S85Khu2LZge2uX/vCD1YfDdtj0AAIDqYbADeAL1ltkswKBkxRIdCiKiO+itVEg8f73gg== X-Received: by 10.180.211.235 with SMTP id nf11mr4579525wic.52.1425400338777; Tue, 03 Mar 2015 08:32:18 -0800 (PST) References: <54F08FF3.3040404@seld.be> <63262a9c0edd51bbf38df2a00c87340e@mail.gmail.com> <9977a20c9d756489f41e666d23c89e3f@mail.gmail.com> <9656140ae786d42e7b0da11dbd416a61@mail.gmail.com> <4ee494ad54939f8 147b0038a503b88e8@mail.gmail.com> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQKGyN3KgWG36vID82kvfjRJrrXIyAJK0qX5ATr4h/cC0qV80wNZyGBIAZYUbesBqsedZgIrANg8AZZnn6cCJ35+AQFt/8XUAZZse/8CQ+t/FgJqnzwNAtY2ENQCVACsbgKTp9uGArRUxmiadf2wIA== Date: Tue, 3 Mar 2015 18:32:15 +0200 Message-ID: <73db72094f98cba6adddfda31e43ab4a@mail.gmail.com> To: Anthony Ferrara Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: RE: [PHP-DEV] Re: Zend JIT Open Sourced From: zeev@zend.com (Zeev Suraski) > It wins on uneven ground. Without the output buffering code it's a LOT more uneven, as the PHP version is flushing every byte - approx. 6,000 such flushes. > 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. I don't see how it proves that. Flushing a few dozen times is negligible on 6K of output. You can add ob_end_flush(); ob_start(); on every line to make it 100% equivalent (or hack the SAPI write callback to use fwrite() instead of write(), which would be even more comparable); But I still maintain that saying it's Apples and Oranges is not a very realistic view of things. Both versions are buffered. Without the output buffering code - the PHP version would be *completely* unbuffered when run in CLI mode, which is why it was added in the first place. The C version is also buffered - a touch less than the PHP version - but using a much simpler buffering system (glibc streams, vs. our much more complex multi-layer output buffering system) and therefore probably at least slightly faster. Of course, adding 'full' output buffering to the C version (that would also buffer newlines) is way beyond the scope of such a simple test. The two versions are very much comparable, and are the reasonable implementations one would use without giving one platform or the other an unfair advantage or disadvantage (as removing the ob_() calls does, given that CLI uses unbuffered write()'s). It's perhaps the difference between a 200gr apple and a 205gr apple, but certainly not apples and oranges, and it's absolutely not the reason for why the PHP JIT version was faster. > > 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. So just get rid of the newline prints, but keep everything else. That means zero flushing, full buffering for the C version. How fast does that run? Zeev