Skip to content

Commit 78d024d

Browse files
benpeartdscho
authored andcommitted
Enable the filesystem cache (fscache) in refresh_index().
On file systems that support it, this can dramatically speed up operations like add, commit, describe, rebase, reset, rm that would otherwise have to lstat() every file to "re-match" the stat information in the index to that of the file system. On a synthetic repo with 1M files, "git reset" dropped from 52.02 seconds to 14.42 seconds for a savings of 72%. Signed-off-by: Ben Peart <[email protected]>
1 parent 8807f87 commit 78d024d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

read-cache.c

+2
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
16301630
typechange_fmt = in_porcelain ? "T\t%s\n" : "%s: needs update\n";
16311631
added_fmt = in_porcelain ? "A\t%s\n" : "%s: needs update\n";
16321632
unmerged_fmt = in_porcelain ? "U\t%s\n" : "%s: needs merge\n";
1633+
enable_fscache(1);
16331634
/*
16341635
* Use the multi-threaded preload_index() to refresh most of the
16351636
* cache entries quickly then in the single threaded loop below,
@@ -1724,6 +1725,7 @@ int refresh_index(struct index_state *istate, unsigned int flags,
17241725
display_progress(progress, istate->cache_nr);
17251726
stop_progress(&progress);
17261727
trace_performance_leave("refresh index");
1728+
enable_fscache(0);
17271729
return has_errors;
17281730
}
17291731

0 commit comments

Comments
 (0)