all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gemini Lasswell <geminilasswell@runbox.com>
To: Helmut Eller <eller.helmut@gmail.com>
Cc: Gemini Lasswell <gazally@runbox.com>, emacs-devel@gnu.org
Subject: Re: backtrace-mode
Date: Thu, 21 Jun 2018 17:08:52 -0700	[thread overview]
Message-ID: <871sczsmwb.fsf@runbox.com> (raw)
In-Reply-To: <m2r2l2uhrs.fsf@gmail.com> (Helmut Eller's message of "Wed, 20 Jun 2018 07:52:07 +0200")


Helmut Eller <eller.helmut@gmail.com> writes:

> So I think there
> should either be a proper "view source" command or xref backend for
> backtraces.

I agree.  I think there should be three commands:

1. "View source", to jump to the source for the frame at point.  I
haven't done it yet but I plan on implementing it and binding it to
the 's' key.  For now it is going to work best with Edebug, but when
the byte compiler or Lisp reader gain the ability someday to save
source code positions, it could be made to work with those as well.

2. "Go to definition", to jump to the source code for the definition
of the symbol at point, which can be used on any function or variable
name in the buffer.  I think xref-find-definitions with the Elisp
backend works well for this.

3. "Show help", to bring up help for the symbol at point, currently
implemented by backtrace-help-follow-symbol, bound to RET.

> Another issue: backtrace-get-frames seems to compute the entire
> backtrace and all possibly relevant information in advance.  Maybe that
> should be done a bit more lazily, e.g. compute the next N frames only if
> somebody needs them.  For local variable also keep in mind that
> backtrace--locals is implemented rather inefficiently.  That would also
> be less problematic if locals are only fetched when needed.

I'm aware that there's an O(n^2) here but I didn't want to prematurely
optimize and make the code more complicated without noticable benefit.
While working on this code I had tried generating backtraces from
max-lisp-eval-depth errors a few times and they always came up
quickly.  Yesterday I realized that was due to a bug, now on debbugs
as #31919.  With that fixed I tried wrapping the calls to
backtrace-get-frames and backtrace-print with benchmark-run, and
then evaluating this code:

(toggle-debug-on-error)
(defun my-func (arg)
  (let ((arg1 arg))
    (+ (length arg) (my-func arg))))

And then I tried both (my-func "hello") and (my-func my-str) with
my-str bound to the buffer-string of a magit-status buffer, which 
for the one I used made (length (cl-prin1-to-string my-str)) evaluate
to 1711302, and which is the sort of value which would make previous
versions of Emacs backtraces excruciatingly slow.

From my experiments I concluded backtrace-get-frames is not a
performance problem.  With standard stack limits it takes about 0.015
seconds, and even after increasing both max-lisp-eval-depth and
max-specpdl-size by a factor of 5, it still only takes 0.2 seconds (on
a 5-year old Intel cpu, 2.6GHz).  But backtrace-print is far slower,
taking 3.7 seconds with high stack limits and "hello" and 60 seconds
with default stack limits and the magit buffer-string.  So I'll look
into what can be done lazily when rendering the backtrace frames into
the buffer.

Gemini



  reply	other threads:[~2018-06-22  0:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 22:58 backtrace-mode Gemini Lasswell
2018-06-20  5:52 ` backtrace-mode Helmut Eller
2018-06-22  0:08   ` Gemini Lasswell [this message]
2018-06-22  2:07     ` backtrace-mode Stefan Monnier
2018-06-22  5:41       ` backtrace-mode Gemini Lasswell
2018-06-20 12:32 ` backtrace-mode Stefan Monnier
2018-06-20 15:23 ` backtrace-mode Filipp Gunbin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871sczsmwb.fsf@runbox.com \
    --to=geminilasswell@runbox.com \
    --cc=eller.helmut@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=gazally@runbox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.