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: Dmitry Gutov <dmitry <at> gutov.dev>
To: 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: Fri, 22 Sep 2023 04:36:50 +0300
Hi Ihor,

On 20/09/2023 11:53, Ihor Radchenko wrote:
> In the attached profile, ~500 Org buffers are being opened and calls to
> `find-buffer-visiting' take 12.4 sec out of total 30.9 sec - 1/3 of all
> the execution time. After replacing some of the calls to
> `find-buffer-visiting' with `get-file-buffer', the total execution time
> decreased to ~20 sec, confirming that `find-buffer-visiting' is
> contributing significantly to slow performance.
> 
> Would it be possible to implement some kind of caching mechanism to be
> used by `find-buffer-visiting'?

I'm guessing you Cc'd me because of an existing comment inside xref.el? 
As you can see I decided not to use this function there, but even 
get-file-buffer wasn't as fast as I would've wanted, so there's a 
quick-and-dirty caching solution for sequential lookups (which assumes 
that the same file would be looked up multiple times in a row).

Putting aside the perspective of maintaining a cache in the core 
(hopefully this will be discussed later in this feature request), any 
chance you could initialize that cache yourself first (by iterating 
through buffers and building file-truename -> buffer map), before you 
are doing those many lookups? Somewhere in org-agenda-list, perhaps.

That should change the complexity from N*M to N+M, more or less.




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

Previous Next


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