Re: [PATCH 0/5] notmuch batch count
authorMark Walters <markwalters1009@gmail.com>
Tue, 15 Jan 2013 23:43:41 +0000 (23:43 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:07 +0000 (09:53 -0800)
bb/d3be5cbb8af3937986a951bbc88464c94823d7 [new file with mode: 0644]

diff --git a/bb/d3be5cbb8af3937986a951bbc88464c94823d7 b/bb/d3be5cbb8af3937986a951bbc88464c94823d7
new file mode 100644 (file)
index 0000000..d230304
--- /dev/null
@@ -0,0 +1,196 @@
+Return-Path: <m.walters@qmul.ac.uk>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id CEDC2431FBC\r
+       for <notmuch@notmuchmail.org>; Tue, 15 Jan 2013 15:43:45 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+       tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+       NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id G6h2ZyYz4Ygw for <notmuch@notmuchmail.org>;\r
+       Tue, 15 Jan 2013 15:43:45 -0800 (PST)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id DEF3B431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 15 Jan 2013 15:43:44 -0800 (PST)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+       by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1TvGAM-0003nV-Ra; Tue, 15 Jan 2013 23:43:41 +0000\r
+Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
+       by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1TvGAM-0001ET-Ev; Tue, 15 Jan 2013 23:43:38 +0000\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Jani Nikula <jani@nikula.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 0/5] notmuch batch count\r
+In-Reply-To: <cover.1358273133.git.jani@nikula.org>\r
+References: <cover.1358273133.git.jani@nikula.org>\r
+User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Tue, 15 Jan 2013 23:43:41 +0000\r
+Message-ID: <8738y2ui4y.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 93.97.24.31\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: c33bdbdeee0d570020f8373a98493d2c (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+       determine if it is\r
+       spam. We require at least 5.0 points to mark a message as spam.\r
+       This message scored -1.8 points.\r
+       Summary of the scoring: \r
+       * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+       *      medium trust\r
+       *      [138.37.6.40 listed in list.dnswl.org]\r
+       * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+       provider *      (markwalters1009[at]gmail.com)\r
+       *  0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Tue, 15 Jan 2013 23:43:45 -0000\r
+\r
+\r
+On Tue, 15 Jan 2013, Jani Nikula <jani@nikula.org> wrote:\r
+> Hi all -\r
+>\r
+> Notmuch remote usage [1] is a pretty handy way of accessing a notmuch\r
+> database on a remote server. However, the more you have saved searches\r
+> and tags, the slower notmuch-hello becomes, and it ends up being by and\r
+> far the biggest usability issue with remote notmuch. This is because\r
+> notmuch-hello issues a separate 'notmuch count' for each saved search\r
+> and tag.\r
+>\r
+> One could argue that notmuch-hello should be fixed somehow, but I chose\r
+> to try another route: batch support for notmuch count. This enables\r
+> notmuch-hello to get the counts for all the saved searches or tags in a\r
+> single call. The performance improvement is huge in remote usage, but\r
+> it's not limited to that. Regular local usage benefits from it too, but\r
+> it's not as obviously noticeable.\r
+\r
+This series looks good to me (that is the code looks fine).\r
+\r
+Two questions are:\r
+\r
+Do we want this functionality? I think it is useful even on local setups\r
+particularly if people have lots of tags (the section that shows all\r
+tags can be quite noticeably sped up). It is a substantial improvement\r
+on remote setups but I am not sure if that is sufficiently common to\r
+warrant the change. At least the code path is the same so it will get\r
+enough testing.\r
+\r
+Secondly, if we do the functionality should it be more general so that\r
+it can do searches etc too. I think this is less clear. Count is likely\r
+to be the most useful one since running several (simultaneous) counts is\r
+probably more common than running several simultaneous searches.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+>\r
+> Here's a script that demonstrates one-by-one count vs. batch count,\r
+> locally and over ssh (assuming ssh key authentication is set up), over\r
+> 10 iterations:\r
+>\r
+> #!/bin/bash\r
+>\r
+> echo "tag count:"\r
+> notmuch search --output=tags "*" | wc -l\r
+>\r
+> for remote in "" "ssh example.com"; do\r
+>     export remote\r
+>     echo "one-by-one count:"\r
+>     time sh -c 'for i in `seq 10`; do notmuch search --format=text0 --output=tags "*" | xargs -0 -n 1 -I "{}" $remote notmuch count tag:"{}" > /dev/null; done'\r
+>\r
+>     echo "batch count:"\r
+>     time sh -c 'for i in `seq 10`; do notmuch search --format=text --output=tags "*" | sed "s/.*/tag:\"\0\"/" | $remote notmuch count --batch > /dev/null; done'\r
+> done\r
+>\r
+> And here's the output of it in my setup:\r
+>\r
+> tag count:\r
+> 36\r
+> one-by-one count:\r
+>\r
+> real 0m2.349s\r
+> user 0m0.552s\r
+> sys  0m0.868s\r
+> batch count:\r
+>\r
+> real 0m0.179s\r
+> user 0m0.120s\r
+> sys  0m0.064s\r
+> one-by-one count:\r
+>\r
+> real 0m56.527s\r
+> user 0m1.424s\r
+> sys  0m1.164s\r
+> batch count:\r
+>\r
+> real 0m2.407s\r
+> user 0m0.068s\r
+> sys  0m0.040s\r
+>\r
+> As can be seen, in local usage (the first pair of results) the speedup\r
+> is more than 10x, although one-by-one notmuch count is usually\r
+> sufficiently fast. The difference is more noticeable in remote use (the\r
+> second pair of results), where the speedup is 20x here, and any\r
+> additional, occasional network latency is multiplied by tag count. (That\r
+> result is actually faster than usual for me, but it's still 5+ seconds\r
+> to display or refresh notmuch-hello.)\r
+>\r
+> Mark has written a patch that I've been using to switch notmuch-hello to\r
+> use batch count. That has made me switch from running notmuch in ssh to\r
+> using remote notmuch. The great thing is that we could switch to using\r
+> that in Emacs with no special casing for remote usage, and it would\r
+> speed things up also in local use. I'm expecting Mark to post his patch\r
+> in reply to this series.\r
+>\r
+> Mark actually wrote the elisp part based on the rough idea prior to any\r
+> of this cli plumbing, so I felt obliged to follow up. So thanks Mark!\r
+>\r
+>\r
+> BR,\r
+> Jani.\r
+>\r
+>\r
+> [1] http://notmuchmail.org/remoteusage/ (the page could use some\r
+> cleanup; it's really not nearly as complicated as the page suggests)\r
+>\r
+>\r
+> Jani Nikula (5):\r
+>   cli: remove useless strdup\r
+>   cli: extract count printing to a separate function in notmuch count\r
+>   cli: add --batch option to notmuch count\r
+>   man: document notmuch count --batch and --input options\r
+>   test: notmuch count --batch and --input options\r
+>\r
+>  man/man1/notmuch-count.1 |   20 +++++++++\r
+>  notmuch-count.c          |  111 +++++++++++++++++++++++++++++++++++-----------\r
+>  test/count               |   46 +++++++++++++++++++\r
+>  3 files changed, 150 insertions(+), 27 deletions(-)\r
+>\r
+> -- \r
+> 1.7.10.4\r