unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#60107: 30.0.50; Open new files very slow if eglot and which-function-mode are enabled.
@ 2022-12-15 22:53 Felix
  2022-12-15 23:44 ` João Távora
  0 siblings, 1 reply; 7+ messages in thread
From: Felix @ 2022-12-15 22:53 UTC (permalink / raw)
  To: 60107





In GNU Emacs 30.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version
 3.24.35) of 2022-12-15 built on felix-lifebooka531
Repository revision: 0d60579b6b6f2648a881572783322b1bcf931a73
Repository branch: makepkg
Windowing system distributor 'The X.Org Foundation', version 11.0.12201006
System Description: Arch Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-modules --without-libotf --without-m17n-flt --without-gconf
 --enable-autodepend --with-native-compilation=yes --with-xinput2
 --with-x-toolkit=gtk3 --without-xaw3d --without-cairo --with-sound=no
 --with-xwidgets --with-tree-sitter --without-gpm
 --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
 'CFLAGS=-march=native -mtune=generic -O3 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection'
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
ACL DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2
LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11
XDBE XFT XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB

Important settings:
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8


Opening C files is very slow if which-function-mode and eglot are
enabled at the same time. I tested this with:

emacs -Q
opening a C project file
M-x eglot
M-x which-function-mode
switching to another .c project file now takes seconds until the buffer
shows up.
I use an old Laptop, but with just one of the two modes disabled,
it's quite snappy.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#60107: 30.0.50; Open new files very slow if eglot and which-function-mode are enabled.
  2022-12-15 22:53 bug#60107: 30.0.50; Open new files very slow if eglot and which-function-mode are enabled Felix
@ 2022-12-15 23:44 ` João Távora
  2022-12-15 23:59   ` Felix
  0 siblings, 1 reply; 7+ messages in thread
From: João Távora @ 2022-12-15 23:44 UTC (permalink / raw)
  To: Felix; +Cc: 60107

[-- Attachment #1: Type: text/plain, Size: 3401 bytes --]

Hi Felix,

First of all, thanks for the easy-to-follow Emacs -Q reproduction
recipe.  I reproduced the problem, although in my own test, which
used medium/small C++ files, the delay I noticed wasn't very long,
about 1 second.

Which-function-mode relies on Imenu, which is the keeper of
a syntactic sub-tree of the file, which it must collect from somewhere.
When Eglot is enabled, Imenu gets its tree from the LSP server.
Depending on the LSP server and the amount of information at
hand, this can be a lot of information and take some time to gather.

It seems which-function-mode not only relies on Imenu but also
blocks the user interface and redisplay while it is waiting for the
Imenu backend to reply (the Imenu backend in this case being
Eglot's).

I don't see a good fix for this, except disabling Imenu/Eglot integration
by adding the symbol 'imenu to eglot-stay-out-of (see the Eglot
manual).

It can also be that what's slowing down operation here isn't the
collection of the syntax tree per se but the logging that is going
on.  See also the Eglot manual for how to configure
eglot-events-buffer-size to see if it makes a difference or not.;

Finally, you can probably get some other source for Imenu information
to feed which-func-mode.  The new C++ modes like c++-ts-mode seems
to have similar information handy, and perhaps it takes a lot less time
to compute.

João

On Thu, Dec 15, 2022 at 10:57 PM Felix <felix.dick@web.de> wrote:

>
>
>
>
> In GNU Emacs 30.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version
>  3.24.35) of 2022-12-15 built on felix-lifebooka531
> Repository revision: 0d60579b6b6f2648a881572783322b1bcf931a73
> Repository branch: makepkg
> Windowing system distributor 'The X.Org Foundation', version 11.0.12201006
> System Description: Arch Linux
>
> Configured using:
>  'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
>  --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
>  --with-modules --without-libotf --without-m17n-flt --without-gconf
>  --enable-autodepend --with-native-compilation=yes --with-xinput2
>  --with-x-toolkit=gtk3 --without-xaw3d --without-cairo --with-sound=no
>  --with-xwidgets --with-tree-sitter --without-gpm
>  --without-compress-install
>  '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
>  'CFLAGS=-march=native -mtune=generic -O3 -pipe -fno-plt -fexceptions
>  -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
>  -fstack-clash-protection -fcf-protection'
>  LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'
>
> Configured features:
> ACL DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2
> LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG
> SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11
> XDBE XFT XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB
>
> Important settings:
>   value of $LANG: de_DE.UTF-8
>   locale-coding-system: utf-8
>
>
> Opening C files is very slow if which-function-mode and eglot are
> enabled at the same time. I tested this with:
>
> emacs -Q
> opening a C project file
> M-x eglot
> M-x which-function-mode
> switching to another .c project file now takes seconds until the buffer
> shows up.
> I use an old Laptop, but with just one of the two modes disabled,
> it's quite snappy.
>
>
>
>

-- 
João Távora

[-- Attachment #2: Type: text/html, Size: 4310 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#60107: 30.0.50; Open new files very slow if eglot and which-function-mode are enabled.
  2022-12-15 23:44 ` João Távora
