[RFC PATCH 2/5] cli: drop inode sort order on directories unknown to the database
[notmuch-archives.git] / aa / 38ddf5e51b04f6e1d8360e25a2fbd071e864ac
1 Return-Path: <jani@nikula.org>\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 arlo.cworth.org (Postfix) with ESMTP id 2FCA36DE0350\r
6  for <notmuch@notmuchmail.org>; Fri, 15 Apr 2016 12:30:54 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
9 X-Spam-Flag: NO\r
10 X-Spam-Score: -0.557\r
11 X-Spam-Level: \r
12 X-Spam-Status: No, score=-0.557 tagged_above=-999 required=5 tests=[AWL=0.163,\r
13   DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
14  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled\r
15 Received: from arlo.cworth.org ([127.0.0.1])\r
16  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
17  with ESMTP id IYV73PdIWT_y for <notmuch@notmuchmail.org>;\r
18  Fri, 15 Apr 2016 12:30:46 -0700 (PDT)\r
19 Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com\r
20  [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 52E9E6DE014D for\r
21  <notmuch@notmuchmail.org>; Fri, 15 Apr 2016 12:30:39 -0700 (PDT)\r
22 Received: by mail-wm0-f68.google.com with SMTP id y144so8575913wmd.0\r
23  for <notmuch@notmuchmail.org>; Fri, 15 Apr 2016 12:30:39 -0700 (PDT)\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25  d=nikula-org.20150623.gappssmtp.com; s=20150623;\r
26  h=from:to:cc:subject:date:message-id:in-reply-to:references\r
27  :in-reply-to:references;\r
28  bh=ZIIn8KghJ1jZoJ60VVVXUshVpwhEScEitCj5Vd6m4rU=;\r
29  b=Ynzq7qdV4e1D/CXpL/w9lAG/3sbRJXp8ZBjCE8IQ5bI8B8kJm2Z+FZHvX+5UREXbXo\r
30  7wJysTiWiBwQfRi4sCYYDDTeGc5vV/pmwnY6RoUqofglCbsLqn2n/vUQl77fRPXxsOYM\r
31  V4C36NxtRYPtT89f88SvAFywzx1dabGhUga6SDqrADvB3pZFEVxYy/KGKu934/04nU+H\r
32  AvG62T9J7rSUbs3vgO2Xv9KsWkXGDTpA5ND+Bz7y6S2FzDicjndo2/sBldbZraLAyYhA\r
33  KzHaOIrL6sFcZIy/8mw5n5Fq7cs7EKiGnRNVGpaMj5nzdlUVYO14vMGtyEYA59gZfJ81\r
34  i7Ew==\r
35 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
36  d=1e100.net; s=20130820;\r
37  h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
38  :references:in-reply-to:references;\r
39  bh=ZIIn8KghJ1jZoJ60VVVXUshVpwhEScEitCj5Vd6m4rU=;\r
40  b=OrQGxP+BDs3+rcGN0fZJgJa4nW+H1OX328uJuY82/RLyQ1r0W9+c2r/q3zSro3mD97\r
41  q8XjaxjLWViMzLB75sZCHmPo4q3QvegysrZNLEvbCPawJBKowj9vVY2Yx7nCljj0KoYV\r
42  QBJOfMcjywPGLQCrh5ePZe+zlvY0t+OSVerYp95BKGGEK9lmYo2OI+NRlp1yAoRAtOGz\r
43  CP1FvHBO7pMvu2lKmaoP9vy+D9c1wWwy88TgLKWVk/y94xnH3UwM4LqXTaTnqH5JEQ/s\r
44  sO5z3vw5+PFKxALuksR/wmInRMeOMRjEMTfWillCvYDWYDu4/xDtpyLe+R3pB41IqL6L\r
45  SEhw==\r
46 X-Gm-Message-State:\r
47  AOPr4FUGkUteKVo/hMDU3zuVIB9bioS1BJcNhq5HDotlmBewKSkLiXEt1IgvuIeK2lgx5Q==\r
48 X-Received: by 10.194.43.34 with SMTP id t2mr23487197wjl.58.1460748638069;\r
49  Fri, 15 Apr 2016 12:30:38 -0700 (PDT)\r
50 Received: from localhost (mobile-access-bcee7f-102.dhcp.inet.fi.\r
51  [188.238.127.102])\r
52  by smtp.gmail.com with ESMTPSA id j10sm50452278wjb.46.2016.04.15.12.30.37\r
53  (version=TLSv1/SSLv3 cipher=OTHER);\r
54  Fri, 15 Apr 2016 12:30:37 -0700 (PDT)\r
55 From: Jani Nikula <jani@nikula.org>\r
56 To: notmuch@notmuchmail.org\r
57 Subject: [RFC PATCH 2/5] cli: drop inode sort order on directories unknown to\r
58  the database\r
59 Date: Fri, 15 Apr 2016 22:29:16 +0300\r
60 Message-Id:\r
61  <af16ea8e7b415662343e7f812de219f07b642561.1460748142.git.jani@nikula.org>\r
62 X-Mailer: git-send-email 2.1.4\r
63 In-Reply-To: <cover.1460748142.git.jani@nikula.org>\r
64 References: <cover.1460748142.git.jani@nikula.org>\r
65 In-Reply-To: <cover.1460748142.git.jani@nikula.org>\r
66 References: <cover.1460748142.git.jani@nikula.org>\r
67 X-BeenThere: notmuch@notmuchmail.org\r
68 X-Mailman-Version: 2.1.20\r
69 Precedence: list\r
70 List-Id: "Use and development of the notmuch mail system."\r
71  <notmuch.notmuchmail.org>\r
72 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
73  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
74 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
75 List-Post: <mailto:notmuch@notmuchmail.org>\r
76 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
77 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
78  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
79 X-List-Received-Date: Fri, 15 Apr 2016 19:30:54 -0000\r
80 \r
81 The claim is that inode sort order leads to faster filesystem\r
82 operation:\r
83 \r
84 commit a45ff8c36112a2f17c1ad5c20a16c30a47759797\r
85 Author: Stewart Smith <stewart@flamingspork.com>\r
86 Date:   Wed Nov 18 12:56:40 2009 +1100\r
87 \r
88     Read mail directory in inode number order\r
89 \r
90 The numbers cited seem convincing, but since then we've limited the\r
91 inode sorting to directories new to the database. Directories known to\r
92 the database are scanned in asciibetical order.\r
93 \r
94 Making this change helps future work, and having it as a standalone\r
95 step makes it easier to evaluate the potential performance impact.\r
96 ---\r
97  notmuch-new.c | 13 +++----------\r
98  1 file changed, 3 insertions(+), 10 deletions(-)\r
99 \r
100 diff --git a/notmuch-new.c b/notmuch-new.c\r
101 index 2d975eb5b640..930cbbc9b86f 100644\r
102 --- a/notmuch-new.c\r
103 +++ b/notmuch-new.c\r
104 @@ -151,12 +151,6 @@ generic_print_progress (const char *action, const char *object,\r
105  }\r
106  \r
107  static int\r
108 -dirent_sort_inode (const struct dirent **a, const struct dirent **b)\r
109 -{\r
110 -    return ((*a)->d_ino < (*b)->d_ino) ? -1 : 1;\r
111 -}\r
112 -\r
113 -static int\r
114  dirent_sort_strcmp_name (const struct dirent **a, const struct dirent **b)\r
115  {\r
116      return strcmp ((*a)->d_name, (*b)->d_name);\r
117 @@ -415,11 +409,10 @@ add_files (notmuch_database_t *notmuch,\r
118      }\r
119  \r
120      /* If the database knows about this directory, then we sort based\r
121 -     * on strcmp to match the database sorting. Otherwise, we can do\r
122 -     * inode-based sorting for faster filesystem operation. */\r
123 +     * on strcmp to match the database sorting. */\r
124      num_fs_entries = scandir (path, &fs_entries, 0,\r
125                               directory ?\r
126 -                             dirent_sort_strcmp_name : dirent_sort_inode);\r
127 +                             dirent_sort_strcmp_name : NULL);\r
128  \r
129      if (num_fs_entries == -1) {\r
130         fprintf (stderr, "Error opening directory %s: %s\n",\r
131 @@ -722,7 +715,7 @@ count_files (const char *path, int *count, add_files_state_t *state)\r
132      struct dirent *entry = NULL;\r
133      char *next;\r
134      struct dirent **fs_entries = NULL;\r
135 -    int num_fs_entries = scandir (path, &fs_entries, 0, dirent_sort_inode);\r
136 +    int num_fs_entries = scandir (path, &fs_entries, 0, NULL);\r
137      int entry_type, i;\r
138  \r
139      if (num_fs_entries == -1) {\r
140 -- \r
141 2.1.4\r
142 \r