[PATCH v8 0/2] emacs: User-defined sections in notmuch-hello
[notmuch-archives.git] / e3 / 30181a198aaa971c57149c4b4e4c64ce0421aa
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 9F4D0431FB6\r
6         for <notmuch@notmuchmail.org>; Sun, 27 Feb 2011 00:45:10 -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.699\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
13         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 x6p35e7MVq+1 for <notmuch@notmuchmail.org>;\r
17         Sun, 27 Feb 2011 00:45:10 -0800 (PST)\r
18 Received: from mail-qy0-f174.google.com (mail-qy0-f174.google.com\r
19         [209.85.216.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id F1AE6431FB5\r
22         for <notmuch@notmuchmail.org>; Sun, 27 Feb 2011 00:45:09 -0800 (PST)\r
23 Received: by qyk7 with SMTP id 7so1548244qyk.5\r
24         for <notmuch@notmuchmail.org>; Sun, 27 Feb 2011 00:45:06 -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         :content-transfer-encoding;\r
29         bh=bKagnCGuB3Wxe7+J/y7hutn/LIAXkPKroEyAnsrijnw=;\r
30         b=D1+YKjG2XIMy9Yd2j+bfIdZG2wIbMQvvEFkqV+XSZimNdQ5do9hCapE07QvoxaBvQV\r
31         VVka/qu8f9LrzOaHPjUOJTi9JNGfXyyWHgnDZHErqpBY+COKhW8ieLNsY8HmAoxTsABs\r
32         03DvpsLi4AmKNcNsRtMlLxv3C7yR5ZiMW9NiA=\r
33 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
34         h=mime-version:sender:in-reply-to:references:date\r
35         :x-google-sender-auth:message-id:subject:from:to:cc:content-type\r
36         :content-transfer-encoding;\r
37         b=RppbrDi3j7v92MXvUtv4w99I6unzHUgVj0h0aKEkuVVmJdO86p6lfUg8btXjJyJrFo\r
38         DTMbEq5e53vWTvVmMobiJG5bpLMXUl2y2QQvGaH7UL52k4akgzwXITOq/Iq3F9TK38/3\r
39         ph7pJh1x8vG6oGs0eWwhIvBwZmZOoedeVbgxA=\r
40 MIME-Version: 1.0\r
41 Received: by 10.229.89.84 with SMTP id d20mr3269021qcm.100.1298796305133; Sun,\r
42         27 Feb 2011 00:45:05 -0800 (PST)\r
43 Sender: amdragon@gmail.com\r
44 Received: by 10.229.105.68 with HTTP; Sun, 27 Feb 2011 00:45:05 -0800 (PST)\r
45 In-Reply-To: <1296855871-15702-1-git-send-email-kzak@redhat.com>\r
46 References: <1296855871-15702-1-git-send-email-kzak@redhat.com>\r
47 Date: Sun, 27 Feb 2011 03:45:05 -0500\r
48 X-Google-Sender-Auth: MaJ-nspqing9qwhz-sKupkzx9yM\r
49 Message-ID: <AANLkTi=PfbB9Fv6euxuzsjOkSsj-EqQxTFuz9ucfzJHi@mail.gmail.com>\r
50 Subject: Re: [PATCH] new: read db_files and db_subdirs if mtime changed\r
51 From: Austin Clements <amdragon@mit.edu>\r
52 To: Karel Zak <kzak@redhat.com>\r
53 Content-Type: text/plain; charset=ISO-8859-1\r
54 Content-Transfer-Encoding: quoted-printable\r
55 Cc: notmuch@notmuchmail.org\r
56 X-BeenThere: notmuch@notmuchmail.org\r
57 X-Mailman-Version: 2.1.13\r
58 Precedence: list\r
59 List-Id: "Use and development of the notmuch mail system."\r
60         <notmuch.notmuchmail.org>\r
61 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
63 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
64 List-Post: <mailto:notmuch@notmuchmail.org>\r
65 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
66 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
67         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
68 X-List-Received-Date: Sun, 27 Feb 2011 08:45:10 -0000\r
69 \r
70 Looks good (faster than, but provably equivalent to the original code!\r
71  notmuch_directory_get_child_* are side-effect free,\r
72 db_files/db_subdirs aren't used between where they were set in the old\r
73 code and where they are set in the new code, and db_files/db_subdirs\r
74 are initialized to NULL when declared).\r
75 \r
76 Another timing data point:\r
77 Old code: ./notmuch new  0.77s user 0.28s system 99% cpu 1.051 total\r
78 New code: ./notmuch new  0.09s user 0.27s system 98% cpu 0.368 total\r
79 \r
80 I wonder if an even faster approach than the current recursive walk\r
81 would be to get *all* of the directory names and mtimes out of Xapian\r
82 in one pass and stat them all.  If the mtime didn't change, then\r
83 there's no need to scandir that directory at all.  This could even\r
84 beat the "time find >/dev/null" bound, but the gains may be too\r
85 marginal to make it worthwhile.\r
86 \r
87 On Fri, Feb 4, 2011 at 4:44 PM, Karel Zak <kzak@redhat.com> wrote:\r
88 > The db_files and db_subdirs are unnecessary for unchanged directories.\r
89 >\r
90 > maildir with 10000 e-mails:\r
91 >\r
92 > old version:\r
93 > =A0 =A0 =A0 =A0$ time ./notmuch new\r
94 > =A0 =A0 =A0 =A0No new mail.\r
95 >\r
96 > =A0 =A0 =A0 =A0real =A0 =A00m0.053s\r
97 > =A0 =A0 =A0 =A0user =A0 =A00m0.028s\r
98 > =A0 =A0 =A0 =A0sys =A0 =A0 0m0.026s\r
99 >\r
100 > new version:\r
101 > =A0 =A0 =A0 =A0$ time ./notmuch new\r
102 > =A0 =A0 =A0 =A0No new mail.\r
103 >\r
104 > =A0 =A0 =A0 =A0real =A0 =A00m0.032s\r
105 > =A0 =A0 =A0 =A0user =A0 =A00m0.009s\r
106 > =A0 =A0 =A0 =A0sys =A0 =A0 0m0.023s\r
107 >\r
108 > Signed-off-by: Karel Zak <kzak@redhat.com>\r
109 > ---\r
110 > =A0notmuch-new.c | =A0 15 ++++++---------\r
111 > =A01 files changed, 6 insertions(+), 9 deletions(-)\r
112 >\r
113 > diff --git a/notmuch-new.c b/notmuch-new.c\r
114 > index 941f9d6..31d4553 100644\r
115 > --- a/notmuch-new.c\r
116 > +++ b/notmuch-new.c\r
117 > @@ -247,15 +247,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
118 > =A0 =A0 directory =3D notmuch_database_get_directory (notmuch, path);\r
119 > =A0 =A0 db_mtime =3D notmuch_directory_get_mtime (directory);\r
120 >\r
121 > - =A0 =A0if (db_mtime =3D=3D 0) {\r
122 > - =A0 =A0 =A0 new_directory =3D TRUE;\r
123 > - =A0 =A0 =A0 db_files =3D NULL;\r
124 > - =A0 =A0 =A0 db_subdirs =3D NULL;\r
125 > - =A0 =A0} else {\r
126 > - =A0 =A0 =A0 new_directory =3D FALSE;\r
127 > - =A0 =A0 =A0 db_files =3D notmuch_directory_get_child_files (directory);\r
128 > - =A0 =A0 =A0 db_subdirs =3D notmuch_directory_get_child_directories (dir=\r
129 ectory);\r
130 > - =A0 =A0}\r
131 > + =A0 =A0new_directory =3D db_mtime ? FALSE : TRUE;\r
132 >\r
133 > =A0 =A0 /* If the database knows about this directory, then we sort based\r
134 > =A0 =A0 =A0* on strcmp to match the database sorting. Otherwise, we can d=\r
135 o\r
136 > @@ -328,6 +320,11 @@ add_files_recursive (notmuch_database_t *notmuch,\r
137 > =A0 =A0 if (fs_mtime =3D=3D db_mtime)\r
138 > =A0 =A0 =A0 =A0goto DONE;\r
139 >\r
140 > + =A0 =A0if (!new_directory) {\r
141 > + =A0 =A0 =A0 db_files =3D notmuch_directory_get_child_files (directory);\r
142 > + =A0 =A0 =A0 db_subdirs =3D notmuch_directory_get_child_directories (dir=\r
143 ectory);\r
144 > + =A0 =A0}\r
145 > +\r
146 > =A0 =A0 /* Pass 2: Scan for new files, removed files, and removed directo=\r
147 ries. */\r
148 > =A0 =A0 for (i =3D 0; i < num_fs_entries; i++)\r
149 > =A0 =A0 {\r
150 > --\r
151 > 1.7.3.4\r
152 >\r
153 > _______________________________________________\r
154 > notmuch mailing list\r
155 > notmuch@notmuchmail.org\r
156 > http://notmuchmail.org/mailman/listinfo/notmuch\r
157 >\r