unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Arash Esbati <arash@gnu.org>
To: 65988@debbugs.gnu.org
Subject: bug#65988: 30.0.50; Emacs and -O3 compiler optimization
Date: Fri, 15 Sep 2023 11:22:36 +0200	[thread overview]
Message-ID: <86bke36bab.fsf@gnu.org> (raw)

Hi all,

in this message[1], Eli explained why the -O3 optimization switch isn't
recommended when building Emacs:

  In a nutshell, it bloats the code (due to excessive inlining), with no
  real effect on speed.  The inner loops in Emacs are very large, and
  thus the techniques used by -O3 to speed up code (loop unrolling etc.)
  don't really work.  Moreover, they could make things worse because the
  larger loops might no longer fit into the L1 cache of the CPU.

  The -O3 is well suited to speed up relatively simple algorithms with
  tight loops.  Emacs has very few of those, in the places that matter
  for observable performance.

Presuming that the note above applies to GCC on all platforms, I suggest
to change/adjust the following example in INSTALL[2]:

  Here's an example of a 'configure' invocation, assuming a Bourne-like
  shell such as Bash, which uses these variables:

    ./configure \
      CPPFLAGS='-I/foo/myinclude' LDFLAGS='-L/bar/mylib' \
      CFLAGS='-O3' LIBS='-lfoo -lbar'

  (this is all one shell command).  This tells 'configure' to instruct the
  preprocessor to look in the '/foo/myinclude' directory for header
  files (in addition to the standard directories), instruct the linker
  to look in '/bar/mylib' for libraries, pass the -O3 optimization
  switch to the compiler, and link against libfoo and libbar
  libraries in addition to the standard ones.

IIRC this was the place where I picked up the -O3 switch for the script
I wrote for building Emacs.

Best, Arash

Footnotes:
[1]  https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-06/msg01274.html

[2]  http://git.savannah.gnu.org/cgit/emacs.git/tree/INSTALL#n493





             reply	other threads:[~2023-09-15  9:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15  9:22 Arash Esbati [this message]
2023-09-15 11:29 ` bug#65988: 30.0.50; Emacs and -O3 compiler optimization Eli Zaretskii

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=86bke36bab.fsf@gnu.org \
    --to=arash@gnu.org \
    --cc=65988@debbugs.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).