[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#36566: 27.0.50; debug is sometimes horribly slow

From: Gemini Lasswell
Subject: bug#36566: 27.0.50; debug is sometimes horribly slow
Date: Sat, 13 Jul 2019 17:02:19 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2.90 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

> With print-gemsym -> nil, the debugger needs approx. 2 seconds here to
> pop up, and with print-gemsym -> t, approx. 12.  So I wonder why this
> setting makes it that slow - I would expect a small time penalty, but
> such a big difference?

The C printing code builds hash tables to match gensyms to the numbers
they are printed with.  So it is building and discarding these hash
tables which causes the garbage collection and the slowdown.  Emacs 26's
backtrace printing is also significantly slower with print-gensym turned

The reason master is so much slower than Emacs 26 is because of the
adaptive abbreviating I added to reduce problems with really long lines.
In Emacs 26 it's hard to debug things like magit or org-mode because
lines in the backtrace can easily get to be thousands or millions of
characters long and display gets really slow.  When I added
backtrace-mode, I gave it a target line length and a function which
starts with guesses at the appropriate values of print-length and
print-level, and which iteratively prints using those values, and if the
length of the printed representation is over the target, it reduces
print-length and print-level and tries again.  That reprinting, and
consequential repeated construction of gensym hash tables, is what's
making master slower than Emacs 26 in this case.

I remember when I was writing that function thinking that it was a
heuristic sort of algorithm and would likely need tweaking, so here we

The easy fix for you for today is to set backtrace-line-length to 100 or
less, which will make the initial values of print-length and print-level
so low that little reprinting will be done.  Then use
backtrace-expand-ellipsis (bound to "."), with or without C-u, on the
lines where you want to see the full data structure.  And try "+" and
"-" if you haven't already.

I'll experiment with tweaking the heuristic to reduce the amount of
reprinting it does, and let you know what I come up with.

> BTW, extra points if the debugger provided commands/ a menu to tune such
> settings (like printing variables) live when using it.

There is such a command for print-circle (bound to "#") and it would be
easy to add one for print-gensym, although I could use a keybinding
suggestion.  backtrace-line-length is a defcustom.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]