Subject: bug#76505: 31.0.50; igc: M-x project-compile is slow

From: Pip Cet <[email-masked]>
Date: Sun, 23 Feb 2025 16:08:04 +0000

"Ihor Radchenko" <[email-masked]> writes:

> Hi,
>
> After running Emacs for a few days (no crashes!), I noticed significant
> hangs when running compilation.

Thanks for the report, we're very interested in cases where feature/igc
becomes unusable (less usable) in large sessions!

> The perf data is silent, but Emacs becomes unresponsive right at the
> beginning of compilations and sometimes in the middle, as the
> compilation buffer is filled.
>
> Any suggestions, ideas?

Many!  First, may I ask you to save a core file (attach gdb, "gcore",
shouldn't destroy the session) somewhere along with the emacs binary and
.pdmp file that correspond to it?  That way, if we fix your session we
can still figure out why it was broken in the first place.  (Of course,
you should nevershare the core file).

The next step would be to set garbage-collection-messages to t to see
whether it's indeed MPS that's to blame.

What are the values of igc-step-interval and igc--balance-intervals?

Can you send a dump of the output of M-x igc-stats and M-x
igc-roots-stats?

Does a manual full collection (M-x igc-collect) help temporarily?  How
long does it take?

Are you using the debug version of libmps or the standard version?
IIUC, the debug version sometimes verifies so many things that it runs
into complexity issues.

Attaching gdb Monte-Carlo-style a few times during the hang and sending
the "bt full" might also provide some hints.

> In GNU Emacs 31.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version
>  3.24.42, cairo version 1.18.2) of 2025-02-15 built on localhost
> Repository revision: 67e602105774a31508239a6d2a6a05a4d4c5d363

Hmm.  That commit's a bit old, but I'm not aware of any major
performance problems that would have gone away entirely since then.

> Repository branch: feature/igc
> Windowing system distributor 'The X.Org Foundation', version 11.0.12101014
> System Description: Gentoo Linux
>
> Configured using:
>  'configure --with-mps=yes --with-native-compilation 'CFLAGS=-g3
>  -I/opt/mps/include -L/opt/mps/lib'
>  JAVAC=/etc/java-config-2/current-system-vm/bin/javac
>  PKG_CONFIG_PATH=/usr/share/guile-data/3.0/pkgconfig'

IIUC, configuring Emacs that way will add a "-O" flag to the CFLAGS,
which is unusual as -O2 and -O3 are much more common.  I'm not sure
whether that's what you intended to do, but it always surprises me :-)

Pip