emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using __builtin_expect (likely/unlikely macros)


From: Paul Eggert
Subject: Re: Using __builtin_expect (likely/unlikely macros)
Date: Fri, 19 Apr 2019 10:33:43 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]