bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large nu


From: Dmitry Gutov
Subject: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers
Date: Thu, 5 Oct 2023 20:14:28 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 05/10/2023 14:27, Ihor Radchenko wrote:
Looking into `xref--find-file-buffer', all it does is memoizing the
previous call. I think that we can easily achieve the same performance
improvement by maintaining approximate cache for Fget_file_buffer -
something like
(if (and (gethash file cache)
            (equal (buffer-local-value 'buffer-file-name (gethash ...)) file))
   <return cached>
  <compute and cache the result>)

Or maybe even cache the last call separately to not pay `gethash' call price.

That works for the Xref's scenario (where, when there are many matches, they would tend to come several per file), but I'm not sure it's a good caching strategy in general.

And applications that are suited for it might as well write a small wrapper like I did.

100% reliable cache is not necessary in this scenario. And not necessary
in my scenario, as I have found via my benchmarks in another message.

IIUC a cache that keys on non-abbreviated/non-expanded filenames would be able to speed all that up anyway. But a more algorithmic improvement first would be better, of course.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]