From: Mark Walters Date: Tue, 21 May 2013 14:27:47 +0000 (+0100) Subject: Re: [PATCH 5/5] emacs: Use streaming S-expr parser for search X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3c50a47ff3eb8cd929ad880ebc52a116a15348df;p=notmuch-archives.git Re: [PATCH 5/5] emacs: Use streaming S-expr parser for search --- diff --git a/f4/b6ad9c6cf98ed98dd1c1d4f3b608339302d25f b/f4/b6ad9c6cf98ed98dd1c1d4f3b608339302d25f new file mode 100644 index 000000000..9add9a27a --- /dev/null +++ b/f4/b6ad9c6cf98ed98dd1c1d4f3b608339302d25f @@ -0,0 +1,188 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 88A3A431FC0 + for ; Tue, 21 May 2013 07:27:57 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id Ewzg5Nalgrk8 for ; + Tue, 21 May 2013 07:27:51 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 58D8F431FB6 + for ; Tue, 21 May 2013 07:27:51 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1UenXZ-0007Rb-IR; Tue, 21 May 2013 15:27:50 +0100 +Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) + (envelope-from ) + id 1UenXY-00021j-PR; Tue, 21 May 2013 15:27:49 +0100 +From: Mark Walters +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH 5/5] emacs: Use streaming S-expr parser for search +In-Reply-To: <1368851472-5382-6-git-send-email-amdragon@mit.edu> +References: <1368851472-5382-1-git-send-email-amdragon@mit.edu> + <1368851472-5382-6-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 21 May 2013 15:27:47 +0100 +Message-ID: <87ip2c2ysc.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 93.97.24.31 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: b0822419b61b875fb8fac3e08803688d (of first 20000 bytes) +X-SpamAssassin-Score: -0.2 +X-SpamAssassin-SpamBar: / +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -0.2 points. + Summary of the scoring: + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.2 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 21 May 2013 14:27:57 -0000 + + +This patch and patch 3/5 look good to me. Do you intend to take out the +async json parser immediately after this goes in? If not then I think it +would be good to tweak the arguments/error handling in the json parser +so that it matches that in this sexp parser. + +Best wishes + +Mark + +On Sat, 18 May 2013, Austin Clements wrote: +> In addition to being the Right Thing to do, this noticeably improves +> the time taken to display the first page of search results, since it's +> roughly an order of magnitude faster than the JSON parser. +> Interestingly, it does *not* significantly improve the time to +> completely fill a large search buffer because for large search +> buffers, the cost of creating author invisibility overlays and +> inserting text (which slows down with more overlays) dominates. +> However, the time required to display the first page of results is +> generally more important to the user experience. +> --- +> emacs/notmuch.el | 13 +++---------- +> test/emacs | 10 +++------- +> 2 files changed, 6 insertions(+), 17 deletions(-) +> +> diff --git a/emacs/notmuch.el b/emacs/notmuch.el +> index b8d9c44..5a8c957 100644 +> --- a/emacs/notmuch.el +> +++ b/emacs/notmuch.el +> @@ -58,6 +58,7 @@ +> (require 'notmuch-hello) +> (require 'notmuch-maildir-fcc) +> (require 'notmuch-message) +> +(require 'notmuch-parser) +> +> (defcustom notmuch-search-result-format +> `(("date" . "%12s ") +> @@ -809,13 +810,6 @@ non-authors is found, assume that all of the authors match." +> (setq notmuch-search-target-thread "found") +> (goto-char beg))))) +> +> -(defun notmuch-search-show-error (string &rest objects) +> - (save-excursion +> - (goto-char (point-max)) +> - (insert "Error: Unexpected output from notmuch search:\n") +> - (insert (apply #'format string objects)) +> - (insert "\n"))) +> - +> (defun notmuch-search-process-filter (proc string) +> "Process and filter the output of \"notmuch search\"" +> (let ((results-buf (process-buffer proc)) +> @@ -829,8 +823,7 @@ non-authors is found, assume that all of the authors match." +> (save-excursion +> (goto-char (point-max)) +> (insert string)) +> - (notmuch-json-parse-partial-list 'notmuch-search-show-result +> - 'notmuch-search-show-error +> + (notmuch-sexp-parse-partial-list 'notmuch-search-show-result +> results-buf))))) +> +> (defun notmuch-search-tag-all (&optional tag-changes) +> @@ -933,7 +926,7 @@ Other optional parameters are used as follows: +> (save-excursion +> (let ((proc (notmuch-start-notmuch +> "notmuch-search" buffer #'notmuch-search-process-sentinel +> - "search" "--format=json" "--format-version=1" +> + "search" "--format=sexp" "--format-version=1" +> (if oldest-first +> "--sort=oldest-first" +> "--sort=newest-first") +> diff --git a/test/emacs b/test/emacs +> index d38ae8c..7d42abf 100755 +> --- a/test/emacs +> +++ b/test/emacs +> @@ -856,7 +856,7 @@ test_expect_success "Rendering HTML mail with images" \ +> test_begin_subtest "Search handles subprocess error exit codes" +> cat > notmuch_fail < #!/bin/sh +> -echo This is output +> +echo '()' +> exit 1 +> EOF +> chmod a+x notmuch_fail +> @@ -871,21 +871,19 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\")) +> (test-output))" +> sed -i -e 's/^\[.*\]$/[XXX]/' ERROR +> test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\ +> -Error: Unexpected output from notmuch search: +> -This is output +> End of search results. +> --- +> $PWD/notmuch_fail exited with status 1 (see *Notmuch errors* for more details) +> --- +> [XXX] +> $PWD/notmuch_fail exited with status 1 +> -command: $PWD/notmuch_fail search --format\=json --format-version\=1 --sort\=newest-first tag\:inbox +> +command: $PWD/notmuch_fail search --format\=sexp --format-version\=1 --sort\=newest-first tag\:inbox +> exit status: 1" +> +> test_begin_subtest "Search handles subprocess warnings" +> cat > notmuch_fail < #!/bin/sh +> -echo This is output +> +echo '()' +> echo This is a warning >&2 +> echo This is another warning >&2 +> exit 0 +> @@ -903,8 +901,6 @@ test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\")) +> (test-output))" +> sed -i -e 's/^\[.*\]$/[XXX]/' ERROR +> test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\ +> -Error: Unexpected output from notmuch search: +> -This is output +> End of search results. +> --- +> This is a warning (see *Notmuch errors* for more details) +> -- +> 1.7.10.4