@ 2022-12-15 23:59   ` Felix
  2022-12-16  7:23     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Felix @ 2022-12-15 23:59 UTC (permalink / raw)
  To: João Távora; +Cc: 60107


Hallo João,

Thanks for the fast response!

Now it makes sense that glsl-mode managed with eglot and glslls takes
forever to open glsl files, and imenu is not working at all.
Seems to depend on the server.
I will try your suggestions, in the end which-function-mode
is not that important to me, so if everything fails it's not that bad
either.
If this is not a bug of emacs,
feel free to close this bug report.

Btw. thanks a lot for eglot!

Felix







João Távora <joaotavora@gmail.com> writes:

> Hi Felix,
>
> First of all, thanks for the easy-to-follow Emacs -Q reproduction
> recipe.  I reproduced the problem, although in my own test, which
> used medium/small C++ files, the delay I noticed wasn't very long,
> about 1 second.
>
> Which-function-mode relies on Imenu, which is the keeper of
> a syntactic sub-tree of the file, which it must collect from somewhere.
> When Eglot is enabled, Imenu gets its tree from the LSP server.
> Depending on the LSP server and the amount of information at
> hand, this can be a lot of information and take some time to gather.
>
> It seems which-function-mode not only relies on Imenu but also
> blocks the user interface and redisplay while it is waiting for the
> Imenu backend to reply (the Imenu backend in this case being
> Eglot's).
>
> I don't see a good fix for this, except disabling Imenu/Eglot integration
> by adding the symbol 'imenu to eglot-stay-out-of (see the Eglot
> manual).
>
> It can also be that what's slowing down operation here isn't the
> collection of the syntax tree per se but the logging that is going
> on.  See also the Eglot manual for how to configure
> eglot-events-buffer-size to see if it makes a difference or not.;
>
> Finally, you can probably get some other source for Imenu information
> to feed which-func-mode.  The new C++ modes like c++-ts-mode seems
> to have similar information handy, and perhaps it takes a lot less time
> to compute.
>
> João
>
> On Thu, Dec 15, 2022 at 10:57 PM Felix <felix.dick@web.de> wrote:
>
>  In GNU Emacs 30.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version
>   3.24.35) of 2022-12-15 built on felix-lifebooka531
>  Repository revision: 0d60579b6b6f2648a881572783322b1bcf931a73
>  Repository branch: makepkg
>  Windowing system distributor 'The X.Org Foundation', version 11.0.12201006
>  System Description: Arch Linux
>
>  Configured using:
>   'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
>   --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
>   --with-modules --without-libotf --without-m17n-flt --without-gconf
>   --enable-autodepend --with-native-compilation=yes --with-xinput2
>   --with-x-toolkit=gtk3 --without-xaw3d --without-cairo --with-sound=no
>   --with-xwidgets --with-tree-sitter --without-gpm
>   --without-compress-install
>   '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
>   'CFLAGS=-march=native -mtune=generic -O3 -pipe -fno-plt -fexceptions
>   -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
>   -fstack-clash-protection -fcf-protection'
>   LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'
>
>  Configured features:
>  ACL DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2
>  LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG
>  SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11
>  XDBE XFT XIM XINPUT2 XPM XWIDGETS GTK3 ZLIB
>
>  Important settings:
>    value of $LANG: de_DE.UTF-8
>    locale-coding-system: utf-8
>
>  Opening C files is very slow if which-function-mode and eglot are
>  enabled at the same time. I tested this with:
>
>  emacs -Q
>  opening a C project file
>  M-x eglot
>  M-x which-function-mode
>  switching to another .c project file now takes seconds until the buffer
>  shows up.
>  I use an old Laptop, but with just one of the two modes disabled,
>  it's quite snappy.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#60107: 30.0.50; Open new files very slow if eglot and which-function-mode are enabled.
  2022-12-15 23:59   ` Felix
@ 2022-12-16  7:23     ` Eli Zaretskii
  2022-12-16 11:26       ` Felix
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2022-12-16  7:23 UTC (permalink / raw)
  To: Felix; +Cc: joaotavora, 60107

> Cc: 60107@debbugs.gnu.org
> From: Felix <felix.dick@web.de>
> Date: Fri, 16 Dec 2022 00:59:28 +0100
> 
> Now it makes sense that glsl-mode managed with eglot and glslls takes
> forever to open glsl files, and imenu is not working at all.
> Seems to depend on the server.
> I will try your suggestions, in the end which-function-mode
> is not that important to me, so if everything fails it's not that bad
> either.

Does it help to customize which-func-non-auto-modes to add the major
mode you are using there?  Or maybe customize which-func-maxout to a
small value to get the same effect in any mode?  I'm asking whether
this helps because it's unclear to me whether doing so will avoid
blocking redisplay, if and when which-func finally becomes active.

