unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrea Corallo <acorallo@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Pip Cet <pipcet@protonmail.com>,  emacs-devel@gnu.org
Subject: Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code.
Date: Thu, 28 Nov 2024 09:55:34 -0500	[thread overview]
Message-ID: <yp18qt3if15.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <86ttbrctag.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 28 Nov 2024 16:44:07 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Thu, 28 Nov 2024 13:53:40 +0000
>> Cc: Emacs Devel <emacs-devel@gnu.org>
>> From:  Pip Cet via "Emacs development discussions." <emacs-devel@gnu.org>
>> 
>> On Thursday, November 28th, 2024 at 10:35, Andrea Corallo <acorallo@gnu.org> wrote:
>> 
>> > branch: master
>> > commit b0ba0d42b0fdf70a20cd7a070128db8abe4a0826
>> > Author: Andrea Corallo acorallo@gnu.org
>> > 
>> > Commit: Andrea Corallo acorallo@gnu.org
>> > 
>> > 
>> > * src/lisp.h (EQ): Improve generated code.
>> > 
>> > Outside compilation 'symbols_with_pos_enabled' is always false, so ask
>> > the compiler to organize the most likely execution path in a sequential
>> > fashion in order to favor run-time performance.
>> 
>> Are we officially using __builtin_expect now?
>> 
>> I think that's a major change to the way Emacs C code is written, and a decision which might benefit from further discussion.
>> 
>> To quote the GCC manual:
>> In general, you should prefer to use actual profile feedback for this (-fprofile-arcs), as programmers are notoriously bad at predicting how their programs actually perform.
>> 
>> Maybe we should use __builtin_expect_with_probability instead, in
>> those rare cases when we are certain we're making a correct
>> prediction? Or, my preference, avoid using __builtin_expect
>> entirely, so our scarce resources can be spent on more important
>> issues?
>> 
>> I also don't think the assumption you're telling GCC to make in this specific case (more than 90% of calls to EQ happen while syms_with_pos_enabled == false) is obviously correct.
>> 
>> IIUC, the current master branch won't even compile with a compiler that doesn't handle (or ignore) __builtin_expect.
>
> I think we should us __builtin_expect only when building with GCC,
> indeed.

AFAICS config.h defines __builtin_expect to a nop if the used compiler
does not support it, am I wrong?

  Andrea



  reply	other threads:[~2024-11-28 14:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <173279015204.1017853.4020802222494409378@vcs3.savannah.gnu.org>
     [not found] ` <20241128103552.86CC34F4FDB@vcs3.savannah.gnu.org>
2024-11-28 13:53   ` master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code Pip Cet via Emacs development discussions.
2024-11-28 14:44     ` Eli Zaretskii
2024-11-28 14:55       ` Andrea Corallo [this message]
2024-11-28 15:00         ` Eli Zaretskii
2024-11-28 15:02     ` Andrea Corallo
2024-11-28 17:53     ` Mattias Engdegård
2024-11-28 20:14       ` Pip Cet via Emacs development discussions.
2024-11-28 20:16       ` Eli Zaretskii
2024-11-28 22:46         ` Stefan Kangas
2024-11-29  8:21           ` Andrea Corallo
2024-11-29  1:10       ` Björn Lindqvist

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=yp18qt3if15.fsf@fencepost.gnu.org \
    --to=acorallo@gnu.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=pipcet@protonmail.com \
    /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).