unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 0/2] Make elide messages use cli side
@ 2012-02-23 21:41 Mark Walters
  2012-02-23 21:41 ` [PATCH 1/2] emacs/cli: remove entire-thread default from show: JSON Mark Walters
  2012-02-23 21:41 ` [PATCH 2/2] emacs: make elide messages use notmuch-show for omitting messages Mark Walters
  0 siblings, 2 replies; 6+ messages in thread
From: Mark Walters @ 2012-02-23 21:41 UTC (permalink / raw)
  To: notmuch

Currently the elide messages option in notmuch-show.el fetches all
messages in the thread (via notmuch-show.c) parses the JSON and throws 
away all the non-matching messages.

This patch removes the entire-thread assumption for format=json from 
notmuch-show.c. This allows the emacs code to call notmuch-show with 
out the --entire-thread flag and just receive the matching messages 
(but with the full thread structure) in return. 

This makes notmuch-show.c much faster (but in practice this is small
anyway) but more importantly substantially improves the speed of the
JSON parsing. Rough wall clock timing on my system shows (best case) a
4 second time for showing a large thread (170 messages) reduced to an
almost instant time for a single matching message from that thread.

For the existing show view the gain is nice but not critical. However,
notmuch-pick shows a single message at a time and the speed increase
will be needed there.

Best wishes

Mark



Mark Walters (2):
  emacs/cli: remove entire-thread default from show: JSON
  emacs: make elide messages use notmuch-show for omitting messages.

 emacs/notmuch-show.el |   15 +++++++++------
 notmuch-show.c        |    1 -
 2 files changed, 9 insertions(+), 7 deletions(-)

-- 
1.7.2.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] emacs/cli: remove entire-thread default from show: JSON
  2012-02-23 21:41 [PATCH 0/2] Make elide messages use cli side Mark Walters
@ 2012-02-23 21:41 ` Mark Walters
  2012-02-23 21:45   ` Adam Wolfe Gordon
  2012-02-23 21:41 ` [PATCH 2/2] emacs: make elide messages use notmuch-show for omitting messages Mark Walters
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Walters @ 2012-02-23 21:41 UTC (permalink / raw)
  To: notmuch

Previously notmuch-show.c defaulted to --entire-thread when
format=json.  Make the default just the matching messages, but make
the single emacs caller add --entire-thread to the arguments supplied
so the end result should be unchanged.
---
 emacs/notmuch-show.el |    7 ++++---
 notmuch-show.c        |    1 -
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index aa9ccee..dcef3d5 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1063,14 +1063,15 @@ function is used."
 	     (args (if notmuch-show-query-context
 		       (append (list "\'") basic-args
 			       (list "and (" notmuch-show-query-context ")\'"))
-		     (append (list "\'") basic-args (list "\'")))))
-	(notmuch-show-insert-forest (notmuch-query-get-threads args))
+		     (append (list "\'") basic-args (list "\'"))))
+	     (cli-args (list "--entire-thread")))
+	(notmuch-show-insert-forest (notmuch-query-get-threads (append cli-args args)))
 	;; If the query context reduced the results to nothing, run
 	;; the basic query.
 	(when (and (eq (buffer-size) 0)
 		   notmuch-show-query-context)
 	  (notmuch-show-insert-forest
-	   (notmuch-query-get-threads basic-args))))
+	   (notmuch-query-get-threads (append cli-args basic-args)))))
 
       (jit-lock-register #'notmuch-show-buttonise-links)
 
diff --git a/notmuch-show.c b/notmuch-show.c
index d930f94..5a9db8f 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1066,7 +1066,6 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
     switch (format_sel) {
     case NOTMUCH_FORMAT_JSON:
 	format = &format_json;
-	params.entire_thread = TRUE;
 	break;
     case NOTMUCH_FORMAT_TEXT:
 	format = &format_text;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] emacs: make elide messages use notmuch-show for omitting messages.
  2012-02-23 21:41 [PATCH 0/2] Make elide messages use cli side Mark Walters
  2012-02-23 21:41 ` [PATCH 1/2] emacs/cli: remove entire-thread default from show: JSON Mark Walters
@ 2012-02-23 21:41 ` Mark Walters
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Walters @ 2012-02-23 21:41 UTC (permalink / raw)
  To: notmuch

Previously the elide messages code got the entire-thread from
notmuch-show.c and then threw away all non-matching messages. This
version calls notmuch-show.c without the --entire-thread flag so
it never receives the non-matching messages in the first place.

This makes it substantially faster.
---
 emacs/notmuch-show.el |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index dcef3d5..e368363 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -981,9 +981,10 @@ current buffer, if possible."
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
 	(replies (cadr tree)))
-    (if (or (not notmuch-show-elide-non-matching-messages)
-	    (plist-get msg :match))
-	(notmuch-show-insert-msg msg depth))
+    ;; We test whether there is a message or just some replies.
+    (if (eq (length tree) 2)
+	(notmuch-show-insert-msg msg depth)
+      (setq replies msg))
     (notmuch-show-insert-thread replies (1+ depth))))
 
 (defun notmuch-show-insert-thread (thread depth)
@@ -1064,7 +1065,8 @@ function is used."
 		       (append (list "\'") basic-args
 			       (list "and (" notmuch-show-query-context ")\'"))
 		     (append (list "\'") basic-args (list "\'"))))
-	     (cli-args (list "--entire-thread")))
+	     (cli-args (unless notmuch-show-elide-non-matching-messages
+			 (list "--entire-thread"))))
 	(notmuch-show-insert-forest (notmuch-query-get-threads (append cli-args args)))
 	;; If the query context reduced the results to nothing, run
 	;; the basic query.
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] emacs/cli: remove entire-thread default from show: JSON
  2012-02-23 21:41 ` [PATCH 1/2] emacs/cli: remove entire-thread default from show: JSON Mark Walters
