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

From: Ihor Radchenko <[email-masked]>
Date: Fri, 22 Sep 2023 13:38:53 +0000

Dmitry Gutov <[email-masked]> writes:

>> However, upon recording the profiler report with that change,
>> `find-buffer-visiting' still took a significant fraction of CPU time.
>> So, I decided to reach out upstream.
>
> Because the rest of the calls are made from Org?

I am not 100% sure what you mean.

> I see this in the profile, though:
>
>          6247  20%        - editorconfig--advice-find-file-noselect
>
> There seems to be a lot of timers in that profile, and this is in one of 
> them (under "Automatic GC" which takes up 53% of the time).
>
> So one was to improve this in the meantime would be to bring it up with 
> "editorconfig" authors. I would even question the wisdom of advising 
> find-file-noselect.

Nope. If you dig deeper, you will see that it is an around advice that
later calls the original `find-file-noselect', where we spend most of
the time:

        6247  20%        - editorconfig--advice-find-file-noselect
        6247  20%         - let
        6247  20%          - let
        6247  20%           - setq
        6247  20%            - apply
        1773   5%             - #<lambda -0xd6e9bb25a48132a>
        1773   5%              - if
        1773   5%               - if
        1773   5%                - let*
        1773   5%                 - and
        1773   5%                  + find-buffer-visiting
        1666   5%             - #<lambda -0xd6e9bb25a48132a>
        1666   5%              - if
        1666   5%               - if
        1666   5%                - let*
        1666   5%                 - and
        1666   5%                  + find-buffer-visiting
        1006   3%             - #<lambda -0xd6e9bb25a48132a>
        1006   3%              - if
        1006   3%               - if
        1006   3%                - let*
        1006   3%                 - if
        1006   3%                  - setq
        1006   3%                   + create-file-buffer
         830   2%             - #<lambda -0xd6e9bb25a48132a>
         830   2%              - if
         830   2%               - if
         830   2%                - let*
         830   2%                 - and
         830   2%                  + find-buffer-visiting
         776   2%             - #<lambda -0xd6e9bb25a48132a>
         776   2%              - if
         776   2%               - if
         776   2%                - let*
         776   2%                 - and
         776   2%                  + find-buffer-visiting

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