GNU bug report logs - #66117
30.0.50; `find-buffer-visiting' is slow when opening large number of buffers

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Wed, 20 Sep 2023 08:53:02 UTC

Severity: minor

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: dmitry <at> gutov.dev, Ihor Radchenko <yantar92 <at> posteo.net>, 66117 <at> debbugs.gnu.org
Subject: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers
Date: Wed, 13 Dec 2023 09:12:39 -0500
>> But it will only solve specific problem with `find-buffer-visiting' and
>> we can always go for it if we cannot find anything better.
> Which other popular functions need to loop through all the buffers in
> Lisp?

Not sure why that matters.  The performance problem comes from repeated
uses of `(let ((case-fold-search ..)) ...)` where the repetition can be
due to anything (not only enumerating buffers).

The "loop through buffers" happens when entering and leaving the `let`,
because it has to `set/unset` the corresponding filed of the `struct
buffer` of all the buffers whose `case-fold-search` is "global".

Making it a DEFVAR_LISP rather than a DEFVAR_PER_BUFFER will fix this
problem (at the cost of making it less efficient to `set-buffer` when
that variable has been made buffer-local).

DEFVAR_PER_BUFFER should be for variables which are usually
buffer-local, and apparently that's not the case of `case-fold-search`,
so I'm starting to think that changing it from DEFVAR_PER_BUFFER to
DEFVAR_LISP might be the better option.


        Stefan





This bug report was last modified 1 year and 136 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.