Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24218 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87452 invoked by uid 1010); 26 Jun 2006 11:21:04 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 87437 invoked from network); 26 Jun 2006 11:21:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2006 11:21:04 -0000 X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:12783] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 77/7B-44237-C13CF944 for ; Mon, 26 Jun 2006 07:21:02 -0400 Received: (qmail 6220 invoked from network); 26 Jun 2006 11:20:16 -0000 Received: from internal.zend.office (HELO thinkpad) (10.1.1.1) by internal.zend.office with SMTP; 26 Jun 2006 11:20:16 -0000 To: "'Nuno Lopes'" , "'PHPdev'" Cc: , Date: Mon, 26 Jun 2006 15:20:44 +0400 Message-ID: <000301c69912$94b07090$6e02a8c0@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 Importance: Normal In-Reply-To: <002901c692de$108b2fb0$0100a8c0@pc07653> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 Subject: RE: messing with branch prediction From: dmitry@zend.com ("Dmitry Stogov") References: <002901c692de$108b2fb0$0100a8c0@pc07653> The patch looks good. I already did some experiments with __builtin_expect() in the past, but didn't get any visible speedup. As I understand __builtin_expect() helps only in case if branch is not in BTB and static branch prediction is used. In case if branch instruction was already executed (and didn't go out from BTB), __builtin_expect() has no effect. It just reorders basic-blocks according to static branch prediction algorithm. Thanks. Dmitry. > -----Original Message----- > From: Nuno Lopes [mailto:nlopess@php.net] > Sent: Sunday, June 18, 2006 5:50 PM > To: PHPdev > Cc: andi@php.net; dmitry@php.net > Subject: messing with branch prediction > > > Hello, > > Yesterday I was playing with branch prediction in the Zend VM > executor. > Although I didn't have any noticeable performance improvement > within the > bench.php script, I've put the patch on-line, because someone > else might > want to mess with it too :) (but with care..) > > patch: http://mega.ist.utl.pt/~ncpl/zend_branch_prediction.txt > gcc docs: > http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-g_ > t_005f_005fbuiltin_005fexpect-2440 > > the zend.h part of the patch is based on the similar macros > (with the same > name, too) found in the Linux kernel. > > I made & tested the patch in a Centrino laptop with gcc 3.4, > so it might be > the cause of getting no relevant performance increase. On > CPUs with longer > pipelines (like Pentium 4/NetBurst architecture), the > performance increase > might be noticeable. > > > Happy hacking :) > Nuno > > >