Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87765 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5748 invoked from network); 17 Aug 2015 11:38:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Aug 2015 11:38:38 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.213.175 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.213.175 mail-ig0-f175.google.com Received: from [209.85.213.175] ([209.85.213.175:37556] helo=mail-ig0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8D/00-05177-CB7C1D55 for ; Mon, 17 Aug 2015 07:38:37 -0400 Received: by igui7 with SMTP id i7so52797448igu.0 for ; Mon, 17 Aug 2015 04:38:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=bIorCdB/W1gQpNlyi4r6Oyv6QD683Hyg4DFgfrCqHU8=; b=Q0dmFboFaRLbhGBbt7fRZM1Ajpk2suWbgt7sgy+Jl1cjASxKc2Ax2gpUs3tPQLzNIS XH9zXYyfXWAgEK84hgsQtPjvhOL6Pt1QQTfdGXRJgWF5GfU5nrj9JwwwqN3H2hf7KEms AL0Kj5gpwXUOsKWWDTTx80UXy7nivfAaKedFsaSTSKvJB0tTQrIQFD2cbcGGaHpjjeBJ wpCCxK0NRKSRXQyBxuK7CSiIkLQ9FNmGauCtk1tKn54H7qI8ZB9WQ9N0Qy+iGs6rqws3 wZHyZOKNm+c46mREmk5qZa9dIMXqgZ4eLKxSOqp25ZVLsc1fjHAHCZfJ2S8Ees3n2WgZ tB4A== X-Gm-Message-State: ALoCoQk9sifv17cUzVw32tEtR/LCuXQgJXw+gIrdLUUZuSBS4NEuqio8hBVpXZXL0zMq++BnSHpkrasUyWrihTZ77B4cchcGPbzw8Ff+shb7BxlnmUJXiXg5x1XtXOAhZpXmkjDk7ukcqRnGQc2yzbWJVyeanHoKZKj2FSQ/Jf+qLj6MWEg4FtI= MIME-Version: 1.0 X-Received: by 10.50.20.228 with SMTP id q4mr7442092ige.3.1439811513571; Mon, 17 Aug 2015 04:38:33 -0700 (PDT) Received: by 10.50.35.101 with HTTP; Mon, 17 Aug 2015 04:38:33 -0700 (PDT) In-Reply-To: <74E46BF748B74E5388C90AE7AFE9373E@pc1> References: <74E46BF748B74E5388C90AE7AFE9373E@pc1> Date: Mon, 17 Aug 2015 14:38:33 +0300 Message-ID: To: Matt Wilmas Cc: PHP Internals Content-Type: multipart/alternative; boundary=047d7bd757c4cf8950051d803d0f Subject: Re: Marking error, etc. functions as cold? From: dmitry@zend.com (Dmitry Stogov) --047d7bd757c4cf8950051d803d0f Content-Type: text/plain; charset=UTF-8 This is good idea. Some times ago I played with "hot" attribute, and didn't get any improvement, but we really may get something with "cold". Thanks. Dmitry. On Mon, Aug 17, 2015 at 1:26 PM, Matt Wilmas wrote: > Hi Dmitry, all, > > Has it been considered to use __attribute__((cold)) on, for example, > error-type functions? I happened to notice this part about it in the GCC > docs [1] a couple days ago: "The paths leading to calls of cold functions > within code are marked as unlikely by the branch prediction mechanism." > > A while ago I figured that, technically, many if () conditions for errors > could use UNEXPECTED(), but that would be overkill for each possible tiny > advantage. But that sort of happens automatically for conditions leading > to "cold" functions! :^) > > I was thinking of widely-used functions like php_error_docref*, zend_error > (and related); also noticed exception/throwing functions, or even > zend_accel_error in opcache. > > I didn't do any profiling, just simply tried marking *only* > php_error_docref0 cold. With GCC 4.8, it reduced the size by almost 4 KB > (-O2, --disable-all CLI). And checking through the code, it did indeed > move the calls around (e.g. out of fast path) in many cases compared to > default (some cases didn't optimize more). > > Looks like more zend_error calls in VM that aren't already part of > UNEXPECTED() conditions could be moved "out of the way" if marked cold... > > [1] https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html > > Thoughts? > > > Thanks, > Matt > --047d7bd757c4cf8950051d803d0f--