@ 2012-02-23 21:45   ` Adam Wolfe Gordon
  2012-02-23 22:04     ` Mark Walters
  0 siblings, 1 reply; 6+ messages in thread
From: Adam Wolfe Gordon @ 2012-02-23 21:45 UTC (permalink / raw)
  To: Mark Walters; +Cc: notmuch

Hi Mark,

On Thu, Feb 23, 2012 at 14:41, Mark Walters <markwalters1009@gmail.com> wrote:
> Previously notmuch-show.c defaulted to --entire-thread when
> format=json.  Make the default just the matching messages, but make
> the single emacs caller add --entire-thread to the arguments supplied
> so the end result should be unchanged.

The patch looks good to me. You should probably update the man page as
well, to reflect the change in defauls.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] emacs/cli: remove entire-thread default from show: JSON
  2012-02-23 21:45   ` Adam Wolfe Gordon
@ 2012-02-23 22:04     ` Mark Walters
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Walters @ 2012-02-23 22:04 UTC (permalink / raw)
  To: Adam Wolfe Gordon; +Cc: notmuch

On Thu, 23 Feb 2012 14:45:57 -0700, Adam Wolfe Gordon <awg+notmuch@xvx.ca> wrote:
> Hi Mark,
> 
> On Thu, Feb 23, 2012 at 14:41, Mark Walters <markwalters1009@gmail.com> wrote:
> > Previously notmuch-show.c defaulted to --entire-thread when
> > format=json.  Make the default just the matching messages, but make
> > the single emacs caller add --entire-thread to the arguments supplied
> > so the end result should be unchanged.
> 
> The patch looks good to me. You should probably update the man page as
> well, to reflect the change in defauls.

Thanks for the review. I will include an updated man page in the next
version.

Many thanks

Mark

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] emacs: make elide messages use notmuch-show for omitting messages.
  2012-04-10 17:04 [PATCH 0/2] Allow JSON to use non-entire thread, and use for elide Mark Walters
@ 2012-04-10 17:04 ` Mark Walters
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Walters @ 2012-04-10 17:04 UTC (permalink / raw)
  To: notmuch

Previously the elide messages code got the entire-thread from
notmuch-show.c and then threw away all non-matching messages. This
version calls notmuch-show.c without the --entire-thread flag so
it never receives the non-matching messages in the first place.

This makes it substantially faster.
---
 emacs/notmuch-show.el |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 30b26d1..31e6937 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -976,9 +976,9 @@ current buffer, if possible."
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
 	(replies (cadr tree)))
-    (if (or (not notmuch-show-elide-non-matching-messages)
-	    (plist-get msg :match))
-	(notmuch-show-insert-msg msg depth))
+    ;; 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))))
 
 (defun notmuch-show-insert-thread (thread depth)
@@ -1059,16 +1059,17 @@ function is used."
 	     (args (if notmuch-show-query-context
 		       (append (list "\'") basic-args
 			       (list "and (" notmuch-show-query-context ")\'"))
-		     (append (list "\'") basic-args (list "\'")))))
-	(notmuch-show-insert-forest (notmuch-query-get-threads
-				     (cons "--exclude=false" args)))
+		     (append (list "\'") basic-args (list "\'"))))
+	     (cli-args (when notmuch-show-elide-non-matching-messages
+			 (list "--entire-thread=false" "--exclude=false"))))
+
+	(notmuch-show-insert-forest (notmuch-query-get-threads (append cli-args args)))
 	;; If the query context reduced the results to nothing, run
 	;; the basic query.
 	(when (and (eq (buffer-size) 0)
 		   notmuch-show-query-context)
 	  (notmuch-show-insert-forest
-	   (notmuch-query-get-threads
-	    (cons "--exclude=false" basic-args)))))
+	   (notmuch-query-get-threads (append cli-args basic-args)))))
 
       (jit-lock-register #'notmuch-show-buttonise-links)
 
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-10 17:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-23 21:41 [PATCH 0/2] Make elide messages use cli side Mark Walters
2012-02-23 21:41 ` [PATCH 1/2] emacs/cli: remove entire-thread default from show: JSON Mark Walters
2012-02-23 21:45   ` Adam Wolfe Gordon
2012-02-23 22:04     ` Mark Walters
2012-02-23 21:41 ` [PATCH 2/2] emacs: make elide messages use notmuch-show for omitting messages Mark Walters
  -- strict thread matches above, loose matches on Subject: below --
2012-04-10 17:04 [PATCH 0/2] Allow JSON to use non-entire thread, and use for elide Mark Walters
2012-04-10 17:04 ` [PATCH 2/2] emacs: make elide messages use notmuch-show for omitting messages Mark Walters

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).