1 Return-Path: <bremner@tesseract.cs.unb.ca>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id 9493B6DE1BAD
\r
6 for <notmuch@notmuchmail.org>; Sun, 5 Apr 2015 16:02:56 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.529 tagged_above=-999 required=5 tests=[AWL=0.519,
\r
12 T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled
\r
13 Received: from arlo.cworth.org ([127.0.0.1])
\r
14 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id lew0B-DmIy94 for <notmuch@notmuchmail.org>;
\r
16 Sun, 5 Apr 2015 16:02:55 -0700 (PDT)
\r
17 Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net
\r
19 by arlo.cworth.org (Postfix) with ESMTPS id 02D6A6DE1BA5
\r
20 for <notmuch@notmuchmail.org>; Sun, 5 Apr 2015 16:02:51 -0700 (PDT)
\r
21 Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim
\r
22 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)
\r
23 id 1YetXS-0002ou-AV; Sun, 05 Apr 2015 23:01:10 +0000
\r
24 Received: (nullmailer pid 2237 invoked by uid 1000); Sun, 05 Apr 2015
\r
26 From: David Bremner <david@tethera.net>
\r
27 To: notmuch@notmuchmail.org
\r
28 Subject: [WIP2 01/12] lib: Only sync modified message documents
\r
29 Date: Mon, 6 Apr 2015 07:59:03 +0900
\r
30 Message-Id: <1428274754-1698-2-git-send-email-david@tethera.net>
\r
31 X-Mailer: git-send-email 2.1.4
\r
32 In-Reply-To: <1428274754-1698-1-git-send-email-david@tethera.net>
\r
33 References: <1428274754-1698-1-git-send-email-david@tethera.net>
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.18
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Sun, 05 Apr 2015 23:02:56 -0000
\r
48 From: Austin Clements <amdragon@mit.edu>
\r
50 Previously, we updated the database copy of a message on every call to
\r
51 _notmuch_message_sync, even if nothing had changed. In particular,
\r
52 this always happens on a thaw, so a freeze/thaw pair with no
\r
53 modifications between still caused a database update.
\r
55 We only modify message documents in a handful of places, so keep track
\r
56 of whether the document has been modified and only sync it when
\r
57 necessary. This will be particularly important when we add message
\r
60 lib/message.cc | 12 ++++++++++++
\r
61 1 file changed, 12 insertions(+)
\r
63 diff --git a/lib/message.cc b/lib/message.cc
\r
64 index 5bc7aff..1ddce3c 100644
\r
65 --- a/lib/message.cc
\r
66 +++ b/lib/message.cc
\r
67 @@ -43,6 +43,9 @@ struct visible _notmuch_message {
\r
68 * if each flag has been initialized. */
\r
69 unsigned long lazy_flags;
\r
71 + /* Message document modified since last sync */
\r
72 + notmuch_bool_t modified;
\r
74 Xapian::Document doc;
\r
75 Xapian::termcount termpos;
\r
77 @@ -539,6 +542,7 @@ _notmuch_message_remove_terms (notmuch_message_t *message, const char *prefix)
\r
80 message->doc.remove_term ((*i));
\r
81 + message->modified = TRUE;
\r
82 } catch (const Xapian::InvalidArgumentError) {
\r
83 /* Ignore failure to remove non-existent term. */
\r
85 @@ -793,6 +797,7 @@ void
\r
86 _notmuch_message_clear_data (notmuch_message_t *message)
\r
88 message->doc.set_data ("");
\r
89 + message->modified = TRUE;
\r
93 @@ -990,6 +995,7 @@ _notmuch_message_set_header_values (notmuch_message_t *message,
\r
94 Xapian::sortable_serialise (time_value));
\r
95 message->doc.add_value (NOTMUCH_VALUE_FROM, from);
\r
96 message->doc.add_value (NOTMUCH_VALUE_SUBJECT, subject);
\r
97 + message->modified = TRUE;
\r
100 /* Synchronize changes made to message->doc out into the database. */
\r
101 @@ -1001,8 +1007,12 @@ _notmuch_message_sync (notmuch_message_t *message)
\r
102 if (message->notmuch->mode == NOTMUCH_DATABASE_MODE_READ_ONLY)
\r
105 + if (! message->modified)
\r
108 db = static_cast <Xapian::WritableDatabase *> (message->notmuch->xapian_db);
\r
109 db->replace_document (message->doc_id, message->doc);
\r
110 + message->modified = FALSE;
\r
113 /* Delete a message document from the database. */
\r
114 @@ -1077,6 +1087,7 @@ _notmuch_message_add_term (notmuch_message_t *message,
\r
115 return NOTMUCH_PRIVATE_STATUS_TERM_TOO_LONG;
\r
117 message->doc.add_term (term, 0);
\r
118 + message->modified = TRUE;
\r
120 talloc_free (term);
\r
122 @@ -1145,6 +1156,7 @@ _notmuch_message_remove_term (notmuch_message_t *message,
\r
125 message->doc.remove_term (term);
\r
126 + message->modified = TRUE;
\r
127 } catch (const Xapian::InvalidArgumentError) {
\r
128 /* We'll let the philosopher's try to wrestle with the
\r
129 * question of whether failing to remove that which was not
\r