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: John Carter
Subject: Re: Using __builtin_expect (likely/unlikely macros)
Date: Wed, 15 Apr 2020 15:14:19 +1200

As a small datapoint I recently converted the largish (about 2megasloc) code base I maintain to using likely/unlikely.

I have been very pleasantly surprised by how much more readable it made the __builtin's..

And then surprised again by how much more readable it makes code in general.

I now occasionally add them to my code, not so much as an optimization hint, but as documentation to indicate the expected "Happy Path".

In fact, so much so, I find interesting those cases where I consider it.... and then say, meh, I don't know which path is more likely...



On Mon, Apr 15, 2019 at 1:19 PM Paul Eggert <address@hidden> wrote:
Alex Gramiak wrote:
> the likely/unlikely
> macros are a nice way to indicate that a branch is exceedingly
> rare/common.

The cost (in making the C code harder to read, write and maintain) so often
exceeds that benefit that I'd rather avoid these macros unless there's a good
performance case for putting them in.



--
John Carter
Phone : (64)(3) 358 6639
Tait Electronics                        
PO Box 1645 Christchurch
New Zealand



This Communication is Confidential. We only send and receive email on the
basis of the terms set out at www.taitradio.com/email_disclaimer


reply via email to

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