1

I am using https://www.emacswiki.org/emacs/GccEmacs :

GccEmacs refers to the --with-native-compilation configuration option when building Emacs, which adds support for compiling EmacsLisp to native code using libgccjit. All of the Elisp packages shipped with Emacs are native-compiled, providing a noticeable performance improvement out-of-the-box. Third-party packages are also compiled to achieve further performance improvements.

The way I installed emacs, please note that -b feature/native-comp flag is mentioned in https://akrl.sdf.org/gccemacs.html#orgf5ebdd1:

# git clone git://git.savannah.gnu.org/emacs.git  # for the master branch
git clone git://git.savannah.gnu.org/emacs.git -b feature/native-comp
cd emacs
./autogen.sh
./configure --with-native-compilation CPPFLAGS='-fgnu89-inline' \
            --with-x-toolkit=no --with-xml2 --with-jpeg=ifavailable \
            --with-tiff=ifavailable --with-gnutls=ifavailable --with-mailutils
make -j$(nproc)
sudo mkdir -p /opt/ss
sudo rm -f /opt/ss/*
sudo ln -s ~/tools/emacs/lib-src/emacsclient /opt/ss/
sudo ln -s ~/tools/emacs/src/emacs /opt/ss/
$ emacs --version
GNU Emacs 29.0.50

I have following lines related to native-compile in my config file:

(setq native-comp-deferred-compilation t)
(setq package-native-compile t)
(setq comp-async-report-warnings-errors nil)

When I start my emacs server in the *Async-native-compile-log* buffer I keep seeing following compilation log, compilation takes around 2-3 minutes:

Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/bytecomp.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/byte-opt.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/subr-x.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/gv.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/help-mode.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/cl-macs.el’ newer than byte-compiled file; using older file
Compiling /home/alper/tools/emacs/lisp/emacs-lisp/seq.el...
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/bytecomp.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/byte-opt.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/subr-x.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/gv.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/help-mode.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/cl-macs.el’ newer than byte-compiled file; using older file
Compiling /home/alper/tools/emacs/lisp/emacs-lisp/bytecomp.el...
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/bytecomp.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/byte-opt.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/subr-x.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/gv.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/help-mode.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/cl-macs.el’ newer than byte-compiled file; using older file
Compiling /home/alper/tools/emacs/lisp/emacs-lisp/byte-opt.el...
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/bytecomp.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/byte-opt.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/subr-x.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/gv.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/help-mode.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/cl-macs.el’ newer than byte-compiled file; using older file
Compiling /home/alper/tools/emacs/lisp/emacs-lisp/subr-x.el...
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/bytecomp.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/byte-opt.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/subr-x.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/gv.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/help-mode.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/cl-macs.el’ newer than byte-compiled file; using older file
Compiling /home/alper/tools/emacs/lisp/emacs-lisp/gv.el...
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/bytecomp.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/byte-opt.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/subr-x.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/gv.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/help-mode.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/cl-macs.el’ newer than byte-compiled file; using older file
Compiling /home/alper/tools/emacs/lisp/url/url-vars.el...

// ... many more ...

Compiling /home/alper/.emacs.d/elpa/flycheck-pycheckers-20211122.235/flycheck-pycheckers.el...
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/bytecomp.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/byte-opt.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/subr-x.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/seq.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/gv.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/help-mode.el’ newer than byte-compiled file; using older file
Source file ‘/home/alper/tools/emacs/lisp/emacs-lisp/cl-macs.el’ newer than byte-compiled file; using older file
Compiling /home/alper/tools/emacs/lisp/dired-x.el...
Compilation finished.

I don't understand why does it consumes around 100% cpu on the background since compilation already done on the previous session. Which makes intances that has 1 GiB Memory halts.

enter image description here

Is this a normal behavior? Is there any way to make this process without consuming high cpu?

Observation: When I try to use GccEmacs for performance improvement in a free-tier Google Instance, which requires 1 CPUs and 1 GiB memory. Due to startup compilation gccemacs frozes the complete instance.

alper
  • 1,238
  • 11
  • 30
  • `-b feature/native-comp` is *not* what your linked EmacsWiki page says. – phils Mar 10 '22 at 12:21
  • "I don't understand why does it consumes around 100% cpu on the background since compilation already done on the previous session." -- look at the native compilation log buffer to see what it is doing (which will undoubtedly be compiling your config). – phils Mar 10 '22 at 12:22
  • @phils When I dig in in the page (https://akrl.sdf.org/gccemacs.html#orgf5ebdd1), they recommended `-b feature/native-comp` // updated on my answer. Will it compile everytime when I start the emacs server? I thought it should start right away from the already compiled files – alper Mar 10 '22 at 15:30
  • That entry is dated "2021-02-26 Fri" which is more than a year ago. The feature was merged to `master` and from there to `emacs-28` where it will be released. There is literally no development happening on the old branch. – phils Mar 10 '22 at 21:29
  • Compiling Emacs itself doesn't touch (or even know about) your config. Compiling your config happens over time, once you've started using the new build (and of course in the future too, if you update something). Again, just look at the native compilation log buffer -- you will see what's happening. – phils Mar 10 '22 at 21:31
  • You need to recompile from the `emacs-28` branch before doing anything else, though. – phils Mar 10 '22 at 21:35
  • Ok so instead of compiling from `master` or `feature/native-comp` branch of `git clone git://git.savannah.gnu.org/emacs.git` // I should checkout into emacs-28 doing: `git checkout emacs-28.0.91` and apply the `./autogen.sh && ./configure --with-native-compilation ... `, right? – alper Mar 10 '22 at 22:05
  • But as I understand, even if recompiling from `emacs-28`, it won't stop the startup compiling – alper Mar 10 '22 at 22:09
  • `git checkout emacs-28` unless you particularly don't want changes since 28.0.91. Otherwise yes, that's correct. This will give you *almost a year's worth of bug fixes to native-compilation*, so I suggest you test it. – phils Mar 10 '22 at 22:14
  • Is `emacs-28` recommended over latest master branch? – alper Mar 10 '22 at 23:18
  • 1
    Yes. master is unstable; emacs-28 is close to a stable release. – phils Mar 10 '22 at 23:40

0 Answers0