GNU bug report logs - #55481
mostly nonrecursive printing [PATCH]

Previous Next

Package: emacs;

Reported by: Mattias Engdegård <mattiase <at> acm.org>

Date: Tue, 17 May 2022 14:00:02 UTC

Severity: normal

Tags: patch

Done: Mattias Engdegård <mattiase <at> acm.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 55481 in the body.
You can then email your comments to 55481 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#55481; Package emacs. (Tue, 17 May 2022 14:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mattias Engdegård <mattiase <at> acm.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 17 May 2022 14:00:02 GMT) Full text and rfc822 format available.

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

From: Mattias Engdegård <mattiase <at> acm.org>
To: bug-gnu-emacs <at> gnu.org
Subject: mostly nonrecursive printing [PATCH]
Date: Tue, 17 May 2022 15:59:16 +0200
[Message part 1 (text/plain, inline)]
Printing deeply nested values typically crashes Emacs by running out of C stack since the printer uses C recursion to traverse nested data structures. This is a long-standing problem that keeps turning up; see bug#52753 for one example.

The attached patch eliminates most of the recursion: conses, vectors, records, hash tables and char tables are now traversed without consuming C stack. This should cover the vast majority of objects that form deep structures.

Of note:

- Performance seems to be slightly improved (about 2.5 % faster for printing a long list of symbols) but that's not really the point of the patch.

- The patch does not attempt to fix the bogus #N notation for circular lists (bug#55395) but tries to stay bug-compatible for easier comparison.

- Some special syntax is context-conditional: (\, X) is only printed as ,X if surrounded by a positive number of backquote forms. It's not clear what we gain from this; using the special syntax for the backquote, comma and comma-at forms unconditionally would simplify matter without any apparent inconvenience to the user. Right now, the patch does not remove recursion for printing these forms.

- This patch does not address reading nested values, where a similar problem exists.

[print-nonrec.diff (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55481; Package emacs. (Tue, 17 May 2022 15:49:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattiase <at> acm.org>
Cc: 55481 <at> debbugs.gnu.org
Subject: Re: bug#55481: mostly nonrecursive printing [PATCH]
Date: Tue, 17 May 2022 18:48:09 +0300
> From: Mattias Engdegård <mattiase <at> acm.org>
> Date: Tue, 17 May 2022 15:59:16 +0200
> 
> Printing deeply nested values typically crashes Emacs by running out of C stack since the printer uses C recursion to traverse nested data structures. This is a long-standing problem that keeps turning up; see bug#52753 for one example.
> 
> The attached patch eliminates most of the recursion: conses, vectors, records, hash tables and char tables are now traversed without consuming C stack. This should cover the vast majority of objects that form deep structures.

Thanks, this is an important improvement, IMO.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#55481; Package emacs. (Tue, 17 May 2022 17:42:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Mattias Engdegård <mattiase <at> acm.org>,
 55481 <at> debbugs.gnu.org
Subject: Re: bug#55481: mostly nonrecursive printing [PATCH]
Date: Tue, 17 May 2022 19:41:20 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> Thanks, this is an important improvement, IMO.

Yup; sounds excellent.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Reply sent to Mattias Engdegård <mattiase <at> acm.org>:
You have taken responsibility. (Wed, 18 May 2022 09:08:02 GMT) Full text and rfc822 format available.

Notification sent to Mattias Engdegård <mattiase <at> acm.org>:
bug acknowledged by developer. (Wed, 18 May 2022 09:08:02 GMT) Full text and rfc822 format available.

Message #16 received at 55481-done <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: Eli Zaretskii <eliz <at> gnu.org>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 55481-done <at> debbugs.gnu.org
Subject: Re: bug#55481: mostly nonrecursive printing [PATCH]
Date: Wed, 18 May 2022 11:07:19 +0200
17 maj 2022 kl. 17.48 skrev Eli Zaretskii <eliz <at> gnu.org>:

> Thanks, this is an important improvement, IMO.

17 maj 2022 kl. 19.41 skrev Lars Ingebrigtsen <larsi <at> gnus.org>:

> Yup; sounds excellent.

Thank you both! Now pushed to master.





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 15 Jun 2022 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 287 days ago.

Previous Next


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