summaryrefslogtreecommitdiff
path: root/modules/fts
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-09-16 10:05:47 +0200
committerJim Meyering <meyering@redhat.com>2008-09-26 13:37:55 +0200
commit2f2978ede97205c49d3e568ccffa5a04fb53326b (patch)
tree1fc60dc7fc9e123d6ee65d1cc9a020db0e1b058e /modules/fts
parent321f80d0ad62a3fefe8a66b287e3b4e587e44d69 (diff)
downloadgnulib-2f2978ede97205c49d3e568ccffa5a04fb53326b.tar.gz
fts: sort dirent entries on inode number before traversing
This avoids a quadratic, seek-related performance penalty when operating on a directory containing many entries (measurable at 10k; 3.5 hours at 2 million entries with a cold cache) on certain types of file systems, including ext3 and ext4, but not tmpfs. * lib/fts.c (DT_MUST_BE, NOT_AN_INODE_NUMBER, D_INO): Define. (FTS_INODE_SORT_DIR_ENTRIES_THRESHOLD): Define if not defined. (S_MAGIC_TMPFS, S_MAGIC_NFS): Define. (fs_handles_readdir_ordered_dirents_efficiently): New function. (dirent_inode_sort_may_be_useful, fts_compare_ino): Likewise. (fts_build): Set the stat.st_ino member from D_INO. If it is likely to be useful, sort dirent entries on inode number. * m4/fts.m4 (gl_FUNC_FTS_CORE): Check for fstatfs, sys/vfs.h, and the struct statfs.f_type member. * modules/fts (Depends-on): Add d-ino.
Diffstat (limited to 'modules/fts')
-rw-r--r--modules/fts1
1 files changed, 1 insertions, 0 deletions
diff --git a/modules/fts b/modules/fts
index b45f0260ba..a412d0ac9d 100644
--- a/modules/fts
+++ b/modules/fts
@@ -9,6 +9,7 @@ m4/fts.m4
Depends-on:
cycle-check
+d-ino
d-type
dirfd
fchdir