Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 2FCA36DE0350 for ; Fri, 15 Apr 2016 12:30:54 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.557 X-Spam-Level: X-Spam-Status: No, score=-0.557 tagged_above=-999 required=5 tests=[AWL=0.163, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IYV73PdIWT_y for ; Fri, 15 Apr 2016 12:30:46 -0700 (PDT) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by arlo.cworth.org (Postfix) with ESMTPS id 52E9E6DE014D for ; Fri, 15 Apr 2016 12:30:39 -0700 (PDT) Received: by mail-wm0-f68.google.com with SMTP id y144so8575913wmd.0 for ; Fri, 15 Apr 2016 12:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nikula-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=ZIIn8KghJ1jZoJ60VVVXUshVpwhEScEitCj5Vd6m4rU=; b=Ynzq7qdV4e1D/CXpL/w9lAG/3sbRJXp8ZBjCE8IQ5bI8B8kJm2Z+FZHvX+5UREXbXo 7wJysTiWiBwQfRi4sCYYDDTeGc5vV/pmwnY6RoUqofglCbsLqn2n/vUQl77fRPXxsOYM V4C36NxtRYPtT89f88SvAFywzx1dabGhUga6SDqrADvB3pZFEVxYy/KGKu934/04nU+H AvG62T9J7rSUbs3vgO2Xv9KsWkXGDTpA5ND+Bz7y6S2FzDicjndo2/sBldbZraLAyYhA KzHaOIrL6sFcZIy/8mw5n5Fq7cs7EKiGnRNVGpaMj5nzdlUVYO14vMGtyEYA59gZfJ81 i7Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=ZIIn8KghJ1jZoJ60VVVXUshVpwhEScEitCj5Vd6m4rU=; b=OrQGxP+BDs3+rcGN0fZJgJa4nW+H1OX328uJuY82/RLyQ1r0W9+c2r/q3zSro3mD97 q8XjaxjLWViMzLB75sZCHmPo4q3QvegysrZNLEvbCPawJBKowj9vVY2Yx7nCljj0KoYV QBJOfMcjywPGLQCrh5ePZe+zlvY0t+OSVerYp95BKGGEK9lmYo2OI+NRlp1yAoRAtOGz CP1FvHBO7pMvu2lKmaoP9vy+D9c1wWwy88TgLKWVk/y94xnH3UwM4LqXTaTnqH5JEQ/s sO5z3vw5+PFKxALuksR/wmInRMeOMRjEMTfWillCvYDWYDu4/xDtpyLe+R3pB41IqL6L SEhw== X-Gm-Message-State: AOPr4FUGkUteKVo/hMDU3zuVIB9bioS1BJcNhq5HDotlmBewKSkLiXEt1IgvuIeK2lgx5Q== X-Received: by 10.194.43.34 with SMTP id t2mr23487197wjl.58.1460748638069; Fri, 15 Apr 2016 12:30:38 -0700 (PDT) Received: from localhost (mobile-access-bcee7f-102.dhcp.inet.fi. [188.238.127.102]) by smtp.gmail.com with ESMTPSA id j10sm50452278wjb.46.2016.04.15.12.30.37 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Apr 2016 12:30:37 -0700 (PDT) From: Jani Nikula 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 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Apr 2016 19:30:54 -0000 The claim is that inode sort order leads to faster filesystem operation: commit a45ff8c36112a2f17c1ad5c20a16c30a47759797 Author: Stewart Smith 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