Subject: bug#78665: closed (Re: bug#78665: 31.0.50; Very slow saves)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 04 Jun 2025 20:41:02 +0000

Your bug report

#78665: 31.0.50; Very slow saves

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
78665: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78665
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#78665: 31.0.50; Very slow saves
From: Stefan Monnier <[email-masked]>
To: Juri Linkov <[email-masked]>
Cc: [email-masked], Eli Zaretskii <[email-masked]>, Jonas Bernoulli <[email-masked]>, [email-masked]
Date: Wed, 04 Jun 2025 16:40:36 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

> I've completed testing your patch and found no problems.

Thanks, pushed to `master`,

        Stefan

Subject: 31.0.50; Very slow saves
From: Stefan Monnier <[email-masked]>
To: [email-masked]
Date: Sun, 01 Jun 2025 16:06:53 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Package: Emacs
Version: 31.0.50

The last few weeks I noticed that saving a buffer was sometimes taking
a very long time (like more than 10s).  I finally managed to catch it
in the act while running the profiler, and it seems to have something to
do with `outline--hidden-headings-restore-paths`:

        9630  75% - command-execute
        9630  75%  - call-interactively
        8638  67%   - funcall-interactively
        8630  67%    - save-buffer
        8630  67%     - basic-save-buffer
        8607  67%      - run-hooks
        8607  67%       - vc-git-resolve-when-done
        8593  67%        - vc-resynch-buffer
        8593  67%         - vc-resynch-window
        8593  67%          - vc-revert-buffer-internal
        8593  67%           - revert-buffer
        8353  65%            - mapc
        8353  65%             - funcall
        8353  65%              - #<byte-code-function 1FB>
        8353  65%               - outline--hidden-headings-restore-paths
        8353  65%                - outline-map-region
        7748  60%                 - #<byte-code-function 28A>
        7732  60%                  - outline-hide-subtree
        7728  60%                   - outline-flag-subtree
        4268  33%                    + outline-back-to-heading
        3393  26%                    + outline-end-of-subtree
          63   0%                    + outline-flag-region
           4   0%                    + outline-end-of-heading
           8   0%                  + mapcar
           4   0%                    gethash
           4   0%                    pos-bol
         605   4%                 + outline-next-heading
         232   1%            + run-hook-wrapped
           8   0%            + revert-buffer--default
          14   0%          re-search-forward
          16   0%      + basic-save-buffer-1
           4   0%      + vc-before-save
           3   0%      + vc-after-save
           8   0%    + execute-extended-command
         992   7%   + byte-code
        1855  14% + redisplay_internal (C function)
        1166   9% + #<byte-code-function 6A0>
          45   0% + timer-event-handler
           4   0% + jit-lock--antiblink-post-command
           4   0% + reveal-post-command
           0   0%   ...

This one occurred while saving `transient.el`.

Maybe we could avoid the whole thing by changing VC to not
`revert-buffer` (AFAIK this was done to handle the case where CVS/RCS
would update the "keywords" in the file to reflect its new state, but
I believe this is basically never done nowadays).

But in any case `outline--hidden-headings-restore-paths` just takes too
much time.

        Stefan