[PATCH] new: read db_files and db_subdirs if mtime changed
authorKarel Zak <kzak@redhat.com>
Fri, 4 Feb 2011 21:44:31 +0000 (22:44 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:52 +0000 (09:37 -0800)
2f/637779d71fe70bb6a44a3dbf380f2f43790cff [new file with mode: 0644]

diff --git a/2f/637779d71fe70bb6a44a3dbf380f2f43790cff b/2f/637779d71fe70bb6a44a3dbf380f2f43790cff
new file mode 100644 (file)
index 0000000..b014a60
--- /dev/null
@@ -0,0 +1,108 @@
+Return-Path: <kzak@redhat.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id CAC38431FB6\r
+       for <notmuch@notmuchmail.org>; Fri,  4 Feb 2011 13:45:11 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -5\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-5 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_HI=-5] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id rVyzu0IWKlpE for <notmuch@notmuchmail.org>;\r
+       Fri,  4 Feb 2011 13:45:10 -0800 (PST)\r
+Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28])\r
+       by olra.theworths.org (Postfix) with ESMTP id A414A431FB5\r
+       for <notmuch@notmuchmail.org>; Fri,  4 Feb 2011 13:45:10 -0800 (PST)\r
+Received: from int-mx01.intmail.prod.int.phx2.redhat.com\r
+       (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\r
+       by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p14LjAi6003573\r
+       (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)\r
+       for <notmuch@notmuchmail.org>; Fri, 4 Feb 2011 16:45:10 -0500\r
+Received: from nb.net.home (vpn-238-160.phx2.redhat.com [10.3.238.160])\r
+       by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP\r
+       id p14Lj8JO024777; Fri, 4 Feb 2011 16:45:09 -0500\r
+From: Karel Zak <kzak@redhat.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] new: read db_files and db_subdirs if mtime changed\r
+Date: Fri,  4 Feb 2011 22:44:31 +0100\r
+Message-Id: <1296855871-15702-1-git-send-email-kzak@redhat.com>\r
+X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 04 Feb 2011 21:45:11 -0000\r
+\r
+The db_files and db_subdirs are unnecessary for unchanged directories.\r
+\r
+maildir with 10000 e-mails:\r
+\r
+old version:\r
+       $ time ./notmuch new\r
+       No new mail.\r
+\r
+       real    0m0.053s\r
+       user    0m0.028s\r
+       sys     0m0.026s\r
+\r
+new version:\r
+       $ time ./notmuch new\r
+       No new mail.\r
+\r
+       real    0m0.032s\r
+       user    0m0.009s\r
+       sys     0m0.023s\r
+\r
+Signed-off-by: Karel Zak <kzak@redhat.com>\r
+---\r
+ notmuch-new.c |   15 ++++++---------\r
+ 1 files changed, 6 insertions(+), 9 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index 941f9d6..31d4553 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -247,15 +247,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+     directory = notmuch_database_get_directory (notmuch, path);\r
+     db_mtime = notmuch_directory_get_mtime (directory);\r
\r
+-    if (db_mtime == 0) {\r
+-      new_directory = TRUE;\r
+-      db_files = NULL;\r
+-      db_subdirs = NULL;\r
+-    } else {\r
+-      new_directory = FALSE;\r
+-      db_files = notmuch_directory_get_child_files (directory);\r
+-      db_subdirs = notmuch_directory_get_child_directories (directory);\r
+-    }\r
++    new_directory = db_mtime ? FALSE : TRUE;\r
\r
+     /* If the database knows about this directory, then we sort based\r
+      * on strcmp to match the database sorting. Otherwise, we can do\r
+@@ -328,6 +320,11 @@ add_files_recursive (notmuch_database_t *notmuch,\r
+     if (fs_mtime == db_mtime)\r
+       goto DONE;\r
\r
++    if (!new_directory) {\r
++      db_files = notmuch_directory_get_child_files (directory);\r
++      db_subdirs = notmuch_directory_get_child_directories (directory);\r
++    }\r
++\r
+     /* Pass 2: Scan for new files, removed files, and removed directories. */\r
+     for (i = 0; i < num_fs_entries; i++)\r
+     {\r
+-- \r
+1.7.3.4\r
+\r