[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code.
From: |
Pip Cet |
Subject: |
Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code. |
Date: |
Thu, 28 Nov 2024 13:53:40 +0000 |
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.
Pip
- Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code.,
Pip Cet <=
- Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code., Eli Zaretskii, 2024/11/28
- Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code., Andrea Corallo, 2024/11/28
- Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code., Mattias Engdegård, 2024/11/28
- Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code., Björn Lindqvist, 2024/11/28
- Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code., Pip Cet, 2024/11/29