Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52494 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14876 invoked from network); 21 May 2011 20:05:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 May 2011 20:05:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=martynas@venck.us; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=martynas@venck.us; sender-id=unknown Received-SPF: error (pb1.pair.com: domain venck.us from 209.85.161.170 cause and error) X-PHP-List-Original-Sender: martynas@venck.us X-Host-Fingerprint: 209.85.161.170 mail-gx0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:60485] helo=mail-gx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 76/9D-41792-2FA18DD4 for ; Sat, 21 May 2011 16:05:08 -0400 Received: by gxk27 with SMTP id 27so1988693gxk.29 for ; Sat, 21 May 2011 13:05:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.77.39 with SMTP id c27mr939885yhe.209.1306008304110; Sat, 21 May 2011 13:05:04 -0700 (PDT) Received: by 10.147.40.10 with HTTP; Sat, 21 May 2011 13:05:04 -0700 (PDT) X-Originating-IP: [88.118.0.226] In-Reply-To: <4DD748A0.9020004@php.net> References: <4DD63451.10408@zend.com> <4DD748A0.9020004@php.net> Date: Sat, 21 May 2011 23:05:04 +0300 Message-ID: To: Sebastian Bergmann Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] [PATCH] arithmetic speedup From: martynas@venck.us (Martynas Venckus) On 5/21/11, Sebastian Bergmann wrote: > On 05/20/2011 11:28 AM, Dmitry Stogov wrote: >> The bench.php gets more than 10% speedup (2.5 sec instead of 2.9 sec) >> Real-life applications are not affected. All the PHPT tests are passed. > > I chatted with Kore Nordmann, the creator of Image_3D (raytracer written > in PHP) and ezcGraph (chart component in the Zeta Components library) > last night. His code will definitely benefit from these improvements. > > Another performance improvement with regards to math functionality in > PHP could be compiling math functions such as abs() into specialized > opcodes thus alleviating the function call overhead that is otherwise > incurred. Kore mentioned, for example, that Xdebug and KCacheGrind > currently show that most time is spent in several hundred thousand calls > to abs() while running the component's test suite. What platform was that on? GCC already inlines its builtins by default (even at -O0). I.e., the abs() generates the following code: movl -4(%rbp), %eax movl %eax, %edx sarl $31, %edx movl %edx, %eax xorl -4(%rbp), %eax subl %edx, %eax I think it's wrong to do the md inlines in PHP itself for couple reasons: - There's a huge list of such md functions; esp. the fp ones would show bigger benefits. However inlining each one of them is infeasible. - The inlines are platform-dependent, so this would only benefit a few platforms. - It is generally a wrong level to do such optimizations--this is a compiler's job. If your profiling shows that there's a function worth a md inline and compiler doesn't already do that, submit a bug for your compiler vendor. (-;