Subject: Re: bug#63364: (man "gcc") very slow

From: Eli Zaretskii <[email-masked]>
Date: Mon, 08 May 2023 16:11:10 +0300

> Date: Mon, 8 May 2023 10:15:33 +0200
> From: Tobias Bading <[email-masked]>
> 
> With emacs-29 branch 7133784303 or master 31a66dc891:
> 
> 1. emacs -Q
> 
> 2. M-x man RET gcc RET
> 
> Emacs 29 and 30 both need almost 30 seconds to fully display this man page
> on my machine (18714 lines, gcc-9, 2021-06-01). Emacs 26.3 needs about 2
> seconds. (All tests done after “sudo cpupower frequency-set --max 3.5GHz”.)
> 
> According to “perf top -g”, rpl_re_search_2 and re_match_2_internal are
> heavily involved.

I think this is the price of fixing bugs with fontification/cleanup of
the man pages, which we installed in Emacs 27; see bug#36927.  Since
the text of the man page is received from the background formatter in
chunks of arbitrary size, we cannot fontify/cleanup each chunk
separately, because that will miss some patterns we want to process.
So whenever a chunk is received, we always go to the beginning of the
section, and start fontifying from there.  And the GCC man page
basically has one huge OPTIONS section and very little else.  So each
time we receive one more chunk, we go back to the beginning of OPTIONS
and restart anew.

If someone has ideas for how to go back to a closer place without
missing some roff markup that got divided between chunks, patches are
welcome.  OTOH, we don't really want to encourage use of man pages...