unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [RFC PATCH 2/5] cli: drop inode sort order on directories unknown to the database
Date: Fri, 15 Apr 2016 22:29:16 +0300	[thread overview]
Message-ID: <af16ea8e7b415662343e7f812de219f07b642561.1460748142.git.jani@nikula.org> (raw)
In-Reply-To: <cover.1460748142.git.jani@nikula.org>
In-Reply-To: <cover.1460748142.git.jani@nikula.org>

The claim is that inode sort order leads to faster filesystem
operation:

commit a45ff8c36112a2f17c1ad5c20a16c30a47759797
Author: Stewart Smith <stewart@flamingspork.com>
Date:   Wed Nov 18 12:56:40 2009 +1100

    Read mail directory in inode number order

The numbers cited seem convincing, but since then we've limited the
inode sorting to directories new to the database. Directories known to
the database are scanned in asciibetical order.

Making this change helps future work, and having it as a standalone
step makes it easier to evaluate the potential performance impact.
---
 notmuch-new.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 2d975eb5b640..930cbbc9b86f 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -151,12 +151,6 @@ generic_print_progress (const char *action, const char *object,
 }
 
 static int
-dirent_sort_inode (const struct dirent **a, const struct dirent **b)
-{
-    return ((*a)->d_ino < (*b)->d_ino) ? -1 : 1;
-}
-
-static int
 dirent_sort_strcmp_name (const struct dirent **a, const struct dirent **b)
 {
     return strcmp ((*a)->d_name, (*b)->d_name);
@@ -415,11 +409,10 @@ add_files (notmuch_database_t *notmuch,
     }
 
     /* If the database knows about this directory, then we sort based
-     * on strcmp to match the database sorting. Otherwise, we can do
-     * inode-based sorting for faster filesystem operation. */
+     * on strcmp to match the database sorting. */
     num_fs_entries = scandir (path, &fs_entries, 0,
 			      directory ?
-			      dirent_sort_strcmp_name : dirent_sort_inode);
+			      dirent_sort_strcmp_name : NULL);
 
     if (num_fs_entries == -1) {
 	fprintf (stderr, "Error opening directory %s: %s\n",
@@ -722,7 +715,7 @@ count_files (const char *path, int *count, add_files_state_t *state)
     struct dirent *entry = NULL;
     char *next;
     struct dirent **fs_entries = NULL;
-    int num_fs_entries = scandir (path, &fs_entries, 0, dirent_sort_inode);
+    int num_fs_entries = scandir (path, &fs_entries, 0, NULL);
     int entry_type, i;
 
     if (num_fs_entries == -1) {
-- 
2.1.4

  parent reply	other threads:[~2016-04-15 19:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-15 19:29 [RFC PATCH 0/5] cli: notmuch new scandir rework Jani Nikula
2016-04-15 19:29 ` [RFC PATCH 1/5] cli: remove leftover dir variable Jani Nikula
2016-05-02 11:23   ` David Bremner
2016-04-15 19:29 ` Jani Nikula [this message]
2016-04-15 19:29 ` [RFC PATCH 3/5] util: add a homebrew scandir implementation Jani Nikula
2016-04-15 19:29 ` [RFC PATCH 4/5] cli: use homebrew scandir in notmuch new add_files Jani Nikula
2016-04-15 19:29 ` [RFC PATCH 5/5] cli: convert count_files to new scandir Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=af16ea8e7b415662343e7f812de219f07b642561.1460748142.git.jani@nikula.org \
    --to=jani@nikula.org \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).