Re: Emacs: Crypto: How to get automatic encryption?
[notmuch-archives.git] / 87 / 55ab4c0bb0c06e157e7779eeb60f2eda36e082
1 Return-Path: <sojkam1@fel.cvut.cz>\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 3568A431FD0\r
6         for <notmuch@notmuchmail.org>; Fri, 21 Jan 2011 01:59:49 -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\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\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 wA9ER4uoxzDi for <notmuch@notmuchmail.org>;\r
16         Fri, 21 Jan 2011 01:59:48 -0800 (PST)\r
17 Received: from mail.loccal.net (gw.loccal.net [94.142.235.206])\r
18         by olra.theworths.org (Postfix) with ESMTP id A1027431FB6\r
19         for <notmuch@notmuchmail.org>; Fri, 21 Jan 2011 01:59:47 -0800 (PST)\r
20 Received: from localhost (localhost [127.0.0.1])\r
21         by mail.loccal.net (Postfix) with ESMTP id E57FE563D;\r
22         Fri, 21 Jan 2011 11:12:22 +0100 (CET)\r
23 X-Virus-Scanned: amavisd-new at loccal.net\r
24 Received: from mail.loccal.net ([127.0.0.1])\r
25         by localhost (mail.loccal.net [127.0.0.1]) (amavisd-new, port 10024)\r
26         with LMTP id tdn0bdnivyZu; Fri, 21 Jan 2011 11:12:18 +0100 (CET)\r
27 Received: from steelpick.2x.cz (unknown [10.21.129.4])\r
28         by mail.loccal.net (Postfix) with ESMTPS id CA40810456;\r
29         Fri, 21 Jan 2011 11:12:18 +0100 (CET)\r
30 Received: from wsh by steelpick.2x.cz with local (Exim 4.72)\r
31         (envelope-from <sojkam1@fel.cvut.cz>)\r
32         id 1PgDmP-0003jg-16; Fri, 21 Jan 2011 10:59:41 +0100\r
33 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH 1/3] Do not defer maildir flag synchronization during the\r
36         first notmuch new\r
37 Date: Fri, 21 Jan 2011 10:59:34 +0100\r
38 Message-Id: <1295603977-14326-2-git-send-email-sojkam1@fel.cvut.cz>\r
39 X-Mailer: git-send-email 1.7.2.3\r
40 In-Reply-To: <1295603977-14326-1-git-send-email-sojkam1@fel.cvut.cz>\r
41 References: <1295603977-14326-1-git-send-email-sojkam1@fel.cvut.cz>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Fri, 21 Jan 2011 09:59:49 -0000\r
55 \r
56 When notmuch new is run for the first time, it is not necessary to defer\r
57 maildir flags synchronization to later because we already know that no\r
58 files will be removed.\r
59 \r
60 Performing the maildinr flag synchronization immediately after the\r
61 message is added to the database has the advantage that the message is\r
62 likely hot in the disk cache so the synchronization is faster.\r
63 Additionally, we also save one database query for each message, which\r
64 must be performed when the operation is deferred.\r
65 \r
66 Without this patchi, the first notmuch new of 200k messages (3 GB) took\r
67 1h and 46m out of which 20m was maildir flags synchronization. With this\r
68 patch, the whole operation took only 1h and 36m.\r
69 ---\r
70  notmuch-new.c |   36 ++++++++++++++++++++++++++----------\r
71  1 files changed, 26 insertions(+), 10 deletions(-)\r
72 \r
73 diff --git a/notmuch-new.c b/notmuch-new.c\r
74 index cdf8513..a2af045 100644\r
75 --- a/notmuch-new.c\r
76 +++ b/notmuch-new.c\r
77 @@ -420,19 +420,35 @@ add_files_recursive (notmuch_database_t *notmuch,\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 (message));\r
86 +           if (state->synchronize_flags == TRUE) {\r
87 +               if (!state->total_files) {\r
88 +                   /* Defer sync of maildir flags until after old filenames\r
89 +                    * are removed in the case of a rename. */\r
90 +                   _filename_list_add (state->message_ids_to_sync,\r
91 +                                       notmuch_message_get_message_id (message));\r
92 +               } else {\r
93 +                   /* During the first notmuch new we synchronize\r
94 +                    * flags immediately, while the message is hot in\r
95 +                    * disk cache. */\r
96 +                   notmuch_message_maildir_flags_to_tags (message);\r
97 +               }\r
98 +           }\r
99             break;\r
100         /* Non-fatal issues (go on to next file) */\r
101         case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:\r
102 -           /* Defer sync of maildir flags until after old filenames\r
103 -            * are removed in the case of a rename. */\r
104 -           if (state->synchronize_flags == TRUE)\r
105 -               _filename_list_add (state->message_ids_to_sync,\r
106 -                                   notmuch_message_get_message_id (message));\r
107 +           if (state->synchronize_flags == TRUE) {\r
108 +               if (!state->total_files) {\r
109 +                   /* Defer sync of maildir flags until after old filenames\r
110 +                    * are removed in the case of a rename. */\r
111 +                   _filename_list_add (state->message_ids_to_sync,\r
112 +                                       notmuch_message_get_message_id (message));\r
113 +               } else {\r
114 +                   /* During the first notmuch new we synchronize\r
115 +                    * flags immediately, while the message is hot in\r
116 +                    * disk cache. */\r
117 +                   notmuch_message_maildir_flags_to_tags (message);\r
118 +               }\r
119 +           }\r
120             break;\r
121         case NOTMUCH_STATUS_FILE_NOT_EMAIL:\r
122             fprintf (stderr, "Note: Ignoring non-mail file: %s\n",\r
123 -- \r
124 1.7.2.3\r
125 \r