1 Return-Path: <amthrax@awakening.csail.mit.edu>
\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 olra.theworths.org (Postfix) with ESMTP id D20C3431FB6
\r
6 for <notmuch@notmuchmail.org>; Thu, 9 Dec 2010 13:00:44 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id VIL38PYfZ7fM for <notmuch@notmuchmail.org>;
\r
16 Thu, 9 Dec 2010 13:00:42 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-6.mit.edu (DMZ-MAILSEC-SCANNER-6.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id BAF1941A557
\r
20 for <notmuch@notmuchmail.org>; Thu, 9 Dec 2010 13:00:35 -0800 (PST)
\r
21 X-AuditID: 12074423-b7bd0ae000000a00-b8-4d01437397a7
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-6.mit.edu (Symantec Brightmail Gateway) with
\r
24 SMTP id 07.2A.02560.373410D4; Thu, 9 Dec 2010 16:00:35 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id oB9L0Zh0011388;
\r
27 Thu, 9 Dec 2010 16:00:35 -0500
\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id oB9L0Y4U010114
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Thu, 9 Dec 2010 16:00:35 -0500 (EST)
\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.72)
\r
35 (envelope-from <amthrax@awakening.csail.mit.edu>)
\r
36 id 1PQnbO-0007Hv-42; Thu, 09 Dec 2010 16:00:34 -0500
\r
37 From: Austin Clements <amdragon@MIT.EDU>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH 4/5] Add the file name list to the unified message metadata
\r
41 Date: Thu, 9 Dec 2010 15:59:55 -0500
\r
42 Message-Id: <1291928396-27937-5-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.2.3
\r
44 In-Reply-To: <1291928396-27937-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1291928396-27937-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker: AAAAARbjX5o=
\r
47 Cc: Austin Clements <amdragon@mit.edu>
\r
48 X-BeenThere: notmuch@notmuchmail.org
\r
49 X-Mailman-Version: 2.1.13
\r
51 List-Id: "Use and development of the notmuch mail system."
\r
52 <notmuch.notmuchmail.org>
\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
56 List-Post: <mailto:notmuch@notmuchmail.org>
\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
60 X-List-Received-Date: Thu, 09 Dec 2010 21:00:45 -0000
\r
62 Even if the caller never uses the file names, there is little cost to
\r
63 simply fetching the file name terms. However, retrieving the full
\r
64 paths requires additional database work, so the expansion from terms
\r
65 to full paths is performed lazily.
\r
67 This also simplifies clearing the filename cache, since that's now
\r
68 handled by the generic metadata cache code.
\r
70 This further reduces my inbox search from 3.102 seconds before the
\r
71 unified metadata pass to 2.206 seconds (1.4X faster).
\r
73 lib/message.cc | 52 +++++++++++++++++++++++++++++-----------------------
\r
74 1 files changed, 29 insertions(+), 23 deletions(-)
\r
76 diff --git a/lib/message.cc b/lib/message.cc
\r
77 index dbf683c..adb205f 100644
\r
78 --- a/lib/message.cc
\r
79 +++ b/lib/message.cc
\r
80 @@ -32,6 +32,7 @@ struct _notmuch_message {
\r
84 + notmuch_string_list_t *filename_term_list;
\r
85 notmuch_string_list_t *filename_list;
\r
87 notmuch_message_file_t *message_file;
\r
88 @@ -101,6 +102,7 @@ _notmuch_message_create_for_document (const void *talloc_owner,
\r
89 message->message_id = NULL;
\r
90 message->thread_id = NULL;
\r
91 message->in_reply_to = NULL;
\r
92 + message->filename_term_list = NULL;
\r
93 message->filename_list = NULL;
\r
94 message->message_file = NULL;
\r
95 message->author = NULL;
\r
96 @@ -292,6 +294,7 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message)
\r
97 Xapian::TermIterator i, end;
\r
98 const char *thread_prefix = _find_prefix ("thread"),
\r
99 *id_prefix = _find_prefix ("id"),
\r
100 + *filename_prefix = _find_prefix ("file-direntry"),
\r
101 *replyto_prefix = _find_prefix ("replyto");
\r
103 /* We do this all in a single pass because Xapian decompresses the
\r
104 @@ -314,8 +317,16 @@ _notmuch_message_ensure_metadata (notmuch_message_t *message)
\r
105 message->message_id =
\r
106 _notmuch_message_get_term (message, i, end, id_prefix);
\r
108 + /* Get filename list. Here we get only the terms. We lazily
\r
109 + * expand them to full file names when needed in
\r
110 + * _notmuch_message_ensure_filename_list. */
\r
111 + assert (strcmp (id_prefix, filename_prefix) < 0);
\r
112 + if (!message->filename_term_list && !message->filename_list)
\r
113 + message->filename_term_list =
\r
114 + _notmuch_get_terms_with_prefix (message, i, end, filename_prefix);
\r
117 - assert (strcmp (id_prefix, replyto_prefix) < 0);
\r
118 + assert (strcmp (filename_prefix, replyto_prefix) < 0);
\r
119 if (!message->in_reply_to)
\r
120 message->in_reply_to =
\r
121 _notmuch_message_get_term (message, i, end, replyto_prefix);
\r
122 @@ -334,6 +345,12 @@ _notmuch_message_invalidate_metadata (notmuch_message_t *message,
\r
123 message->thread_id = NULL;
\r
126 + if (strcmp ("file-direntry", prefix_name) == 0) {
\r
127 + talloc_free (message->filename_term_list);
\r
128 + talloc_free (message->filename_list);
\r
129 + message->filename_term_list = message->filename_list = NULL;
\r
132 if (strcmp ("replyto", prefix_name) == 0) {
\r
133 talloc_free (message->in_reply_to);
\r
134 message->in_reply_to = NULL;
\r
135 @@ -433,11 +450,6 @@ _notmuch_message_add_filename (notmuch_message_t *message,
\r
136 void *local = talloc_new (message);
\r
139 - if (message->filename_list) {
\r
140 - talloc_free (message->filename_list);
\r
141 - message->filename_list = NULL;
\r
144 if (filename == NULL)
\r
145 INTERNAL_ERROR ("Message filename cannot be NULL.");
\r
147 @@ -504,21 +516,18 @@ _notmuch_message_clear_data (notmuch_message_t *message)
\r
149 _notmuch_message_ensure_filename_list (notmuch_message_t *message)
\r
151 - const char *prefix = _find_prefix ("file-direntry");
\r
152 - int prefix_len = strlen (prefix);
\r
153 - Xapian::TermIterator i;
\r
154 + notmuch_string_node_t *node;
\r
156 if (message->filename_list)
\r
159 - message->filename_list = _notmuch_string_list_create (message);
\r
160 + if (!message->filename_term_list)
\r
161 + _notmuch_message_ensure_metadata (message);
\r
163 - i = message->doc.termlist_begin ();
\r
164 - i.skip_to (prefix);
\r
165 + message->filename_list = _notmuch_string_list_create (message);
\r
166 + node = message->filename_term_list->head;
\r
168 - if (i == message->doc.termlist_end () ||
\r
169 - strncmp ((*i).c_str (), prefix, prefix_len))
\r
172 /* A message document created by an old version of notmuch
\r
173 * (prior to rename support) will have the filename in the
\r
174 * data of the document rather than as a file-direntry term.
\r
175 @@ -537,19 +546,13 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message)
\r
179 - for (; i != message->doc.termlist_end (); i++) {
\r
180 + for (; node; node = node->next) {
\r
181 void *local = talloc_new (message);
\r
182 const char *db_path, *directory, *basename, *filename;
\r
183 char *colon, *direntry = NULL;
\r
184 unsigned int directory_id;
\r
186 - /* Terminate loop at first term without desired prefix. */
\r
187 - if (strncmp ((*i).c_str (), prefix, prefix_len))
\r
190 - direntry = talloc_strdup (local, (*i).c_str ());
\r
192 - direntry += prefix_len;
\r
193 + direntry = node->string;
\r
195 directory_id = strtol (direntry, &colon, 10);
\r
197 @@ -577,6 +580,9 @@ _notmuch_message_ensure_filename_list (notmuch_message_t *message)
\r
199 talloc_free (local);
\r
202 + talloc_free (message->filename_term_list);
\r
203 + message->filename_term_list = NULL;
\r