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 E9D8E431FAF for ; Wed, 8 Feb 2012 08:58:08 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 1.7 X-Spam-Level: * X-Spam-Status: No, score=1.7 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=2.499, 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 MlKvkJ0h8SJm for ; Wed, 8 Feb 2012 08:58:08 -0800 (PST) Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id E8FA0431FAE for ; Wed, 8 Feb 2012 08:58:07 -0800 (PST) Received: by bkcjk7 with SMTP id jk7so807835bkc.26 for ; Wed, 08 Feb 2012 08:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type; bh=hJYQuOxjWR6pYUSe6AL5aWfazoo7547u421qFrfnJ1M=; b=M5fHnxKu2F19zg1PX68tFXc6tA6Cr3TVgr+ISxX2zC0BXAirD9PEQnB32Cv1wVH2++ OHQFMAH3Ej9rEaOY5gq1d7I644rR9lmvRUPDrCivPYG7kbBcMSuOW/p4EtBWFNXJ7X68 kEvgnobFpiGBJ7VYH3P72BloCbtSyeBcCA04c= Received: by 10.205.127.147 with SMTP id ha19mr3425996bkc.64.1328720286614; Wed, 08 Feb 2012 08:58:06 -0800 (PST) Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id x20sm6232651bka.9.2012.02.08.08.58.05 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 08 Feb 2012 08:58:05 -0800 (PST) From: Dmitry Kurochkin To: David Edmondson , notmuch@notmuchmail.org Subject: Re: [PATCH v4] emacs: Call "notmuch tag" once when applying tag changes to a thread. In-Reply-To: <1328719395-6333-1-git-send-email-dme@dme.org> References: <1328632303-31877-1-git-send-email-jani@nikula.org> <1328719395-6333-1-git-send-email-dme@dme.org> User-Agent: Notmuch/0.11.1+167~g6e72434 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Wed, 08 Feb 2012 20:56:48 +0400 Message-ID: <87sjil8drj.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: Wed, 08 Feb 2012 16:58:09 -0000 On Wed, 8 Feb 2012 16:43:15 +0000, David Edmondson wrote: > Optimize thread tagging by combining all the tagging operations to a > single "notmuch tag" call. > > For threads in the order of tens or a hundred inbox tagged messages, > this gives a noticeable speedup. On two different machines, archiving > a thread of about 50 inbox tagged messages goes down from 10+ seconds > to about 0.5 seconds. > > The bottleneck is not within emacs; the same behaviour can be observed > in the CLI. This approach has the added benefit of being more > reliable: any of the individual tagging operations might face a locked > database, leading to partial results. > > This introduces a limitation to the number of messages that can be > archived at the same time (through ARG_MAX limiting the command > line). While at least on Linux this seems more like a theoretical > limitation than a real one, it could be avoided by archiving at most a > few hundred messages at a time. > > Based on code from Jani Nikula . > --- > > v4: > - Rebased after Dmitry's tagging changes (yay!). > Now, that my tagging changes are pushed, the same effect can be (and should be) achieved by some code cleanup and function reuse. This patch is obsoleted by [1]. Regards, Dmitry [1] id:"1328719731-13402-1-git-send-email-dmitry.kurochkin@gmail.com" > emacs/notmuch-show.el | 18 +++++++++++------- > 1 files changed, 11 insertions(+), 7 deletions(-) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index faa9f9b..9294bc8 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -1599,14 +1599,18 @@ argument, hide all of the messages." > (backward-button 1)) > > (defun notmuch-show-tag-thread-internal (tag &optional remove) > - "Add tag to the current set of messages. > + "Add TAG to the current set of messages. > > -If the remove switch is given, tags will be removed instead of > -added." > - (goto-char (point-min)) > - (let ((op (if remove "-" "+"))) > - (loop do (notmuch-show-tag-message (concat op tag)) > - until (not (notmuch-show-goto-message-next))))) > +If REMOVE is non-nil, TAG will be removed rather than added." > + (save-excursion > + (goto-char (point-min)) > + (let ((tag-op (concat (if remove "-" "+") tag)) > + (message-ids > + (loop collect (notmuch-show-get-message-id) > + until (not (notmuch-show-goto-message-next))))) > + (if message-ids > + (notmuch-tag (mapconcat #'identity message-ids " OR ") > + tag-op))))) > > (defun notmuch-show-add-tag-thread (tag) > "Add tag to all messages in the current thread." > -- > 1.7.8.3 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch