From 96d91141cf06028d68c7fce4ea6182b2ec1f5468 Mon Sep 17 00:00:00 2001 From: Diego Ongaro Date: Wed, 2 Sep 2020 17:41:35 -0700 Subject: [PATCH 4/5] find: Set FTS_DEFER_STAT flag for sort performance This makes the performance with -s much closer to unsorted. --- find/ftsfind.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/find/ftsfind.c b/find/ftsfind.c index aa27666c..43799b57 100644 --- a/find/ftsfind.c +++ b/find/ftsfind.c @@ -63,8 +63,12 @@ /* FTS_TIGHT_CYCLE_CHECK tries to work around Savannah bug #17877 * (but actually using it doesn't fix the bug). + * + * FTS_DEFER_STAT is useful (even with FTS_NOSTAT set) when a compare function + * is passed to fts_open. Without this, the presence of a compare function + * causes FTS to fetch the stats. */ -static int ftsoptions = FTS_NOSTAT|FTS_TIGHT_CYCLE_CHECK|FTS_CWDFD|FTS_VERBATIM; +static int ftsoptions = FTS_NOSTAT|FTS_DEFER_STAT|FTS_TIGHT_CYCLE_CHECK|FTS_CWDFD|FTS_VERBATIM; static int prev_depth = INT_MIN; /* fts_level can be < 0 */ static int curr_fd = -1; -- 2.27.0