Re: performance in emacs displaying a huge thread

Subject: Re: performance in emacs displaying a huge thread

Date: Wed, 22 Sep 2021 22:48:13 -0300

To: Alan Schmitt, notmuch


From: David Bremner

Alan Schmitt <> writes:

> I can view a thread with more than 7000 messages (with
> show-only-matching-messages to t) if they are not encrypted. In fact I
> already could with 0.32 if I remember correctly. The fact that messages
> are encrypted seems to matter here.

I've been unable to replicate this deep recursion. Whenever I'm in
unthreaded search view, I have one message summary on every line, and
when I trace through notmuch-show-insert-tree,

  (let ((msg (car tree))
	(replies (cadr tree)))

always assigns nil (empty list) to replies.  That means my call stack
has exactly one instance of notmuch-show-insert-tree.

> If it matters, here is the bottom of the debug stack:
>   notmuch-show-insert-thread(((nil ((nil ((nil nil) (nil (... ...))))))) 1)
>   notmuch-show-insert-tree((nil ((nil ((nil ((nil nil) (nil ...))))))) 0)
>   #f(compiled-function (tree) #<bytecode 0x155b49d5fc55>)((nil ((nil ((nil ((nil nil) (nil ...))))))))
>   mapc(#f(compiled-function (tree) #<bytecode 0x155b49d5fc55>) ((nil ((nil ((nil (... ...))))))))
>   notmuch-show-insert-thread(((nil ((nil ((nil (... ...))))))) 0)
>   #f(compiled-function (thread) #<bytecode 0x155b49b2e195>)(((nil ((nil ((nil (... ...))))))))
>   mapc(#f(compiled-function (thread) #<bytecode 0x155b49b2e195>) (((nil ((nil ((nil ...))))))))
>   notmuch-show-insert-forest((((nil ((nil ((nil ...))))))))
>   notmuch-show--build-buffer()
>   notmuch-show("")
>   notmuch-tree-show-message-out()
>   notmuch-tree-show-message(nil)
>   funcall-interactively(notmuch-tree-show-message nil)
>   call-interactively(notmuch-tree-show-message nil nil)
>   command-execute(notmuch-tree-show-message)

On possibility is that there some old version of the code that you are
running.  Inside notmuch-show-insert-tree, the variable
notmuch-show-single-message should be 't', whether called from regular
tree-mode or an unthreaded search.

As an experiment, you could try redefining

(defun notmuch-show-insert-tree (tree depth)
  "Insert the message tree TREE at depth DEPTH in the current thread."
  (let ((msg (car tree))
	(replies (cadr tree)))
    (message "nreplies %d flag %s" (length replies) notmuch-show-single-message)
    ;; We test whether there is a message or just some replies.
    (when msg
      (notmuch-show-insert-msg msg depth))
    (notmuch-show-insert-thread replies (1+ depth))))

this will log the number of replies and flag value. For me, it logs

"nreplies 0 flag t"
notmuch mailing list --
To unsubscribe send an email to