unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Óscar Fuentes" <ofv@wanadoo.es>
To: emacs-devel@gnu.org
Subject: Re: Using __builtin_expect (likely/unlikely macros)
Date: Sat, 20 Apr 2019 21:35:47 +0200	[thread overview]
Message-ID: <87zhoko4fg.fsf@telefonica.net> (raw)
In-Reply-To: d6e68957-1b62-47c5-fab8-f79545707388@cs.ucla.edu

Paul Eggert <eggert@cs.ucla.edu> writes:

> Óscar Fuentes wrote:
>>> For improvements where the
>>> generated code is "obviously" faster (fewer and simpler instructions,
>>> say), I typically don't bother with measurements as my own time is
>>> limited too.
>> You will be surprised.
>>
>> Modern hardware is complex.
>
> I'm often surprised :-), but I don't expect to be surprised when the
> generated code seems obviously faster to me. Although I'm not as
> expert as the computer architecture researcher whose office sits next
> to mine, I know how modern hardware works reasonably well and
> regularly give lectures on topics like μops and TLBs so I won't be
> surprised as often as a naive programmer might be.

I served many years as an Assembler programmer replacing C code where it
was considered too slow so, excuse my arrogance, I'm far from being a
naive programmer.

I've seen many times cases where removing code (deleting unnecessary
instructions and even full procedure calls) made the program run
noticeably slower. "noticeably" as in "you don't need a stopwatch to
notice it".

Also, I've seen plenty of speedups on my development machine that
vanished or even reversed when tried on a different microarchitecture,
or the same microarchitecture with different cache sizes, or even the
same CPU with different RAM modules.

On our time of multi-level caches, branch prediction, speculative
execution and what-not, acting as if your hard-earned 1% speedup will
apply to most machines out there is a risky bet.

>> If the 1.3% improvement in performance requires non-minimal source
>> code complexity growth
>
> It doesn't. In this case the source code shrank slightly. Only very
> slightly: just by 0.001% (this counts all files under Git control).
> Still, a win's a win.

Yea, but now everybody has to learn about and, worse, deal with those
non-standard macros. That's added complexity. And I'm pretty sure that
the speedup will vanish as code is modified and compilers and CPUs
change.




  reply	other threads:[~2019-04-20 19:35 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
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 [this message]
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=87zhoko4fg.fsf@telefonica.net \
    --to=ofv@wanadoo.es \
    --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).