From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.devel Subject: Re: Using __builtin_expect (likely/unlikely macros) Date: Sat, 20 Apr 2019 16:29:08 +0100 Message-ID: <86ef5wd7az.fsf@gmail.com> References: <87a7gst973.fsf@gmail.com> <875zrgt12q.fsf@gmail.com> <6919a4c8-df76-ea1e-34db-1fa62a360e5a@cs.ucla.edu> <87h8aykdod.fsf@gmail.com> <4fa7885e-8c66-c7c4-ff71-a013505863af@cs.ucla.edu> <2dfb837d-989d-c736-b6e6-b20c0e940596@cs.ucla.edu> <87o956c4n4.fsf@gmail.com> <1fbd2fca-18f0-0a90-7a45-58419a9e11ee@cs.ucla.edu> <1555450070.23658.4@yandex.ru> <66b74701-012a-902e-4a5b-6bc30efa87c0@cs.ucla.edu> <87tveu85xt.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="234697"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 20 17:37:47 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hHs3l-000yt8-QZ for ged-emacs-devel@m.gmane.org; Sat, 20 Apr 2019 17:37:45 +0200 Original-Received: from localhost ([127.0.0.1]:42561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHs3k-0002aA-RP for ged-emacs-devel@m.gmane.org; Sat, 20 Apr 2019 11:37:44 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHs2y-0002Ki-9o for emacs-devel@gnu.org; Sat, 20 Apr 2019 11:36:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHrvZ-0000ts-UR for emacs-devel@gnu.org; Sat, 20 Apr 2019 11:29:19 -0400 Original-Received: from [195.159.176.226] (port=41488 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHrvZ-0000t2-Nz for emacs-devel@gnu.org; Sat, 20 Apr 2019 11:29:17 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hHrvW-000oec-9q for emacs-devel@gnu.org; Sat, 20 Apr 2019 17:29:14 +0200 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:GCFQ8AlLwTaHq3oa+7R+R8iT0ww= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:235694 Archived-At: On Fri 19 Apr 2019, Paul Eggert wrote: > On 4/19/19 6:45 AM, Alex Gramiak wrote: >> What do you think about marking a few bytecode cases as >> cold/unused? I've attached a diff below that does that. Does it make a >> difference for you on your setup? > > No, it generates the same machine code for me on Fedora 29 x86-64, gcc > 8.3.1 20190223 (Red Hat 8.3.1-2), with gcc -O2. > >> It seems to slow Emacs down a slight >> bit for me, but I was hoping you might know why it would do so. Since >> the newly cold attributes should be unused, is this perhaps a GCC bug? > > Possibly. Or it could be just bad luck. I've often made small changes > and noted slight slowdowns or speedups that are due to luck rather than > any real effects. Sometimes a simple 'make bootstrap' reverses the > slowdown or speedup; sometimes it's more complicated than that. I > suppose it could be related to lucky alignment in executables, or to > code that just happens to exceed the associativity of my L1 or TLB > caches, or whatever. So one must view these performance measurements > with some skepticism. > >>> This patch also adds a convenience macro AVOID for the now-common pattern >>> '_Noreturn ATTRIBUTE_COLD void'. >> I'm not sure about the name. If I wasn't part of this discussion I might >> have thought AVOID meant that one should avoid usage of the procedure in >> new code. Not a big deal, of course. > > Yes, I considered other names but they all had problems too, and AVOID > worked the best for me of the names that I thought of. A mnemonic is > that 'extern AVOID time_overflow (void);' means that execution typically > avoids calling time_overflow. If someone can think of a better name that > would be good. Or we can just get accustomed to AVOID; as you say, it's > not that big a deal. If the patches from this discussion on marking code as cold or liely/unlikely does not result in improved code generation and measureable performance gains, then they should be dropped as needless clutter in the source code. Performance gains are useful, but changes that claim to improve performance should be accompanied by measurements to demonstrate the claimed benefits. Evidence to motivate these changes does not appear convincing. AndyM