> If this is not a bug of emacs,
> feel free to close this bug report.

If the above doesn't help, I guess some changes to which-func could be
in order, to avoid blocking the first display of a buffer for such a
long time.  So in that case we shouldn't close this bug report yet.

Thanks.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#60107: 30.0.50; Open new files very slow if eglot and which-function-mode are enabled.
  2022-12-16  7:23     ` Eli Zaretskii
@ 2022-12-16 11:26       ` Felix
  2022-12-16 15:45         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Felix @ 2022-12-16 11:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: joaotavora, 60107


Eli Zaretskii <eliz@gnu.org> writes:

>> Cc: 60107@debbugs.gnu.org
>> From: Felix <felix.dick@web.de>
>> Date: Fri, 16 Dec 2022 00:59:28 +0100
>>
>> Now it makes sense that glsl-mode managed with eglot and glslls takes
>> forever to open glsl files, and imenu is not working at all.
>> Seems to depend on the server.
>> I will try your suggestions, in the end which-function-mode
>> is not that important to me, so if everything fails it's not that bad
>> either.
>
> Does it help to customize which-func-non-auto-modes to add the major
> mode you are using there?  Or maybe customize which-func-maxout to a
> small value to get the same effect in any mode?  I'm asking whether
> this helps because it's unclear to me whether doing so will avoid
> blocking redisplay, if and when which-func finally becomes active.
>
>> If this is not a bug of emacs,
>> feel free to close this bug report.
>
> If the above doesn't help, I guess some changes to which-func could be
> in order, to avoid blocking the first display of a buffer for such a
> long time.  So in that case we shouldn't close this bug report yet.
>
> Thanks.

In fact both of it helps!
Adding c-ts-mode to which-func-non-auto-modes solves the problem,
setting which-func-maxout to 1000 works as well (that's the only value i
tested).

Thanks a lot!





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#60107: 30.0.50; Open new files very slow if eglot and which-function-mode are enabled.
  2022-12-16 11:26       ` Felix
@ 2022-12-16 15:45         ` Eli Zaretskii
  2022-12-16 15:53           ` João Távora
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2022-12-16 15:45 UTC (permalink / raw)
  To: Felix; +Cc: 60107-done, joaotavora

> From: Felix <felix.dick@web.de>
> Cc: joaotavora@gmail.com, 60107@debbugs.gnu.org
> Date: Fri, 16 Dec 2022 12:26:21 +0100
> 
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > Does it help to customize which-func-non-auto-modes to add the major
> > mode you are using there?  Or maybe customize which-func-maxout to a
> > small value to get the same effect in any mode?  I'm asking whether
> > this helps because it's unclear to me whether doing so will avoid
> > blocking redisplay, if and when which-func finally becomes active.
> >
> >> If this is not a bug of emacs,
> >> feel free to close this bug report.
> >
> > If the above doesn't help, I guess some changes to which-func could be
> > in order, to avoid blocking the first display of a buffer for such a
> > long time.  So in that case we shouldn't close this bug report yet.
> >
> > Thanks.
> 
> In fact both of it helps!
> Adding c-ts-mode to which-func-non-auto-modes solves the problem,
> setting which-func-maxout to 1000 works as well (that's the only value i
> tested).

Thanks, so I added these hints to the doc strings of the two optioins,
and I'm closing the bug.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#60107: 30.0.50; Open new files very slow if eglot and which-function-mode are enabled.
  2022-12-16 15:45         ` Eli Zaretskii
@ 2022-12-16 15:53           ` João Távora
  0 siblings, 0 replies; 7+ messages in thread
From: João Távora @ 2022-12-16 15:53 UTC (permalink / raw)
  To: Eli Zaretskii, 60107; +Cc: Felix

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

[I don't actually know if this message will go through, given the bug
is closed]

On Fri, Dec 16, 2022 at 3:45 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
>
> Thanks, so I added these hints to the doc strings of the two optioins,
> and I'm closing the bug.

Your previous comment that which-func.el could see some work
re becoming asynchronous or non-blocking still makes sense to
me.

OTOH see bug#58431 where a possible new alternate client
to Imenu's tree, whose functionality would obsolete most
of which-func's is discussed.

It probably makes more sense to invest there, so closing
this may make sense.  Just thought I'd add this note.

[-- Attachment #2: Type: text/html, Size: 860 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-12-16 15:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 22:53 bug#60107: 30.0.50; Open new files very slow if eglot and which-function-mode are enabled Felix
2022-12-15 23:44 ` João Távora
2022-12-15 23:59   ` Felix
2022-12-16  7:23     ` Eli Zaretskii
2022-12-16 11:26       ` Felix
2022-12-16 15:45         ` Eli Zaretskii
2022-12-16 15:53           ` João Távora

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).