unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andy Moreton <andrewjmoreton@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: Using __builtin_expect (likely/unlikely macros)
Date: Sat, 20 Apr 2019 16:29:08 +0100	[thread overview]
Message-ID: <86ef5wd7az.fsf@gmail.com> (raw)
In-Reply-To: d7fd760a-4310-883d-ff6b-e8872b232255@cs.ucla.edu

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




  parent reply	other threads:[~2019-04-20 15:29 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-15  0:15 Using __builtin_expect (likely/unlikely macros) Alex Gramiak
2019-04-15  1:18 ` Paul Eggert
2019-04-15  3:11   ` Alex Gramiak
2019-04-15  4:41     ` Paul Eggert
2019-04-16  0:16       ` Alex Gramiak
2019-04-16  2:34         ` Eli Zaretskii
2019-04-16  5:33           ` Alex Gramiak
2019-04-16 15:23             ` Eli Zaretskii
2019-04-16 15:47               ` Alex Gramiak
2019-04-16  3:42         ` Paul Eggert
2019-04-16 13:05           ` Stefan Monnier
2019-04-16 15:22             ` Paul Eggert
2019-04-16 16:10               ` Alex Gramiak
2019-04-16 17:54                 ` Paul Eggert
2019-04-16 20:50                   ` Alex Gramiak
2019-04-16 21:11                     ` Alex Gramiak
2019-04-16 21:27                     ` Stefan Monnier
2019-04-16 21:27                     ` Konstantin Kharlamov
2019-04-18  8:25                       ` Paul Eggert
2019-04-18  8:43                         ` Konstantin Kharlamov
2019-04-18 13:47                         ` Andy Moreton
2019-04-18 17:27                           ` Paul Eggert
2019-04-18 17:56                             ` Andy Moreton
2019-04-18 19:32                               ` Paul Eggert
2019-04-19 13:45                         ` Alex Gramiak
2019-04-19 13:58                           ` Konstantin Kharlamov
2019-04-19 14:45                             ` Alex Gramiak
2019-04-19 17:33                           ` Paul Eggert
2019-04-19 20:53                             ` Alex Gramiak
2019-04-20  0:05                               ` Alan Mackenzie
2019-04-20  0:42                                 ` Paul Eggert
2019-04-20 19:46                                   ` Alan Mackenzie
2019-04-20 15:29                             ` Andy Moreton [this message]
2019-04-20 15:57                               ` Paul Eggert
2019-04-20 16:03                                 ` Eli Zaretskii
2019-04-20 16:11                                   ` Paul Eggert
2019-04-20 16:18                                     ` Eli Zaretskii
2019-04-20 16:57                                       ` Paul Eggert
2019-04-20 17:22                                         ` Eli Zaretskii
2019-04-20 19:13                                           ` Paul Eggert
2019-04-20 16:28                                 ` Óscar Fuentes
2019-04-20 18:58                                   ` Paul Eggert
2019-04-20 19:35                                     ` Óscar Fuentes
2019-04-20 22:54                                       ` Paul Eggert
2020-04-15  3:14   ` John Carter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86ef5wd7az.fsf@gmail.com \
    --to=andrewjmoreton@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).