v3 of message properties patches
[notmuch-archives.git] / 8f / 6a5a2cb1423bc0fd92525fb2d3d277da9bdb64
1 Return-Path: <amdragon@gmail.com>\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 719F0431FD0\r
6         for <notmuch@notmuchmail.org>; Tue, 25 Jan 2011 14:42:35 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.698\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.698 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
13         HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id zuGEd-dEYTpd for <notmuch@notmuchmail.org>;\r
17         Tue, 25 Jan 2011 14:42:34 -0800 (PST)\r
18 Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com\r
19         [209.85.216.181]) (using TLSv1 with cipher RC4-MD5 (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 33969431FB6\r
22         for <notmuch@notmuchmail.org>; Tue, 25 Jan 2011 14:42:34 -0800 (PST)\r
23 Received: by qyk12 with SMTP id 12so350190qyk.5\r
24         for <notmuch@notmuchmail.org>; Tue, 25 Jan 2011 14:42:31 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=domainkey-signature:mime-version:sender:in-reply-to:references:date\r
27         :x-google-sender-auth:message-id:subject:from:to:cc:content-type;\r
28         bh=KUs+RtmeokD9+CDz33kGAvp+xkCpVLUXIaUCaNX/O4A=;\r
29         b=L763dj//C7XFVtzeRTt8G6LL20Rg1aEfZQ7cirQqyjTdctnmfaX/RCy42cOmsSi6dC\r
30         k5ElRzHShkXr6ikw+ivQIKuzwqfXIl3LBzjNiBjMnViYc3LCJ+iA8+dtzXWFniRCNzJm\r
31         ExxkebLXXt8P8L7bS8plf5eA4AjZ1oOxVRIAM=\r
32 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
33         h=mime-version:sender:in-reply-to:references:date\r
34         :x-google-sender-auth:message-id:subject:from:to:cc:content-type;\r
35         b=P7CILKt6GCgMRoaCVRYztoQlRPaYbFI7ouExdDHBgHaxof/T2+cRy+DE53MDucG3nF\r
36         KU8tVhqGrF/o+fXIZlkqy0iAEfqxMxREnEcwkvySGmdv2rSSlOq/2F6t/Js7K4K74Jm+\r
37         HDubIyZ4sVXVl/U+H8xbNNAd7hIrPOwJwzoCA=\r
38 MIME-Version: 1.0\r
39 Received: by 10.229.217.133 with SMTP id hm5mr5277348qcb.40.1295995350772;\r
40         Tue, 25 Jan 2011 14:42:30 -0800 (PST)\r
41 Sender: amdragon@gmail.com\r
42 Received: by 10.229.97.143 with HTTP; Tue, 25 Jan 2011 14:42:30 -0800 (PST)\r
43 In-Reply-To: <1295603977-14326-3-git-send-email-sojkam1@fel.cvut.cz>\r
44 References: <1295603977-14326-1-git-send-email-sojkam1@fel.cvut.cz>\r
45         <1295603977-14326-3-git-send-email-sojkam1@fel.cvut.cz>\r
46 Date: Tue, 25 Jan 2011 17:42:30 -0500\r
47 X-Google-Sender-Auth: 10buYVdcvusHvj9TBZFPeqs9hF4\r
48 Message-ID: <AANLkTinsC+89yx7jGUaB8PLiftLjyTr7gosUDgAC_g0S@mail.gmail.com>\r
49 Subject: Re: [PATCH 1/3] new: Do not defer maildir flag synchronization during\r
50         the first run\r
51 From: Austin Clements <amdragon@mit.edu>\r
52 To: Michal Sojka <sojkam1@fel.cvut.cz>\r
53 Content-Type: multipart/alternative; boundary=0016361e81a2836fbe049ab36e8f\r
54 Cc: notmuch@notmuchmail.org\r
55 X-BeenThere: notmuch@notmuchmail.org\r
56 X-Mailman-Version: 2.1.13\r
57 Precedence: list\r
58 List-Id: "Use and development of the notmuch mail system."\r
59         <notmuch.notmuchmail.org>\r
60 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
62 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
63 List-Post: <mailto:notmuch@notmuchmail.org>\r
64 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
65 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
66         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
67 X-List-Received-Date: Tue, 25 Jan 2011 22:42:35 -0000\r
68 \r
69 --0016361e81a2836fbe049ab36e8f\r
70 Content-Type: text/plain; charset=ISO-8859-1\r
71 \r
72 Wouldn't this be simpler and more general?\r
73 \r
74 --- a/notmuch-new.c\r
75 +++ b/notmuch-new.c\r
76 @@ -419,12 +419,11 @@ add_files_recursive (notmuch_database_t *notmuch,\r
77         case NOTMUCH_STATUS_SUCCESS:\r
78             state->added_messages++;\r
79             for (tag=state->new_tags; *tag != NULL; tag++)\r
80                 notmuch_message_add_tag (message, *tag);\r
81             /* Defer sync of maildir flags until after old filenames\r
82              * are removed in the case of a rename. */\r
83             if (state->synchronize_flags == TRUE)\r
84 -               _filename_list_add (state->message_ids_to_sync,\r
85 -                                   notmuch_message_get_message_id\r
86 (message));\r
87 +               notmuch_message_maildir_flags_to_tags (message);\r
88             break;\r
89         /* Non-fatal issues (go on to next file) */\r
90         case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:\r
91 \r
92 The idea is that, if notmuch_database_add_message\r
93 returns NOTMUCH_STATUS_SUCCESS, then we know this is a new message (and not\r
94 a rename or anything complicated) and thus might as well perform the flag\r
95 synchronization immediately.  If it\r
96 returns NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID, then it could be a rename (or\r
97 something more complicated), and so we defer the flag synchronization like\r
98 usual.  This works for any new messages, regardless of whether this is the\r
99 initial import or not.\r
100 \r
101 I believe my reasoning is correct.  At least, it passes the maildir sync\r
102 test cases, so if it isn't correct, then we need more maildir sync tests.\r
103 \r
104 On Fri, Jan 21, 2011 at 4:59 AM, Michal Sojka <sojkam1@fel.cvut.cz> wrote:\r
105 \r
106 > When notmuch new is run for the first time, it is not necessary to defer\r
107 > maildir flags synchronization to later because we already know that no\r
108 > files will be removed.\r
109 >\r
110 > Performing the maildinr flag synchronization immediately after the\r
111 > message is added to the database has the advantage that the message is\r
112 > likely hot in the disk cache so the synchronization is faster.\r
113 > Additionally, we also save one database query for each message, which\r
114 > must be performed when the operation is deferred.\r
115 >\r
116 > Without this patchi, the first notmuch new of 200k messages (3 GB) took\r
117 > 1h and 46m out of which 20m was maildir flags synchronization. With this\r
118 > patch, the whole operation took only 1h and 36m.\r
119 > ---\r
120 >  notmuch-new.c |   36 ++++++++++++++++++++++++++----------\r
121 >  1 files changed, 26 insertions(+), 10 deletions(-)\r
122 >\r
123 > diff --git a/notmuch-new.c b/notmuch-new.c\r
124 > index cdf8513..a2af045 100644\r
125 > --- a/notmuch-new.c\r
126 > +++ b/notmuch-new.c\r
127 > @@ -420,19 +420,35 @@ add_files_recursive (notmuch_database_t *notmuch,\r
128 >            state->added_messages++;\r
129 >            for (tag=state->new_tags; *tag != NULL; tag++)\r
130 >                notmuch_message_add_tag (message, *tag);\r
131 > -           /* Defer sync of maildir flags until after old filenames\r
132 > -            * are removed in the case of a rename. */\r
133 > -           if (state->synchronize_flags == TRUE)\r
134 > -               _filename_list_add (state->message_ids_to_sync,\r
135 > -                                   notmuch_message_get_message_id\r
136 > (message));\r
137 > +           if (state->synchronize_flags == TRUE) {\r
138 > +               if (!state->total_files) {\r
139 > +                   /* Defer sync of maildir flags until after old\r
140 > filenames\r
141 > +                    * are removed in the case of a rename. */\r
142 > +                   _filename_list_add (state->message_ids_to_sync,\r
143 > +                                       notmuch_message_get_message_id\r
144 > (message));\r
145 > +               } else {\r
146 > +                   /* During the first notmuch new we synchronize\r
147 > +                    * flags immediately, while the message is hot in\r
148 > +                    * disk cache. */\r
149 > +                   notmuch_message_maildir_flags_to_tags (message);\r
150 > +               }\r
151 > +           }\r
152 >            break;\r
153 >        /* Non-fatal issues (go on to next file) */\r
154 >        case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:\r
155 > -           /* Defer sync of maildir flags until after old filenames\r
156 > -            * are removed in the case of a rename. */\r
157 > -           if (state->synchronize_flags == TRUE)\r
158 > -               _filename_list_add (state->message_ids_to_sync,\r
159 > -                                   notmuch_message_get_message_id\r
160 > (message));\r
161 > +           if (state->synchronize_flags == TRUE) {\r
162 > +               if (!state->total_files) {\r
163 > +                   /* Defer sync of maildir flags until after old\r
164 > filenames\r
165 > +                    * are removed in the case of a rename. */\r
166 > +                   _filename_list_add (state->message_ids_to_sync,\r
167 > +                                       notmuch_message_get_message_id\r
168 > (message));\r
169 > +               } else {\r
170 > +                   /* During the first notmuch new we synchronize\r
171 > +                    * flags immediately, while the message is hot in\r
172 > +                    * disk cache. */\r
173 > +                   notmuch_message_maildir_flags_to_tags (message);\r
174 > +               }\r
175 > +           }\r
176 >            break;\r
177 >        case NOTMUCH_STATUS_FILE_NOT_EMAIL:\r
178 >            fprintf (stderr, "Note: Ignoring non-mail file: %s\n",\r
179 > --\r
180 > 1.7.2.3\r
181 >\r
182 > _______________________________________________\r
183 > notmuch mailing list\r
184 > notmuch@notmuchmail.org\r
185 > http://notmuchmail.org/mailman/listinfo/notmuch\r
186 >\r
187 \r
188 --0016361e81a2836fbe049ab36e8f\r
189 Content-Type: text/html; charset=ISO-8859-1\r
190 Content-Transfer-Encoding: quoted-printable\r
191 \r
192 Wouldn&#39;t this be simpler and more general?<div><br></div><div><div><div=\r
193 >--- a/notmuch-new.c</div><div>+++ b/notmuch-new.c</div><div>@@ -419,12 +41=\r
194 9,11 @@ add_files_recursive (notmuch_database_t *notmuch,</div><div>=A0=A0 =\r
195 =A0 =A0 =A0case NOTMUCH_STATUS_SUCCESS:</div>\r
196 <div>=A0=A0 =A0 =A0 =A0 =A0 =A0state-&gt;added_messages++;</div><div>=A0=A0=\r
197  =A0 =A0 =A0 =A0 =A0for (tag=3Dstate-&gt;new_tags; *tag !=3D NULL; tag++)</=\r
198 div><div>=A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0notmuch_message_add_tag (message=\r
199 , *tag);</div><div>=A0=A0 =A0 =A0 =A0 =A0 =A0/* Defer sync of maildir flags=\r
200  until after old filenames</div>\r
201 <div>=A0=A0 =A0 =A0 =A0 =A0 =A0 * are removed in the case of a rename. */</=\r
202 div><div>=A0=A0 =A0 =A0 =A0 =A0 =A0if (state-&gt;synchronize_flags =3D=3D T=\r
203 RUE)</div><div>- =A0 =A0 =A0 =A0 =A0 =A0 =A0 _filename_list_add (state-&gt;=\r
204 message_ids_to_sync,</div><div>- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =\r
205 =A0 =A0 =A0 =A0 =A0 =A0 =A0 notmuch_message_get_message_id (message));</div=\r
206 >\r
207 <div>+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 notmuch_message_maildir_flags_to_tags (m=\r
208 essage);</div><div>=A0=A0 =A0 =A0 =A0 =A0 =A0break;</div><div>=A0=A0 =A0 =\r
209 =A0 =A0/* Non-fatal issues (go on to next file) */</div><div>=A0=A0 =A0 =A0=\r
210  =A0case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:</div>\r
211 <div><br></div></div><div>The idea is that, if=A0notmuch_database_add_messa=\r
212 ge returns=A0NOTMUCH_STATUS_SUCCESS, then we know this is a new message (an=\r
213 d not a rename or anything complicated) and thus might as well perform the =\r
214 flag synchronization immediately. =A0If it returns=A0NOTMUCH_STATUS_DUPLICA=\r
215 TE_MESSAGE_ID, then it could be a rename (or something more complicated), a=\r
216 nd so we defer the flag synchronization like usual. =A0This works for any n=\r
217 ew messages, regardless of whether this is the initial import or not.</div>\r
218 <div><br></div><div>I believe my reasoning is correct. =A0At least, it pass=\r
219 es the maildir sync test cases, so if it isn&#39;t correct, then we need mo=\r
220 re maildir sync tests.</div><meta http-equiv=3D"content-type" content=3D"te=\r
221 xt/html; charset=3Dutf-8"><div>\r
222 <br></div><div class=3D"gmail_quote">On Fri, Jan 21, 2011 at 4:59 AM, Micha=\r
223 l Sojka <span dir=3D"ltr">&lt;<a href=3D"mailto:sojkam1@fel.cvut.cz">sojkam=\r
224 1@fel.cvut.cz</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" st=\r
225 yle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">\r
226 When notmuch new is run for the first time, it is not necessary to defer<br=\r
227 >\r
228 maildir flags synchronization to later because we already know that no<br>\r
229 files will be removed.<br>\r
230 <br>\r
231 Performing the maildinr flag synchronization immediately after the<br>\r
232 message is added to the database has the advantage that the message is<br>\r
233 likely hot in the disk cache so the synchronization is faster.<br>\r
234 Additionally, we also save one database query for each message, which<br>\r
235 must be performed when the operation is deferred.<br>\r
236 <br>\r
237 Without this patchi, the first notmuch new of 200k messages (3 GB) took<br>\r
238 1h and 46m out of which 20m was maildir flags synchronization. With this<br=\r
239 >\r
240 patch, the whole operation took only 1h and 36m.<br>\r
241 ---<br>\r
242 =A0notmuch-new.c | =A0 36 ++++++++++++++++++++++++++----------<br>\r
243 =A01 files changed, 26 insertions(+), 10 deletions(-)<br>\r
244 <br>\r
245 diff --git a/notmuch-new.c b/notmuch-new.c<br>\r
246 index cdf8513..a2af045 100644<br>\r
247 --- a/notmuch-new.c<br>\r
248 +++ b/notmuch-new.c<br>\r
249 @@ -420,19 +420,35 @@ add_files_recursive (notmuch_database_t *notmuch,<br>\r
250  =A0 =A0 =A0 =A0 =A0 =A0state-&gt;added_messages++;<br>\r
251  =A0 =A0 =A0 =A0 =A0 =A0for (tag=3Dstate-&gt;new_tags; *tag !=3D NULL; tag+=\r
252 +)<br>\r
253  =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0notmuch_message_add_tag (message, *tag);<br=\r
254 >\r
255 - =A0 =A0 =A0 =A0 =A0 /* Defer sync of maildir flags until after old filena=\r
256 mes<br>\r
257 - =A0 =A0 =A0 =A0 =A0 =A0* are removed in the case of a rename. */<br>\r
258 - =A0 =A0 =A0 =A0 =A0 if (state-&gt;synchronize_flags =3D=3D TRUE)<br>\r
259 - =A0 =A0 =A0 =A0 =A0 =A0 =A0 _filename_list_add (state-&gt;message_ids_to_=\r
260 sync,<br>\r
261 - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 notmu=\r
262 ch_message_get_message_id (message));<br>\r
263 + =A0 =A0 =A0 =A0 =A0 if (state-&gt;synchronize_flags =3D=3D TRUE) {<br>\r
264 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!state-&gt;total_files) {<br>\r
265 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Defer sync of maildir flags until =\r
266 after old filenames<br>\r
267 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* are removed in the case of a ren=\r
268 ame. */<br>\r
269 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _filename_list_add (state-&gt;message=\r
270 _ids_to_sync,<br>\r
271 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =\r
272 =A0 notmuch_message_get_message_id (message));<br>\r
273 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {<br>\r
274 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* During the first notmuch new we sy=\r
275 nchronize<br>\r
276 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* flags immediately, while the mes=\r
277 sage is hot in<br>\r
278 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* disk cache. */<br>\r
279 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 notmuch_message_maildir_flags_to_tags=\r
280  (message);<br>\r
281 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }<br>\r
282 + =A0 =A0 =A0 =A0 =A0 }<br>\r
283  =A0 =A0 =A0 =A0 =A0 =A0break;<br>\r
284  =A0 =A0 =A0 =A0/* Non-fatal issues (go on to next file) */<br>\r
285  =A0 =A0 =A0 =A0case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:<br>\r
286 - =A0 =A0 =A0 =A0 =A0 /* Defer sync of maildir flags until after old filena=\r
287 mes<br>\r
288 - =A0 =A0 =A0 =A0 =A0 =A0* are removed in the case of a rename. */<br>\r
289 - =A0 =A0 =A0 =A0 =A0 if (state-&gt;synchronize_flags =3D=3D TRUE)<br>\r
290 - =A0 =A0 =A0 =A0 =A0 =A0 =A0 _filename_list_add (state-&gt;message_ids_to_=\r
291 sync,<br>\r
292 - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 notmu=\r
293 ch_message_get_message_id (message));<br>\r
294 + =A0 =A0 =A0 =A0 =A0 if (state-&gt;synchronize_flags =3D=3D TRUE) {<br>\r
295 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!state-&gt;total_files) {<br>\r
296 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Defer sync of maildir flags until =\r
297 after old filenames<br>\r
298 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* are removed in the case of a ren=\r
299 ame. */<br>\r
300 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _filename_list_add (state-&gt;message=\r
301 _ids_to_sync,<br>\r
302 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =\r
303 =A0 notmuch_message_get_message_id (message));<br>\r
304 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else {<br>\r
305 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* During the first notmuch new we sy=\r
306 nchronize<br>\r
307 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* flags immediately, while the mes=\r
308 sage is hot in<br>\r
309 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* disk cache. */<br>\r
310 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 notmuch_message_maildir_flags_to_tags=\r
311  (message);<br>\r
312 + =A0 =A0 =A0 =A0 =A0 =A0 =A0 }<br>\r
313 + =A0 =A0 =A0 =A0 =A0 }<br>\r
314  =A0 =A0 =A0 =A0 =A0 =A0break;<br>\r
315  =A0 =A0 =A0 =A0case NOTMUCH_STATUS_FILE_NOT_EMAIL:<br>\r
316  =A0 =A0 =A0 =A0 =A0 =A0fprintf (stderr, &quot;Note: Ignoring non-mail file=\r
317 : %s\n&quot;,<br>\r
318 <font color=3D"#888888">--<br>\r
319 1.7.2.3<br>\r
320 <br>\r
321 _______________________________________________<br>\r
322 notmuch mailing list<br>\r
323 <a href=3D"mailto:notmuch@notmuchmail.org">notmuch@notmuchmail.org</a><br>\r
324 <a href=3D"http://notmuchmail.org/mailman/listinfo/notmuch" target=3D"_blan=\r
325 k">http://notmuchmail.org/mailman/listinfo/notmuch</a><br>\r
326 </font></blockquote></div><br></div>\r
327 \r
328 --0016361e81a2836fbe049ab36e8f--\r