GNU bug report logs - #58687
29.0.50; Enabling pp-use-max-width dramatically slows down formatting of large sexps like org-persist--index

Previous Next

Package: emacs;

Reported by: Michael Eliachevitch <m.eliachevitch <at> posteo.de>

Date: Fri, 21 Oct 2022 13:38:02 UTC

Severity: normal

Found in version 29.0.50

Full log


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

From: Ihor Radchenko <yantar92 <at> posteo.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 58687 <at> debbugs.gnu.org, m.eliachevitch <at> posteo.de
Subject: Re: bug#58687: 29.0.50; Enabling pp-use-max-width dramatically
 slows down formatting of large sexps like org-persist--index
Date: Thu, 12 Jan 2023 16:19:37 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> > I attached a file with the value of my `org-persist--index` expression and a file with a benchmark where I run pp on it, which took me 25s when running it with emacs -Q. Until recently my org persist index was much longer, but I pruned it a bit back when I wasn't aware what exactly caused the slowdown.
>> 
>> I'd like to bump this bug.
>
> Why?

Because, I'd like to know if there are chances that it could be fixed.
The original report demonstrates how this issue slows down Emacs quit
time dramatically. I should either let-bind `pp-use-max-with' to nil in
org-persist.el to work around the problem or wait for the fix.

>> Observed: (19.617422592 2 1.0353073050000035)
>> Expected: `pp' not taking ~20sec to write 15k of elisp data.
>
> Did you look at what pp.el does when pp-use-max-width is non-nil?  I
> show a profile below, to make that clear.
>
> The "regular" pp (when pp-use-max-width is nil) finishes almost
> instantaneously in this case.
> ...
>        40041  85%            - pp
>        40041  85%             - pp-to-string
>        40041  85%              - pp-emacs-lisp-code
>        40028  85%               - pp--insert-lisp
>        40028  85%                - pp--format-list
>        40028  85%                 - pp--insert
>        38710  82%                  - pp--insert-lisp
>        38710  82%                   - pp--format-list

So, the current `pp' implementation is re-parsing from bob for every
nested list inside sexp. This is quadratic scaling, and, as the repro
demonstrates, the time goes up very quickly. Is the new option usable
at all in practice?

-- 
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 211 days ago.

Previous Next


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