Re: Possible addtions to notmuch new ?
authorAustin Clements <amdragon@MIT.EDU>
Mon, 12 Aug 2013 14:34:26 +0000 (10:34 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:15 +0000 (09:56 -0800)
cd/c2e668921beac42934bd9ac7b6063697ca5c90 [new file with mode: 0644]

diff --git a/cd/c2e668921beac42934bd9ac7b6063697ca5c90 b/cd/c2e668921beac42934bd9ac7b6063697ca5c90
new file mode 100644 (file)
index 0000000..1ab4cd2
--- /dev/null
@@ -0,0 +1,153 @@
+Return-Path: <amdragon@mit.edu>\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 947BE431FBC\r
+       for <notmuch@notmuchmail.org>; Mon, 12 Aug 2013 07:34:41 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 jlc2fYe5+FOD for <notmuch@notmuchmail.org>;\r
+       Mon, 12 Aug 2013 07:34:35 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu\r
+       [18.9.25.14])\r
+       by olra.theworths.org (Postfix) with ESMTP id 4A18F431FAF\r
+       for <notmuch@notmuchmail.org>; Mon, 12 Aug 2013 07:34:35 -0700 (PDT)\r
+X-AuditID: 1209190e-b7f988e0000009a7-80-5208f277a9ec\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 79.10.02471.872F8025; Mon, 12 Aug 2013 10:34:32 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+       by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r7CEYUoX006416; \r
+       Mon, 12 Aug 2013 10:34:31 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r7CEYSnq030359\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
+       Mon, 12 Aug 2013 10:34:29 -0400\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1V8tCV-0006nu-KX; Mon, 12 Aug 2013 10:34:27 -0400\r
+Date: Mon, 12 Aug 2013 10:34:26 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Vladimir Marek <Vladimir.Marek@Oracle.COM>\r
+Subject: Re: Possible addtions to notmuch new ?\r
+Message-ID: <20130812143426.GA13257@mit.edu>\r
+References: <20130812093443.GB16684@virt.cz.oracle.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <20130812093443.GB16684@virt.cz.oracle.com>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42IRYrdT1634xBFkMPkVq8X1mzOZLTpu72Zz\r
+       YPJ4tuoWs8fHp7dYApiiuGxSUnMyy1KL9O0SuDJ6Vk5kKWiXqDj5zruB8Z1QFyMnh4SAicSE\r
+       Q8+YIWwxiQv31rN1MXJxCAnsY5SY+PstlLORUWJazwk2kCohgdNMEr23IiESSxglpnQvBmtn\r
+       EVCV2DNzHVgRm4CGxLb9yxlBbBEBPYlNm46xgtjMAtIS3343M4HYwgL6Ejev9rKA2LwCOhLz\r
+       JrczQSwwlzi4cjkTRFxQ4uTMJywQvVoSN/69BIpzgM1Z/o8DJMwpYCExc1YD2CpRARWJKSe3\r
+       sU1gFJqFpHsWku5ZCN0LGJlXMcqm5Fbp5iZm5hSnJusWJyfm5aUW6Rrr5WaW6KWmlG5iBAU1\r
+       pyTfDsavB5UOMQpwMCrx8GZ+5AgSYk0sK67MPcQoycGkJMq78wNQiC8pP6UyI7E4I76oNCe1\r
+       +BCjBAezkgiv2jygHG9KYmVValE+TEqag0VJnPfZ07OBQgLpiSWp2ampBalFMFkZDg4lCV4L\r
+       kD2CRanpqRVpmTklCGkmDk6Q4TxAw31AaniLCxJzizPTIfKnGHU5/qyc+4lRiCUvPy9VSpzX\r
+       A6RIAKQoozQPbg4sGb1iFAd6S5g3EKSKB5jI4Ca9AlrCBLTEqBlsSUkiQkqqgXHD2sOmllsk\r
+       3mz3nGeSGeoed1mkomPelpUWqxfXfXDpmNV0VOiPfur0aul134Qkf3Yv2WnROq3lU/w11zfr\r
+       HCYKyOcWuszhOLNUsVlKT+xA9KSJBtsnfpKq+aFx6MLe93Ez5aS3iGaVvTx3oiRu43rr0uV/\r
+       vAwUzzC9ucHQeN92odkUyykzoluUWIozEg21mIuKEwHNfNWjIQMAAA==\r
+Cc: notmuch@notmuchmail.org\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: Mon, 12 Aug 2013 14:34:41 -0000\r
+\r
+Quoth Vladimir Marek on Aug 12 at 11:34 am:\r
+> Hi,\r
+> \r
+> My mail setup is a directory containing several subdirectories each\r
+> subdirectory corresponds to one real mail account I am using. Each mail\r
+> account is synchronized differently - I am using offlineimap, fetchmeail\r
+> or even synthetically created emails (I am writing very simple jabber<->\r
+> mail gate).Every now and then I am running 'notmuch new' to discover new\r
+> emails and make them available in my MUA.\r
+> \r
+> That works pretty well, but has some disadvantages too\r
+>  - notmuch new takes very long time (30s) during which the notmuch\r
+>    database seems to be locked for any other updates from my MUA\r
+>  - notmuch new takes long time because it always processes my archive\r
+>    dir containing many files. That's mostly un-necessary as typically\r
+>    there's no new mail delivered\r
+\r
+Could you try this patch?  It's basically untested other than passing\r
+the test suite, though in principle the worst harm it could do is make\r
+notmuch new miss new messages or think renames are deletions.  If it\r
+helps significantly with your performance problems, I'll clean it up\r
+and add a test.\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index faa33f1..196c5cb 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -323,6 +323,9 @@ add_files (notmuch_database_t *notmuch,\r
+     }\r
+     db_mtime = directory ? notmuch_directory_get_mtime (directory) : 0;\r
\r
++    if (directory && db_mtime == fs_mtime && st.st_nlink == 2)\r
++       goto DONE;\r
++\r
+     /* If the database knows about this directory, then we sort based\r
+      * on strcmp to match the database sorting. Otherwise, we can do\r
+      * inode-based sorting for faster filesystem operation. */\r
+\r
+\r
+>  - I don't have the possibility of passing new mails through procmail.\r
+>    That would be useful for example for changing cron mail subjects,\r
+>    putting related automated mails into threads (bugzilla, etc.).\r
+> \r
+> \r
+> I was thinking that if we could split the new mail discovery from\r
+> it's processing, it would solve the disadvantages I'm facing. Something\r
+> like\r
+> \r
+> notmuch new --verbose --dry-run [dir] | my_filter | notmuch insert -\r
+> \r
+> It would work\r
+>  - --dry-run would not lock and change the database\r
+>  - --verbose would print the changes to stdout/stderr. Something like:\r
+> \r
+> new mail/file.1\r
+> new mail/file.2\r
+> deleted mail/file.3\r
+> renamed mail/file.4 mail/file.5\r
+> ...\r
+> \r
+> [dir] would limit the scope of 'notmuch' new search to dir and it's\r
+> subdirectories. Alternatively we could have set of include or exclude\r
+> rules similarly to rsync (for example), but [dir] is easier to\r
+> implement.\r
+> \r
+> 'my_filter' would be my script which could change the contents of emails\r
+> before they are inserted into notmuch database.\r
+> \r
+> Notmuch insert would be able to not only add new mails, but also remove\r
+> old ones or note that the file was renamed.\r
+> \r
+> How would this sound?\r
+> \r
+> I'm not saying I would implement this, I'm rather curious where would\r
+> you like to see notmuch in the future.\r
+> \r
+> Cheers\r