From: Austin Clements Date: Sat, 1 Jun 2013 00:40:07 +0000 (+2000) Subject: [PATCH v3 5/6] emacs: Use streaming S-expr parser for search X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=62c3edd974d72694faf4f0514435c53d130fc292;p=notmuch-archives.git [PATCH v3 5/6] emacs: Use streaming S-expr parser for search --- diff --git a/85/019ebe17f65c3272264cd4b89740cc57f4029c b/85/019ebe17f65c3272264cd4b89740cc57f4029c new file mode 100644 index 000000000..3980239be --- /dev/null +++ b/85/019ebe17f65c3272264cd4b89740cc57f4029c @@ -0,0 +1,181 @@ +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 531B6429E31 + for ; Fri, 31 May 2013 17:40:28 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 DQC6wUIk8pOe for ; + Fri, 31 May 2013 17:40:22 -0700 (PDT) +Received: from dmz-mailsec-scanner-1.mit.edu (dmz-mailsec-scanner-1.mit.edu + [18.9.25.12]) + by olra.theworths.org (Postfix) with ESMTP id D7A2E431E82 + for ; Fri, 31 May 2013 17:40:16 -0700 (PDT) +X-AuditID: 1209190c-b7f566d000004c69-48-51a942f06008 +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP + id 85.73.19561.0F249A15; Fri, 31 May 2013 20:40:16 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id r510eDsq024662; + Fri, 31 May 2013 20:40:14 -0400 +Received: from drake.dyndns.org (c-76-21-105-205.hsd1.ca.comcast.net + [76.21.105.205]) (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r510eAvc020947 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Fri, 31 May 2013 20:40:12 -0400 +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1UiZrd-0003QY-Li; Fri, 31 May 2013 20:40:09 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH v3 5/6] emacs: Use streaming S-expr parser for search +Date: Fri, 31 May 2013 20:40:07 -0400 +Message-Id: <1370047208-12785-6-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1370047208-12785-1-git-send-email-amdragon@mit.edu> +References: <1370047208-12785-1-git-send-email-amdragon@mit.edu> +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsUixG6novvBaWWgwYoWVYvVc3ksrt+cyWzx + ZuU8Vgdmj52z7rJ7HP66kMXj2apbzAHMUVw2Kak5mWWpRfp2CVwZz+cqFVyXr3h/+CpjA+Nb + yS5GTg4JAROJN2+7mSBsMYkL99azdTFycQgJ7GOU+PS7iw0kISSwkVFi1w1OiMRpJon9Dzez + QyTmMkpMXckIYrMJaEhs278czBYRkJbYeXc2K4jNLBAnsWXKf7C4sICrROvOjcwgNouAqsTM + 6efA5vAKOEhcWNLJDnGFokT3swlgizkFHCXOX/3HDLHLQeLxiZPMExj5FzAyrGKUTcmt0s1N + zMwpTk3WLU5OzMtLLdI11MvNLNFLTSndxAgKLE5Jnh2Mbw4qHWIU4GBU4uHtWLUiUIg1say4 + MvcQoyQHk5Io72zHlYFCfEn5KZUZicUZ8UWlOanFhxglOJiVRHjz5wCV86YkVlalFuXDpKQ5 + WJTEeS+n3PQXEkhPLEnNTk0tSC2CycpwcChJ8L4EGSpYlJqeWpGWmVOCkGbi4AQZzgM0/BxI + DW9xQWJucWY6RP4Uo6KUOO8FkIQASCKjNA+uFxb5rxjFgV4R5uUGpgEhHmDSgOt+BTSYCWjw + E+vlIINLEhFSUg2M+bm631M11HsaZWQelQa4Hwy7PMlDc6Pa2oq4xwqmJ2WmsP4yLo8SNEle + dOz5IZMPxndSrwnMceD7y1BmuqAzfeayrxvDH891ypk+Z53CpWqnybevRexO4au/XuC4IX3b + BrXLET/5l0yJWb5I6HxK4Ra2Hg0D7b8NZxdZrXZznTVf+/GDuj4rJZbijERDLeai4kQAuVt/ + cNcCAAA= +Cc: tomi.ollila@iki.fi +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: Sat, 01 Jun 2013 00:40:28 -0000 + +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 < notmuch_fail <&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 +