Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87761 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83562 invoked from network); 17 Aug 2015 10:26:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Aug 2015 10:26:38 -0000 Authentication-Results: pb1.pair.com header.from=php_lists@realplain.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=php_lists@realplain.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain realplain.com from 216.33.127.80 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 216.33.127.80 mta11.charter.net Solaris 10 1203 Received: from [216.33.127.80] ([216.33.127.80:55002] helo=mta11.charter.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A2/00-17888-9D6B1D55 for ; Mon, 17 Aug 2015 06:26:35 -0400 Received: from imp11 ([10.20.200.11]) by mta11.charter.net (InterMail vM.8.01.05.09 201-2260-151-124-20120717) with ESMTP id <20150817102631.PJWK5815.mta11.charter.net@imp11>; Mon, 17 Aug 2015 06:26:31 -0400 Received: from mtaout006.msg.strl.va.charter.net ([68.114.190.31]) by imp11 with smtp.charter.net id 5mSX1r0020h5dSU05mSXU3; Mon, 17 Aug 2015 06:26:31 -0400 Received: from impout003 ([68.114.189.18]) by mtaout006.msg.strl.va.charter.net (InterMail vM.9.00.020.01 201-2473-160) with ESMTP id <20150817102631.WLBY26995.mtaout006.msg.strl.va.charter.net@impout003>; Mon, 17 Aug 2015 05:26:31 -0500 Received: from pc1 ([96.35.251.86]) by impout003 with charter.net id 5mSW1r00J1sc0so01mSWAm; Mon, 17 Aug 2015 05:26:31 -0500 X-Authority-Analysis: v=2.1 cv=Pvkdbm83 c=1 sm=1 tr=0 a=Is5gsZaFXO8aPum+t7Tz+g==:117 a=Is5gsZaFXO8aPum+t7Tz+g==:17 a=hOpmn2quAAAA:8 a=BCPeO_TGAAAA:8 a=8nJEP1OIZ-IA:10 a=mDV3o1hIAAAA:8 a=HS5GgyM8k1LxoI-euJAA:9 a=wPNLvfGTeEIA:10 a=5IfoIgFWIsMA:10 Message-ID: <74E46BF748B74E5388C90AE7AFE9373E@pc1> To: "PHP Internals" Cc: "Dmitry Stogov" Date: Mon, 17 Aug 2015 05:26:30 -0500 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Subject: Marking error, etc. functions as cold? From: php_lists@realplain.com ("Matt Wilmas") 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