unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] contrib/nmbug: convert to use batch tagging.
@ 2013-02-09  1:40 david
  2013-02-13 14:47 ` Tomi Ollila
  0 siblings, 1 reply; 3+ messages in thread
From: david @ 2013-02-09  1:40 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner

From: David Bremner <bremner@debian.org>

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] contrib/nmbug: convert to use batch tagging.
  2013-02-09  1:40 [PATCH] contrib/nmbug: convert to use batch tagging david
@ 2013-02-13 14:47 ` Tomi Ollila
  2013-02-14  3:02   ` David Bremner
  0 siblings, 1 reply; 3+ messages in thread
From: Tomi Ollila @ 2013-02-13 14:47 UTC (permalink / raw)
  To: david, notmuch; +Cc: David Bremner

On Sat, Feb 09 2013, david@tethera.net wrote:

> From: David Bremner <bremner@debian.org>
>
> 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.
> ---

The code LGTM. Is there any quoting differences between these 2 
tagging methods ?

> This is only lightly tested; please make sure you have backups of your
> database.

Do I dare to test -- I'm lazy taking backups (I don't know how to take
one -- and especially how to restore one ;)

> I'm not 100% sure about the indentation. No doubt Tomi will let me
> know if it can be improved.

No doubt...

Tomi

>
>  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
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] contrib/nmbug: convert to use batch tagging.
  2013-02-13 14:47 ` Tomi Ollila
@ 2013-02-14  3:02   ` David Bremner
  0 siblings, 0 replies; 3+ messages in thread
From: David Bremner @ 2013-02-14  3:02 UTC (permalink / raw)
  To: Tomi Ollila, notmuch

Tomi Ollila <tomi.ollila@iki.fi> writes:

>
> The code LGTM. Is there any quoting differences between these 2 
> tagging methods ?
>

That's a good point. I added quoting easily enough, but as soon as I
did, I discovered the rest of nmbug has some issues with tags with
spaces in them.  I'll see how hard this is to fix.

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-02-14  3:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-09  1:40 [PATCH] contrib/nmbug: convert to use batch tagging david
2013-02-13 14:47 ` Tomi Ollila
2013-02-14  3:02   ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).