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 059E840B964 for ; Fri, 8 Feb 2013 17:40:34 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 k3uCdQE9nvVY for ; Fri, 8 Feb 2013 17:40:33 -0800 (PST) Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7A1B040B961 for ; Fri, 8 Feb 2013 17:40:33 -0800 (PST) Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net ([156.34.82.78] helo=zancas.localnet) by tesseract.cs.unb.ca with esmtpsa (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1U3zQa-0005pA-90; Fri, 08 Feb 2013 21:40:30 -0400 Received: from bremner by zancas.localnet with local (Exim 4.80) (envelope-from ) id 1U3zQU-0005Tq-JK; Fri, 08 Feb 2013 21:40:22 -0400 From: david@tethera.net To: notmuch@notmuchmail.org Subject: [PATCH] contrib/nmbug: convert to use batch tagging. Date: Fri, 8 Feb 2013 21:40:19 -0400 Message-Id: <1360374019-20988-1-git-send-email-david@tethera.net> X-Mailer: git-send-email 1.7.10.4 X-Spam_bar: - Cc: David Bremner 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, 09 Feb 2013 01:40:34 -0000 From: David Bremner In the case of large changes to the database from git, one of main current bottlenecks is the large number of execs of notmuch tag. This avoids that by using use the batch tagging facilities as of notmuch 0.15. We use "spawn" directly rather than inventing a "notmuch_pipe", since it seems the only place we need to pipe to notmuch so far. --- This is only lightly tested; please make sure you have backups of your database. I'm not 100% sure about the indentation. No doubt Tomi will let me know if it can be improved. contrib/nmbug/nmbug | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/contrib/nmbug/nmbug b/contrib/nmbug/nmbug index f003ef9..c66c526 100755 --- a/contrib/nmbug/nmbug +++ b/contrib/nmbug/nmbug @@ -270,17 +270,22 @@ sub do_sync { $D_action = '-'; } - foreach my $pair (@{$status->{added}}) { + my $notmuch = spawn ({}, '|-', qw/notmuch tag --batch/) + or die 'notmuch tag --batch'; - notmuch ('tag', $A_action.$TAGPREFIX.$pair->{tag}, - 'id:'.$pair->{id}); + foreach my $pair (@{$status->{added}}) { + print $notmuch $A_action.$TAGPREFIX.$pair->{tag}, " -- ", + 'id:'.$pair->{id}; } foreach my $pair (@{$status->{deleted}}) { - notmuch ('tag', $D_action.$TAGPREFIX.$pair->{tag}, - 'id:'.$pair->{id}); + print $notmuch $D_action.$TAGPREFIX.$pair->{tag}, + 'id:'.$pair->{id}; } + unless (close $notmuch) { + die "'notmuch tag --batch' exited with nonzero value\n"; + } } -- 1.7.10.4