Subject: bug#64681: 30.0.50; slow saving of scores when leaving an nnml group in gnus

From: Stefan Monnier <[email-masked]>
Date: Mon, 17 Jul 2023 09:10:25 -0400

> A significant amount of time is taken saving scores, as far as I can
> tell.  I use adaptive scoring.  Nothing with respect to scoring has
> changed in my configuration in some time (years probably).

If you could send me your biggest scoring file I could try and reproduce
it locally.

I understand it contains private information, so you might want to
"sanitize" it first e.g. by doing a search&replace such as

    C-u M-% ".+" RET "xxxx" RET

[ Maybe you'll need to tweak the regexp, e.g. if you have strings that
  contain the double quote character or that span more than one line.
  E.g. maybe search for \" before doing the above.  If you need more
  help with that, let me know.  ]

> The offending function appears to be "lisp--local-defform-body-p" with
> large memory and cpu use.

Indeed.

> After discussion on the gnus mailing list, the culprit would appear to
> be the pretty-printing.  Setting pp-default-function to 'pp-28 instead
> of 'pp-fill restores the behaviour to what is desirable in terms of
> speed.

Yup, the underlying difference is that the new `pp-fill` uses
`lisp-indent-line` whereas the old code (`pp-28`) uses
`lisp-indent-region`.  In most cases, the algorithmic complexity of
calling `lisp-indent-line` on every line of a region should be the same
as that of `lisp-indent-region`, but sometimes performance bugs creep
in :-(

        Stefan