GNU bug report logs - #58558
29.0.50; re-search-forward is slow in some buffers

Previous Next

Package: emacs;

Reported by: Ihor Radchenko <yantar92 <at> posteo.net>

Date: Sun, 16 Oct 2022 01:27:02 UTC

Severity: normal

Found in version 29.0.50

Full log


Message #53 received at 58558 <at> debbugs.gnu.org (full text, mbox):

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 58558 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 monnier <at> iro.umontreal.ca
Subject: Re: bug#58558: 29.0.50; re-search-forward is slow in some buffers
Date: Tue, 13 Dec 2022 10:28:57 +0000
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> I thought it might be easier to see the differences in results if one
> first attached perf to a fresh (fast) Emacs and got the trace, and the
> waited until Emacs got slow, and repeated the same thing under another
> trace.
>
> perf is able to do this by:
>
> perf record -p <PID> -g
>
> and
>
> perf report
>
> then shows me stuff, but I don't even know what to look for when
> interpreting that.  Or whether perf is, indeed, the right too for this
> task.

Ok. I got around to try perf, and it turned out to be very easy to get
started.

perf record -p <PID> + perf report already appear to give some clue:

    88.27%  emacs    emacs-30-vcs                      [.] buf_bytepos_to_charpos
     3.75%  emacs    emacs-30-vcs                      [.] re_match_2_internal
     1.35%  emacs    emacs-30-vcs                      [.] scan_sexps_forward
     1.03%  emacs    emacs-30-vcs                      [.] re_search_2
     0.65%  emacs    emacs-30-vcs                      [.] find_interval
     0.56%  emacs    emacs-30-vcs                      [.] sub_char_table_ref
     0.55%  emacs    emacs-30-vcs                      [.] lookup_char_property

The fraction of buf_bytepos_to_charpos increases over repeated benchmark
runs.

In contrast, using find-file-literally produces

    34.44%  emacs    emacs-30-vcs                             [.] re_match_2_internal
    25.55%  emacs    emacs-30-vcs                             [.] scan_sexps_forward
    11.09%  emacs    emacs-30-vcs                             [.] re_search_2
    ...
    0.59%  emacs    emacs-30-vcs                             [.] buf_bytepos_to_charpos

with buf_bytepos_to_charpos taking diminishing cpu sample fraction.

Any ideas what I can do further?

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




This bug report was last modified 2 years and 64 days ago.

Previous Next


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