Subject: bug#66117: 30.0.50; `find-buffer-visiting' is slow when opening large number of buffers

From: Ihor Radchenko <[email-masked]>
Date: Sun, 08 Oct 2023 12:10:14 +0000

Eli Zaretskii <[email-masked]> writes:

>> > If file-attributes is the main source of consing, it could be the reason 
>> > for the line
>> >
>> >    924  36%   Automatic GC
>> 
>> No, the main source of consing, according to the memory profiler, is
>> `inhibit-local-variables-p':
>
> The so-called "memory" profiler doesn't profile memory usage...

This is annoying... Would be so nice if there were an actual profiler
for consing.

I tried

-         (let* ((attributes (file-attributes truename))
+         (let* ((attributes (and nil (file-attributes truename)))

which should effectively eliminate the calls to `file-attributes' from
`find-file-visiting'. The GC time did not change significantly:

         916  38%   Automatic GC
         213   8% + locate-dominating-file
         157   6% + abbreviate-file-name
         141   5% + inhibit-local-variables-p
         120   5% + file-truename
         108   4% + dir-locals--all-files
          60   2% + file-name-sans-versions
          54   2% + insert-file-contents

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>